Skip to content

Commit 0a0ac9e

Browse files
committed
Ruby: Accept test improvement.
1 parent cfa81b1 commit 0a0ac9e

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,22 @@ private module PolynomialReDoSConfig implements DataFlow::ConfigSig {
3737
* expression denial of service vulnerabilities.
3838
*/
3939
module PolynomialReDoSFlow = TaintTracking::Global<PolynomialReDoSConfig>;
40+
41+
predicate flowPath0 = PolynomialReDoSFlow::flowPath/2;
42+
43+
import codeql.ruby.security.regexp.PolynomialReDoSCustomizations::PolynomialReDoS as PR
44+
45+
predicate qqq(
46+
// DataFlow::Node highlight, string pref, string pump, string describe,
47+
PolynomialReDoSFlow::PathNode source, PolynomialReDoSFlow::PathNode sink, PR::Sink sinkNode,
48+
PR::PolynomialBackTrackingTerm regexp
49+
) {
50+
PolynomialReDoSFlow::flowPath(source, sink) and
51+
sinkNode = sink.getNode() and
52+
regexp = sinkNode.getRegExp()
53+
// and
54+
// highlight = sinkNode.getHighlight() and
55+
// pref = regexp.getPrefixMessage() and
56+
// pump = regexp.getPumpString() and
57+
// describe = source.getNode().(PR::Source).describe()
58+
}

ruby/ql/test/query-tests/security/cwe-020/IncompleteHostnameRegExp/IncompleteHostnameRegExp.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| tst-IncompleteHostnameRegExp.rb:20:14:20:31 | ^test.example.com$ | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.rb:20:13:20:26 | "#{...}$" | here |
1717
| tst-IncompleteHostnameRegExp.rb:22:24:22:40 | test.example.com$ | This string, which is used as a regular expression $@, has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.rb:23:13:23:29 | ...[...] | here |
1818
| tst-IncompleteHostnameRegExp.rb:28:24:28:40 | test.example.com$ | This string, which is used as a regular expression $@, has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.rb:63:20:63:36 | ...[...] | here |
19+
| tst-IncompleteHostnameRegExp.rb:30:27:30:43 | test.example.com$ | This string, which is used as a regular expression $@, has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.rb:66:20:66:36 | ...[...] | here |
1920
| tst-IncompleteHostnameRegExp.rb:37:3:37:53 | ^(https?:)?\\/\\/((service\|www).)?example.com(?=$\|\\/) | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.rb:37:2:37:54 | /^(https?:)?\\/\\/((service\|www).../ | here |
2021
| tst-IncompleteHostnameRegExp.rb:38:3:38:43 | ^(http\|https):\\/\\/www.example.com\\/p\\/f\\/ | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.rb:38:2:38:44 | /^(http\|https):\\/\\/www.example.../ | here |
2122
| tst-IncompleteHostnameRegExp.rb:39:5:39:30 | http:\\/\\/sub.example.com\\/ | This regular expression has an unescaped '.' before 'example.com', so it might match more hosts than expected. | tst-IncompleteHostnameRegExp.rb:39:2:39:33 | /^(http:\\/\\/sub.example.com\\/)/ | here |

ruby/ql/test/query-tests/security/cwe-020/IncompleteHostnameRegExp/tst-IncompleteHostnameRegExp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def foo
2727

2828
convert1({ hostname: 'test.example.com$' }); # $ Alert // NOT OK
2929

30-
domains = [ { hostname: 'test.example.com$' } ]; # $ MISSING: Alert # NOT OK - but not flagged due to limitations of TypeTracking.
30+
domains = [ { hostname: 'test.example.com$' } ]; # $ Alert // NOT OK
3131

3232

3333

0 commit comments

Comments
 (0)