Skip to content

Commit 04d3d04

Browse files
committed
Ruby: configsig rb/regex/badly-anchored-regexp
1 parent 77f3a70 commit 04d3d04

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

ruby/ql/lib/codeql/ruby/security/regexp/MissingFullAnchorQuery.qll

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* missing full-anchored regular expressions.
44
*
55
* Note, for performance reasons: only import this file if
6-
* `MissingFullAnchor::Configuration` is needed, otherwise
6+
* `MissingFullAnchorFlow` is needed, otherwise
77
* `MissingFullAnchorCustomizations` should be imported instead.
88
*/
99

@@ -14,8 +14,9 @@ import MissingFullAnchorCustomizations::MissingFullAnchor
1414
/**
1515
* A taint tracking configuration for reasoning about
1616
* missing full-anchored regular expressions.
17+
* DEPRECATED: Use `MissingFullAnchorFlow`
1718
*/
18-
class Configuration extends TaintTracking::Configuration {
19+
deprecated class Configuration extends TaintTracking::Configuration {
1920
Configuration() { this = "MissingFullAnchor" }
2021

2122
override predicate isSource(DataFlow::Node source) { source instanceof Source }
@@ -24,3 +25,16 @@ class Configuration extends TaintTracking::Configuration {
2425

2526
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
2627
}
28+
29+
private module MissingFullAnchorConfig implements DataFlow::ConfigSig {
30+
predicate isSource(DataFlow::Node source) { source instanceof Source }
31+
32+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
33+
34+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
35+
}
36+
37+
/**
38+
* Taint-tracking for reasoning about missing full-anchored regular expressions.
39+
*/
40+
module MissingFullAnchorFlow = TaintTracking::Global<MissingFullAnchorConfig>;

ruby/ql/src/queries/security/cwe-020/MissingFullAnchor.ql

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

1414
import codeql.ruby.security.regexp.MissingFullAnchorQuery
15-
import DataFlow::PathGraph
15+
import MissingFullAnchorFlow::PathGraph
1616

17-
from Configuration config, DataFlow::PathNode source, DataFlow::PathNode sink, Sink sinkNode
18-
where config.hasFlowPath(source, sink) and sink.getNode() = sinkNode
17+
from MissingFullAnchorFlow::PathNode source, MissingFullAnchorFlow::PathNode sink, Sink sinkNode
18+
where MissingFullAnchorFlow::flowPath(source, sink) and sink.getNode() = sinkNode
1919
select sink, source, sink, "This value depends on $@, and is $@ against a $@.", source.getNode(),
2020
source.getNode().(Source).describe(), sinkNode.getCallNode(), "checked", sinkNode.getRegex(),
2121
"badly anchored regular expression"

0 commit comments

Comments
 (0)