Skip to content

Commit 6cb0717

Browse files
authored
Fix test syntax for sanitizer tests
1 parent 5ada3b7 commit 6cb0717

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed
Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
edges
2-
| decompression_api.rb:3:31:3:36 | call to params : | decompression_api.rb:3:31:3:43 | ...[...] |
3-
| decompression_api.rb:12:35:12:40 | call to params : | decompression_api.rb:12:35:12:47 | ...[...] |
4-
| decompression_api.rb:17:27:17:32 | call to params : | decompression_api.rb:17:27:17:39 | ...[...] |
5-
| decompression_api.rb:26:31:26:36 | call to params : | decompression_api.rb:26:31:26:43 | ...[...] |
2+
| decompression_api.rb:3:31:3:36 | call to params : | decompression_api.rb:3:31:3:44 | ...[...] |
3+
| decompression_api.rb:13:44:13:49 | call to params : | decompression_api.rb:13:44:13:57 | ...[...] |
4+
| decompression_api.rb:17:24:17:29 | call to params : | decompression_api.rb:17:24:17:37 | ...[...] |
65
nodes
76
| decompression_api.rb:3:31:3:36 | call to params : | semmle.label | call to params : |
8-
| decompression_api.rb:3:31:3:43 | ...[...] | semmle.label | ...[...] |
9-
| decompression_api.rb:12:35:12:40 | call to params : | semmle.label | call to params : |
10-
| decompression_api.rb:12:35:12:47 | ...[...] | semmle.label | ...[...] |
11-
| decompression_api.rb:17:27:17:32 | call to params : | semmle.label | call to params : |
12-
| decompression_api.rb:17:27:17:39 | ...[...] | semmle.label | ...[...] |
13-
| decompression_api.rb:26:31:26:36 | call to params : | semmle.label | call to params : |
14-
| decompression_api.rb:26:31:26:43 | ...[...] | semmle.label | ...[...] |
7+
| decompression_api.rb:3:31:3:44 | ...[...] | semmle.label | ...[...] |
8+
| decompression_api.rb:13:44:13:49 | call to params : | semmle.label | call to params : |
9+
| decompression_api.rb:13:44:13:57 | ...[...] | semmle.label | ...[...] |
10+
| decompression_api.rb:17:24:17:29 | call to params : | semmle.label | call to params : |
11+
| decompression_api.rb:17:24:17:37 | ...[...] | semmle.label | ...[...] |
1512
subpaths
1613
#select
17-
| decompression_api.rb:3:31:3:43 | ...[...] | decompression_api.rb:3:31:3:36 | call to params : | decompression_api.rb:3:31:3:43 | ...[...] | This call to $@ is unsafe because user-controlled data is used to set the object being decompressed, which could lead to a denial of service attack or malicious code extracted from an unknown source. |
18-
| decompression_api.rb:12:35:12:47 | ...[...] | decompression_api.rb:12:35:12:40 | call to params : | decompression_api.rb:12:35:12:47 | ...[...] | This call to $@ is unsafe because user-controlled data is used to set the object being decompressed, which could lead to a denial of service attack or malicious code extracted from an unknown source. |
19-
| decompression_api.rb:17:27:17:39 | ...[...] | decompression_api.rb:17:27:17:32 | call to params : | decompression_api.rb:17:27:17:39 | ...[...] | This call to $@ is unsafe because user-controlled data is used to set the object being decompressed, which could lead to a denial of service attack or malicious code extracted from an unknown source. |
20-
| decompression_api.rb:26:31:26:43 | ...[...] | decompression_api.rb:26:31:26:36 | call to params : | decompression_api.rb:26:31:26:43 | ...[...] | This call to $@ is unsafe because user-controlled data is used to set the object being decompressed, which could lead to a denial of service attack or malicious code extracted from an unknown source. |
14+
| decompression_api.rb:3:31:3:44 | ...[...] | decompression_api.rb:3:31:3:36 | call to params : | decompression_api.rb:3:31:3:44 | ...[...] | This call to $@ is unsafe because user-controlled data is used to set the object being decompressed, which could lead to a denial of service attack or malicious code extracted from an unknown source. |
15+
| decompression_api.rb:13:44:13:57 | ...[...] | decompression_api.rb:13:44:13:49 | call to params : | decompression_api.rb:13:44:13:57 | ...[...] | This call to $@ is unsafe because user-controlled data is used to set the object being decompressed, which could lead to a denial of service attack or malicious code extracted from an unknown source. |
16+
| decompression_api.rb:17:24:17:37 | ...[...] | decompression_api.rb:17:24:17:29 | call to params : | decompression_api.rb:17:24:17:37 | ...[...] | This call to $@ is unsafe because user-controlled data is used to set the object being decompressed, which could lead to a denial of service attack or malicious code extracted from an unknown source. |

ruby/ql/test/query-tests/security/decompression-api/decompression_api.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class TestController < ActionController::Base
22
def unsafe_zlib_unzip
3-
Zlib::Inflate.inflate(params[:path])
3+
Zlib::Inflate.inflate(params[:fname])
44
end
55

66
def safe_zlib_unzip
@@ -10,11 +10,11 @@ def safe_zlib_unzip
1010

1111
DECOMPRESSION_LIB = Zlib
1212
def unsafe_zlib_unzip_const
13-
DECOMPRESSION_LIB::Inflate.inflate(params[:path])
13+
DECOMPRESSION_LIB::Inflate.inflate(params[:fname])
1414
end
1515

1616
def unsafe_zlib_unzip
17-
Zip::File.open(params[:file]) do |zip_file|
17+
Zip::File.open(params[:fname]) do |zip_file|
1818
zip_file.each do |entry|
1919
entry.extract(entry.name)
2020
end
@@ -26,14 +26,16 @@ def safe_zlib_unzip
2626
end
2727

2828
def sanitized_zlib_unzip
29-
if "safe_file.gz" == params[:path]
30-
Zlib::Inflate.inflate(params[:path])
29+
fname = params[:fname]
30+
if fname == "safe_file.gz"
31+
Zlib::Inflate.inflate(fname)
3132
end
3233
end
3334

3435
def sanitized_array_zlib_unzip
35-
if ["safe_file1.gz", "safe_file2.gz"].include? params[:path]
36-
Zlib::Inflate.inflate(params[:path])
36+
fname = params[:fname]
37+
if ["safe_file1.gz", "safe_file2.gz"].include? fname
38+
Zlib::Inflate.inflate(fname)
3739
end
3840
end
3941

0 commit comments

Comments
 (0)