Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7341b61

Browse files
committed
Make XPathInjection use new API
1 parent a6177b3 commit 7341b61

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

go/ql/lib/semmle/go/security/XPathInjection.qll

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ module XPathInjection {
1414
import XPathInjectionCustomizations::XPathInjection
1515

1616
/**
17+
* DEPRECATED: Use `Flow` instead.
18+
*
1719
* A taint-tracking configuration for reasoning about untrusted user input used in an XPath expression.
1820
*/
19-
class Configuration extends TaintTracking::Configuration {
21+
deprecated class Configuration extends TaintTracking::Configuration {
2022
Configuration() { this = "XPathInjection" }
2123

2224
override predicate isSource(DataFlow::Node source) { source instanceof Source }
@@ -32,4 +34,14 @@ module XPathInjection {
3234
guard instanceof SanitizerGuard
3335
}
3436
}
37+
38+
private module Config implements DataFlow::ConfigSig {
39+
predicate isSource(DataFlow::Node source) { source instanceof Source }
40+
41+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
42+
43+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
44+
}
45+
46+
module Flow = TaintTracking::Global<Config>;
3547
}

go/ql/src/Security/CWE-643/XPathInjection.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
*/
1313

1414
import go
15-
import semmle.go.security.XPathInjection::XPathInjection
16-
import DataFlow::PathGraph
15+
import semmle.go.security.XPathInjection
16+
import XPathInjection::Flow::PathGraph
1717

1818
/** Holds if `node` is either a string or a byte slice */
19-
predicate isStringOrByte(DataFlow::PathNode node) {
19+
predicate isStringOrByte(XPathInjection::Flow::PathNode node) {
2020
exists(Type t | t = node.getNode().getType().getUnderlyingType() |
2121
t instanceof StringType or t instanceof ByteSliceType
2222
)
2323
}
2424

25-
from Configuration config, DataFlow::PathNode source, DataFlow::PathNode sink
26-
where config.hasFlowPath(source, sink) and isStringOrByte(sink)
25+
from XPathInjection::Flow::PathNode source, XPathInjection::Flow::PathNode sink
26+
where XPathInjection::Flow::flowPath(source, sink) and isStringOrByte(sink)
2727
select sink.getNode(), source, sink, "XPath expression depends on a $@.", source.getNode(),
2828
"user-provided value"

0 commit comments

Comments
 (0)