Skip to content

Commit 101dc04

Browse files
committed
Add SPURIOUS and MISSING to some comments
1 parent b28ce66 commit 101dc04

6 files changed

Lines changed: 24 additions & 24 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
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$' } ]; # NOT OK - but not flagged due to limitations of TypeTracking.
30+
domains = [ { hostname: 'test.example.com$' } ]; # $ MISSING: Alert # NOT OK - but not flagged due to limitations of TypeTracking.
3131

3232

3333

@@ -39,7 +39,7 @@ def foo
3939
/^(http:\/\/sub.example.com\/)/i; # $ Alert // NOT OK
4040
/^https?:\/\/api.example.com/; # $ Alert // NOT OK
4141
Regexp.new('^http://localhost:8000|' + "^https?://.+\\.example\\.com/"); # $ Alert // NOT OK
42-
Regexp.new("^http[s]?:\/\/?sub1\\.sub2\\.example\\.com\/f\/(.+)"); # NOT OK
42+
Regexp.new("^http[s]?:\/\/?sub1\\.sub2\\.example\\.com\/f\/(.+)"); # $ MISSING: Alert # NOT OK
4343
/^https:\/\/[a-z]*.example.com$/; # $ Alert // NOT OK
4444
Regexp.compile('^protos?://(localhost|.+.example.net|.+.example-a.com|.+.example-b.com|.+.example.internal)'); # $ Alert // NOT OK
4545

@@ -48,11 +48,11 @@ def foo
4848
Regexp.new('^http://localhost:8000|' + "^https?://.+.example\\.com/"); # $ Alert // NOT OK
4949

5050
primary = 'example.com$';
51-
Regexp.new('test.' + primary); # NOT OK, but not detected
51+
Regexp.new('test.' + primary); # $ MISSING: Alert # NOT OK, but not detected
5252

53-
Regexp.new('test.' + 'example.com$'); # NOT OK
53+
Regexp.new('test.' + 'example.com$'); # $ MISSING: Alert # NOT OK
5454

55-
Regexp.new('^http://test\.example.com'); # NOT OK
55+
Regexp.new('^http://test\.example.com'); # $ MISSING: Alert # NOT OK
5656

5757
/^http:\/\/(..|...)\.example\.com\/index\.html/; # OK, wildcards are intentional
5858
/^http:\/\/.\.example\.com\/index\.html/; # OK, the wildcard is intentional

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
def test (x)
2-
x.index("internal") != nil; # NOT OK, but not flagged
3-
x.index("localhost") != nil; # NOT OK, but not flagged
2+
x.index("internal") != nil; # $ MISSING: Alert # NOT OK, but not flagged
3+
x.index("localhost") != nil; # $ MISSING: Alert # NOT OK, but not flagged
44
x.index("secure.com") != nil; # $ Alert // NOT OK
55
x.index("secure.net") != nil; # $ Alert // NOT OK
66
x.index(".secure.com") != nil; # $ Alert // NOT OK
7-
x.index("sub.secure.") != nil; # NOT OK, but not flagged
8-
x.index(".sub.secure.") != nil; # NOT OK, but not flagged
7+
x.index("sub.secure.") != nil; # $ MISSING: Alert # NOT OK, but not flagged
8+
x.index(".sub.secure.") != nil; # $ MISSING: Alert # NOT OK, but not flagged
99

1010
x.index("secure.com") === nil; # $ Alert // NOT OK
1111
x.index("secure.com") === 0; # $ Alert // NOT OK
@@ -33,7 +33,7 @@ def test (x)
3333
x.index("https://secure.com:443") != nil; # $ Alert // NOT OK
3434
x.index("https://secure.com/") != nil; # $ Alert // NOT OK
3535

36-
x.index(".cn") != nil; # NOT OK, but not flagged
36+
x.index(".cn") != nil; # $ MISSING: Alert # NOT OK, but not flagged
3737
x.index(".jpg") != nil; # OK
3838
x.index("index.html") != nil; # OK
3939
x.index("index.js") != nil; # OK
@@ -43,8 +43,8 @@ def test (x)
4343
x.index("secure=true") != nil; # OK (query param)
4444
x.index("&auth=") != nil; # OK (query param)
4545

46-
x.index(getCurrentDomain()) != nil; # NOT OK, but not flagged
47-
x.index(location.origin) != nil; # NOT OK, but not flagged
46+
x.index(getCurrentDomain()) != nil; # $ MISSING: Alert # NOT OK, but not flagged
47+
x.index(location.origin) != nil; # $ MISSING: Alert # NOT OK, but not flagged
4848

4949
x.index("tar.gz") + offset; # OK
5050
x.index("tar.gz") - offset; # OK
@@ -68,7 +68,7 @@ def test (x)
6868
else
6969
doSomeThingWithTrustedURL(x);
7070
end
71-
71+
7272
x.start_with?("https://secure.com/foo/bar"); # OK - a forward slash after the domain makes prefix checks safe.
7373
x.index("https://secure.com/foo/bar") >= 0 # $ Alert // NOT OK - the url can be anywhere in the string.
7474
x.index("https://secure.com") >= 0 # $ Alert // NOT OK

ruby/ql/test/query-tests/security/cwe-116/IncompleteSanitization/tst.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def good13a(s)
220220
s = s.sub('[', '') # OK
221221
s = s.sub(']', '') # OK
222222
s.sub(/{/, '').sub(/}/, '') # OK
223-
s.sub(']', '').sub('[', '') # $ Alert // probably OK, but still flagged
223+
s.sub(']', '').sub('[', '') # $ SPURIOUS: Alert // probably OK, but still flagged
224224
end
225225

226226
def good13b(s1)

ruby/ql/test/query-tests/security/cwe-1333-exponential-redos/tst.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,10 @@
304304
# NOT GOOD
305305
bad67 = /(\d(\s+)*){20}/ # $ Alert
306306

307-
# GOOD - but we spuriously conclude that a rejecting suffix exists.
307+
# GOOD - but we spuriously conclude that a rejecting suffix exists.
308308
good36 = /(([^\/]|X)+)(\/[\S\s]*)*$/ # $ Alert
309309

310-
# GOOD - but we spuriously conclude that a rejecting suffix exists.
310+
# GOOD - but we spuriously conclude that a rejecting suffix exists.
311311
good37 = /^((x([^Y]+)?)*(Y|$))/ # $ Alert
312312

313313
# NOT GOOD
@@ -326,18 +326,18 @@
326326
good38 = /(a?)*b/
327327

328328
# NOT GOOD - but not detected
329-
bad72 = /(c?a?)*b/
329+
bad72 = /(c?a?)*b/ # $ MISSING: Alert
330330

331331
# NOT GOOD
332332
bad73 = /(?:a|a?)+b/ # $ Alert
333333

334-
# NOT GOOD - but not detected.
335-
bad74 = /(a?b?)*$/
334+
# NOT GOOD - but not detected.
335+
bad74 = /(a?b?)*$/ # $ MISSING: Alert
336336

337337
# NOT GOOD
338338
bad76 = /PRE(([a-c]|[c-d])T(e?e?e?e?|X))+(cTcT|cTXcTX$)/ # $ Alert
339339

340-
# NOT GOOD - but not detected
340+
# NOT GOOD
341341
bad77 = /^((a)+\w)+$/ # $ Alert
342342

343343
# NOT GOOD
@@ -362,7 +362,7 @@
362362
bad85 = /^((?:a{0,|-)|\w\{\d,)+X$/ # $ Alert
363363
bad86 = /^((?:a{0,2|-)|\w\{\d,\d)+X$/ # $ Alert
364364

365-
# NOT GOOD
365+
# NOT GOOD
366366
bad87 = /^((?:a{0,2}|-)|\w\{\d,\d\})+X$/
367367

368368
# NOT GOOD

ruby/ql/test/query-tests/security/cwe-502/unsafe-deserialization/UnsafeDeserialization.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def route8
6767
# TODO: false positive; we aren't detecting flow from `:json` to the call argument.
6868
more_options = { allow_blank: true }
6969
more_options[:mode] = :json
70-
object4 = Oj.load json_data, more_options # $ Alert
70+
object4 = Oj.load json_data, more_options # $ SPURIOUS: Alert
7171
end
7272

7373
# GOOD
@@ -127,7 +127,7 @@ def route16
127127
# GOOD
128128
def route17
129129
yaml_data = params[:key]
130-
object = Psych.parse_stream(yaml_data)
130+
object = Psych.parse_stream(yaml_data)
131131
object = Psych.parse(yaml_data)
132132
object = Psych.parse_file(yaml_data)
133133
end

ruby/ql/test/query-tests/security/cwe-807-user-controlled-bypass/ConditionalBypass.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def bad_handler2
1818
def bad_handler3
1919
# BAD. Not detected: its the last statement in the method, so it doesn't
2020
# match the heuristic for an action.
21-
login if params[:login]
21+
login if params[:login] # $ MISSING: Alert
2222
end
2323

2424
def bad_handler4

0 commit comments

Comments
 (0)