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

Skip to content

Commit 6c91f77

Browse files
committed
Make StringBreak use new API
1 parent 30ae343 commit 6c91f77

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ module StringBreak {
1414
import StringBreakCustomizations::StringBreak
1515

1616
/**
17+
* DEPRECATED: Use `Flow` instead.
18+
*
1719
* A taint-tracking configuration for reasoning about unsafe-quoting vulnerabilities,
1820
* parameterized with the type of quote being tracked.
1921
*/
20-
class Configuration extends TaintTracking::Configuration {
22+
deprecated class Configuration extends TaintTracking::Configuration {
2123
Quote quote;
2224

2325
Configuration() { this = "StringBreak" + quote }
@@ -31,4 +33,21 @@ module StringBreak {
3133

3234
override predicate isSanitizer(DataFlow::Node nd) { quote = nd.(Sanitizer).getQuote() }
3335
}
36+
37+
private module Config implements DataFlow::StateConfigSig {
38+
/** The type of quote being tracked by this configuration. */
39+
class FlowState = Quote;
40+
41+
predicate isSource(DataFlow::Node source, FlowState state) {
42+
source instanceof Source and exists(state)
43+
}
44+
45+
predicate isSink(DataFlow::Node sink, FlowState state) { state = sink.(Sink).getQuote() }
46+
47+
predicate isBarrier(DataFlow::Node node, FlowState state) {
48+
state = node.(Sanitizer).getQuote()
49+
}
50+
}
51+
52+
module Flow = TaintTracking::GlobalWithState<Config>;
3453
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
edges
2+
| StringBreak.go:10:2:10:40 | ... := ...[0] | StringBreak.go:14:47:14:57 | versionJSON |
3+
nodes
4+
| StringBreak.go:10:2:10:40 | ... := ...[0] | semmle.label | ... := ...[0] |
5+
| StringBreak.go:14:47:14:57 | versionJSON | semmle.label | versionJSON |
6+
subpaths
7+
#select
8+
| StringBreak.go:14:47:14:57 | versionJSON | StringBreak.go:10:2:10:40 | ... := ...[0] | StringBreak.go:14:47:14:57 | versionJSON | If this $@ contains a single quote, it could break out of the enclosing quotes. | StringBreak.go:10:2:10:40 | ... := ...[0] | JSON value |

go/ql/src/Security/CWE-089/StringBreak.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import go
1919
import semmle.go.security.StringBreak
20-
import DataFlow::PathGraph
20+
import StringBreak::Flow::PathGraph
2121

22-
from StringBreak::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
23-
where cfg.hasFlowPath(source, sink)
22+
from StringBreak::Flow::PathNode source, StringBreak::Flow::PathNode sink
23+
where StringBreak::Flow::flowPath(source, sink)
2424
select sink.getNode(), source, sink,
25-
"If this $@ contains a " + cfg.getQuote().getType() + " quote, it could break out of " +
26-
"the enclosing quotes.", source.getNode(), "JSON value"
25+
"If this $@ contains a " + sink.getNode().(StringBreak::Sink).getQuote().getType() +
26+
" quote, it could break out of " + "the enclosing quotes.", source.getNode(), "JSON value"

0 commit comments

Comments
 (0)