Skip to content

Commit cca001a

Browse files
committed
Rust: address comments
1 parent b10a296 commit cca001a

File tree

3 files changed

+15
-32
lines changed

3 files changed

+15
-32
lines changed

rust/ql/lib/codeql/rust/Concepts.qll

+1-8
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,7 @@ module Cryptography {
269269

270270
/** Provides classes for modeling path-related APIs. */
271271
module Path {
272-
/**
273-
* A data-flow node that performs path normalization. This is often needed in order
274-
* to safely access paths.
275-
*/
276-
class PathNormalization extends DataFlow::Node instanceof PathNormalization::Range {
277-
/** Gets an argument to this path normalization that is interpreted as a path. */
278-
DataFlow::Node getPathArg() { result = super.getPathArg() }
279-
}
272+
final class PathNormalization = PathNormalization::Range;
280273

281274
/** Provides a class for modeling new path normalization APIs. */
282275
module PathNormalization {

rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll

+9-10
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,15 @@ module RustDataFlow implements InputSig<Location> {
720720
not isSpecialContentSet(cs)
721721
}
722722

723+
/**
724+
* Holds if `cs` is used to encode a special operation as a content component, but should not
725+
* be treated as an ordinary content component.
726+
*/
727+
private predicate isSpecialContentSet(ContentSet cs) {
728+
cs instanceof TOptionalStep or
729+
cs instanceof TOptionalBarrier
730+
}
731+
723732
pragma[nomagic]
724733
private predicate fieldAssignment(Node node1, Node node2, FieldContent c) {
725734
exists(AssignmentExprCfgNode assignment, FieldExprCfgNode access |
@@ -1110,16 +1119,6 @@ private module Cached {
11101119
name = any(FlowSummaryImpl::Private::AccessPathToken tok).getAnArgument("OptionalBarrier")
11111120
}
11121121

1113-
/**
1114-
* Holds if `cs` is used to encode a special operation as a content component, but should not
1115-
* be treated as an ordinary content component.
1116-
*/
1117-
cached
1118-
predicate isSpecialContentSet(ContentSet cs) {
1119-
cs instanceof TOptionalStep or
1120-
cs instanceof TOptionalBarrier
1121-
}
1122-
11231122
/** Holds if `n` is a flow source of kind `kind`. */
11241123
cached
11251124
predicate sourceNode(Node n, string kind) { n.(FlowSummaryNode).isSource(kind, _) }

rust/ql/src/queries/security/CWE-022/TaintedPath.ql

+5-14
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,11 @@ import codeql.rust.security.TaintedPathExtensions
2222
import TaintedPathFlow::PathGraph
2323
private import codeql.rust.Concepts
2424

25-
abstract private class NormalizationState extends string {
26-
bindingset[this]
27-
NormalizationState() { any() }
28-
}
29-
30-
/** A state signifying that the file path has not been normalized. */
31-
class NotNormalized extends NormalizationState {
32-
NotNormalized() { this = "NotNormalized" }
33-
}
34-
35-
/** A state signifying that the file path has been normalized, but not checked. */
36-
class NormalizedUnchecked extends NormalizationState {
37-
NormalizedUnchecked() { this = "NormalizedUnchecked" }
38-
}
25+
newtype NormalizationState =
26+
/** A state signifying that the file path has not been normalized. */
27+
NotNormalized() or
28+
/** A state signifying that the file path has been normalized, but not checked. */
29+
NormalizedUnchecked()
3930

4031
/**
4132
* This configuration uses two flow states, `NotNormalized` and `NormalizedUnchecked`,

0 commit comments

Comments
 (0)