-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java, Ruby: add missing .qlref tests #19888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
19 changes: 0 additions & 19 deletions
19
java/ql/test/query-tests/security/CWE-094/ApkInstallationTest.ql
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
java/ql/test/query-tests/security/CWE-094/ApkInstallationTest/ApkInstallationTest.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#select | ||
| ApkInstallation.java:14:31:14:58 | fromFile(...) | ApkInstallation.java:14:31:14:58 | fromFile(...) | ApkInstallation.java:14:31:14:58 | fromFile(...) | Arbitrary Android APK installation. | | ||
| ApkInstallation.java:22:24:22:51 | fromFile(...) | ApkInstallation.java:22:24:22:51 | fromFile(...) | ApkInstallation.java:22:24:22:51 | fromFile(...) | Arbitrary Android APK installation. | | ||
| ApkInstallation.java:30:31:30:48 | fromFile(...) | ApkInstallation.java:30:31:30:48 | fromFile(...) | ApkInstallation.java:30:31:30:48 | fromFile(...) | Arbitrary Android APK installation. | | ||
| ApkInstallation.java:38:24:38:41 | fromFile(...) | ApkInstallation.java:38:24:38:41 | fromFile(...) | ApkInstallation.java:38:24:38:41 | fromFile(...) | Arbitrary Android APK installation. | | ||
| ApkInstallation.java:45:24:45:41 | fromFile(...) | ApkInstallation.java:45:24:45:41 | fromFile(...) | ApkInstallation.java:45:24:45:41 | fromFile(...) | Arbitrary Android APK installation. | | ||
| ApkInstallation.java:53:24:53:41 | fromFile(...) | ApkInstallation.java:53:24:53:41 | fromFile(...) | ApkInstallation.java:53:24:53:41 | fromFile(...) | Arbitrary Android APK installation. | | ||
edges | ||
nodes | ||
| ApkInstallation.java:14:31:14:58 | fromFile(...) | semmle.label | fromFile(...) | | ||
| ApkInstallation.java:22:24:22:51 | fromFile(...) | semmle.label | fromFile(...) | | ||
| ApkInstallation.java:30:31:30:48 | fromFile(...) | semmle.label | fromFile(...) | | ||
| ApkInstallation.java:38:24:38:41 | fromFile(...) | semmle.label | fromFile(...) | | ||
| ApkInstallation.java:45:24:45:41 | fromFile(...) | semmle.label | fromFile(...) | | ||
| ApkInstallation.java:53:24:53:41 | fromFile(...) | semmle.label | fromFile(...) | | ||
subpaths |
4 changes: 4 additions & 0 deletions
4
java/ql/test/query-tests/security/CWE-094/ApkInstallationTest/ApkInstallationTest.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
query: Security/CWE/CWE-094/ArbitraryApkInstallation.ql | ||
postprocess: | ||
- utils/test/PrettyPrintModels.ql | ||
- utils/test/InlineExpectationsTestQuery.ql |
1 change: 1 addition & 0 deletions
1
java/ql/test/query-tests/security/CWE-094/ApkInstallationTest/options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/validation-api-2.0.1.Final:${testdir}/../../../../stubs/springframework-5.8.x:${testdir}/../../../../stubs/apache-commons-jexl-2.1.1:${testdir}/../../../../stubs/apache-commons-jexl-3.1:${testdir}/../../../../stubs/apache-commons-logging-1.2:${testdir}/../../../../stubs/mvel2-2.4.7:${testdir}/../../../../stubs/groovy-all-3.0.7:${testdir}/../../../../stubs/servlet-api-2.4:${testdir}/../../../../stubs/scriptengine:${testdir}/../../../../stubs/jsr223-api:${testdir}/../../../../stubs/apache-freemarker-2.3.31:${testdir}/../../../../stubs/jinjava-2.6.0:${testdir}/../../../../stubs/pebble-3.1.5:${testdir}/../../../../stubs/thymeleaf-3.0.14:${testdir}/../../../../stubs/apache-velocity-2.3:${testdir}/../../../..//stubs/google-android-9.0.0 |
79 changes: 79 additions & 0 deletions
79
ruby/ql/test/query-tests/meta/TaintedNodes/TaintedNodes.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
| tainted_path.rb:4:5:4:24 | ... = ... | Tainted node | | ||
| tainted_path.rb:4:12:4:17 | call to params | Tainted node | | ||
| tainted_path.rb:4:12:4:24 | ...[...] | Tainted node | | ||
| tainted_path.rb:5:26:5:29 | path | Tainted node | | ||
| tainted_path.rb:10:5:10:43 | ... = ... | Tainted node | | ||
| tainted_path.rb:10:12:10:43 | call to absolute_path | Tainted node | | ||
| tainted_path.rb:10:31:10:36 | call to params | Tainted node | | ||
| tainted_path.rb:10:31:10:43 | ...[...] | Tainted node | | ||
| tainted_path.rb:11:26:11:29 | path | Tainted node | | ||
| tainted_path.rb:16:5:16:47 | ... = ... | Tainted node | | ||
| tainted_path.rb:16:12:16:47 | "#{...}/foo" | Tainted node | | ||
| tainted_path.rb:16:13:16:42 | #{...} | Tainted node | | ||
| tainted_path.rb:16:15:16:41 | call to dirname | Tainted node | | ||
| tainted_path.rb:16:28:16:33 | call to params | Tainted node | | ||
| tainted_path.rb:16:28:16:40 | ...[...] | Tainted node | | ||
| tainted_path.rb:17:26:17:29 | path | Tainted node | | ||
| tainted_path.rb:22:5:22:41 | ... = ... | Tainted node | | ||
| tainted_path.rb:22:12:22:41 | call to expand_path | Tainted node | | ||
| tainted_path.rb:22:29:22:34 | call to params | Tainted node | | ||
| tainted_path.rb:22:29:22:41 | ...[...] | Tainted node | | ||
| tainted_path.rb:23:26:23:29 | path | Tainted node | | ||
| tainted_path.rb:28:5:28:34 | ... = ... | Tainted node | | ||
| tainted_path.rb:28:12:28:34 | call to path | Tainted node | | ||
| tainted_path.rb:28:22:28:27 | call to params | Tainted node | | ||
| tainted_path.rb:28:22:28:34 | ...[...] | Tainted node | | ||
| tainted_path.rb:29:26:29:29 | path | Tainted node | | ||
| tainted_path.rb:34:5:34:41 | ... = ... | Tainted node | | ||
| tainted_path.rb:34:12:34:41 | call to realdirpath | Tainted node | | ||
| tainted_path.rb:34:29:34:34 | call to params | Tainted node | | ||
| tainted_path.rb:34:29:34:41 | ...[...] | Tainted node | | ||
| tainted_path.rb:35:26:35:29 | path | Tainted node | | ||
| tainted_path.rb:40:5:40:38 | ... = ... | Tainted node | | ||
| tainted_path.rb:40:12:40:38 | call to realpath | Tainted node | | ||
| tainted_path.rb:40:26:40:31 | call to params | Tainted node | | ||
| tainted_path.rb:40:26:40:38 | ...[...] | Tainted node | | ||
| tainted_path.rb:41:26:41:29 | path | Tainted node | | ||
| tainted_path.rb:47:5:47:63 | ... = ... | Tainted node | | ||
| tainted_path.rb:47:12:47:63 | call to join | Tainted node | | ||
| tainted_path.rb:47:43:47:48 | call to params | Tainted node | | ||
| tainted_path.rb:47:43:47:55 | ...[...] | Tainted node | | ||
| tainted_path.rb:48:26:48:29 | path | Tainted node | | ||
| tainted_path.rb:53:26:53:31 | call to params | Tainted node | | ||
| tainted_path.rb:53:26:53:38 | ...[...] | Tainted node | | ||
| tainted_path.rb:59:5:59:53 | ... = ... | Tainted node | | ||
| tainted_path.rb:59:12:59:53 | call to new | Tainted node | | ||
| tainted_path.rb:59:40:59:45 | call to params | Tainted node | | ||
| tainted_path.rb:59:40:59:52 | ...[...] | Tainted node | | ||
| tainted_path.rb:60:26:60:29 | path | Tainted node | | ||
| tainted_path.rb:65:5:65:63 | ... = ... | Tainted node | | ||
| tainted_path.rb:65:12:65:53 | call to new | Tainted node | | ||
| tainted_path.rb:65:12:65:63 | call to sanitized | Tainted node | | ||
| tainted_path.rb:65:40:65:45 | call to params | Tainted node | | ||
| tainted_path.rb:65:40:65:52 | ...[...] | Tainted node | | ||
| tainted_path.rb:66:26:66:29 | path | Tainted node | | ||
| tainted_path.rb:71:5:71:53 | ... = ... | Tainted node | | ||
| tainted_path.rb:71:12:71:53 | call to new | Tainted node | | ||
| tainted_path.rb:71:40:71:45 | call to params | Tainted node | | ||
| tainted_path.rb:71:40:71:52 | ...[...] | Tainted node | | ||
| tainted_path.rb:72:15:72:18 | path | Tainted node | | ||
| tainted_path.rb:77:5:77:53 | ... = ... | Tainted node | | ||
| tainted_path.rb:77:12:77:53 | call to new | Tainted node | | ||
| tainted_path.rb:77:40:77:45 | call to params | Tainted node | | ||
| tainted_path.rb:77:40:77:52 | ...[...] | Tainted node | | ||
| tainted_path.rb:78:19:78:22 | path | Tainted node | | ||
| tainted_path.rb:79:14:79:17 | path | Tainted node | | ||
| tainted_path.rb:84:5:84:53 | ... = ... | Tainted node | | ||
| tainted_path.rb:84:12:84:53 | call to new | Tainted node | | ||
| tainted_path.rb:84:40:84:45 | call to params | Tainted node | | ||
| tainted_path.rb:84:40:84:52 | ...[...] | Tainted node | | ||
| tainted_path.rb:85:10:85:13 | path | Tainted node | | ||
| tainted_path.rb:86:25:86:28 | path | Tainted node | | ||
| tainted_path.rb:90:5:90:53 | ... = ... | Tainted node | | ||
| tainted_path.rb:90:12:90:53 | call to new | Tainted node | | ||
| tainted_path.rb:90:40:90:45 | call to params | Tainted node | | ||
| tainted_path.rb:90:40:90:52 | ...[...] | Tainted node | | ||
| tainted_path.rb:91:10:91:43 | "Debug: require_relative(#{...})" | Tainted node | | ||
| tainted_path.rb:91:35:91:41 | #{...} | Tainted node | | ||
| tainted_path.rb:91:37:91:40 | path | Tainted node | | ||
| tainted_path.rb:92:11:92:14 | path | Tainted node | |
4 changes: 4 additions & 0 deletions
4
ruby/ql/test/query-tests/meta/TaintedNodes/TaintedNodes.qlref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
query: queries/meta/TaintedNodes.ql | ||
postprocess: | ||
- utils/test/PrettyPrintModels.ql | ||
- utils/test/InlineExpectationsTestQuery.ql |
94 changes: 94 additions & 0 deletions
94
ruby/ql/test/query-tests/meta/TaintedNodes/tainted_path.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
class FooController < ActionController::Base | ||
# BAD | ||
def route0 | ||
path = params[:path] # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# BAD - File.absolute_path preserves taint | ||
def route1 | ||
path = File.absolute_path params[:path] # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# BAD - File.dirname preserves taint | ||
def route2 | ||
path = "#{File.dirname(params[:path])}/foo" # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# BAD - File.expand_path preserves taint | ||
def route3 | ||
path = File.expand_path params[:path] # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# BAD - File.path preserves taint | ||
def route4 | ||
path = File.path params[:path] # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# BAD - File.realdirpath preserves taint | ||
def route5 | ||
path = File.realdirpath params[:path] # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# BAD - File.realpath preserves taint | ||
def route6 | ||
path = File.realpath params[:path] # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# BAD - tainted arguments in any position propagate to the return value of | ||
# File.join | ||
def route7 | ||
path = File.join("foo", "bar", "baz", params[:path], "qux") # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# GOOD - File.basename does not preserve taint | ||
def route8 | ||
path = File.basename params[:path] # $ Alert | ||
@content = File.read path # Sanitized | ||
end | ||
|
||
# BAD | ||
def route9 | ||
path = ActiveStorage::Filename.new(params[:path]) # $ Alert | ||
@content = File.read path # $ Alert | ||
end | ||
|
||
# GOOD - explicitly sanitized | ||
def route10 | ||
path = ActiveStorage::Filename.new(params[:path]).sanitized # $ Alert | ||
@content = File.read path # $ SPURIOUS: Alert (should have been sanitized) | ||
end | ||
|
||
# BAD | ||
def route11 | ||
path = ActiveStorage::Filename.new(params[:path]) # $ Alert | ||
send_file path # $ Alert | ||
end | ||
|
||
# BAD | ||
def route12 | ||
path = ActiveStorage::Filename.new(params[:path]) # $ Alert | ||
bla (Dir.glob path) # $ Alert | ||
bla (Dir[path]) # $ Alert | ||
end | ||
|
||
# BAD | ||
def route13 | ||
path = ActiveStorage::Filename.new(params[:path]) # $ Alert | ||
load(path) # $ Alert | ||
autoload(:MyModule, path) # $ Alert | ||
end | ||
|
||
def require_relative() | ||
path = ActiveStorage::Filename.new(params[:path]) # $ Alert | ||
puts "Debug: require_relative(#{path})" # $ Alert | ||
super(path) # $ Alert | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
require_relative
method is defined without apath
parameter but callssuper(path)
. Update the signature todef require_relative(path)
to match the super call.Copilot uses AI. Check for mistakes.