-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add support for Apache Commons Lang ArrayUtils #5134
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
6 commits
Select commit
Hold shift + click to select a range
0cf3a29
Add support for Apache Commons Lang ArrayUtils
pwntester 49eda8c
apply LSP formatter
pwntester 8606386
add bidirectional import
pwntester 7d29436
Update java/ql/src/semmle/code/java/frameworks/apache/Lang.qll
504d119
adjust max parameter number
pwntester 8128843
Merge branch 'ArrayUtils' of github.com:pwntester/codeql-1 into Array…
pwntester 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
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
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 |
|---|---|---|
| @@ -1,27 +1,65 @@ | ||
| /** Definitions related to the Apache Commons Lang library. */ | ||
|
|
||
| import java | ||
| private import semmle.code.java.dataflow.FlowSteps | ||
|
|
||
| /*--- Types ---*/ | ||
| /** The class `org.apache.commons.lang.RandomStringUtils` or `org.apache.commons.lang3.RandomStringUtils`. */ | ||
| /** | ||
| * The class `org.apache.commons.lang.RandomStringUtils` or `org.apache.commons.lang3.RandomStringUtils`. | ||
| */ | ||
| class TypeApacheRandomStringUtils extends Class { | ||
| TypeApacheRandomStringUtils() { | ||
| hasQualifiedName("org.apache.commons.lang", "RandomStringUtils") or | ||
| hasQualifiedName("org.apache.commons.lang3", "RandomStringUtils") | ||
| this.hasQualifiedName(["org.apache.commons.lang", "org.apache.commons.lang3"], | ||
| "RandomStringUtils") | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * The class `org.apache.commons.lang.ArrayUtils` or `org.apache.commons.lang3.ArrayUtils`. | ||
| */ | ||
| class TypeApacheArrayUtils extends Class { | ||
| TypeApacheArrayUtils() { | ||
| hasQualifiedName(["org.apache.commons.lang", "org.apache.commons.lang3"], "ArrayUtils") | ||
| } | ||
| } | ||
|
|
||
| /*--- Methods ---*/ | ||
| /** | ||
| * The method `deserialize` in either `org.apache.commons.lang.SerializationUtils` | ||
| * or `org.apache.commons.lang3.SerializationUtils`. | ||
| */ | ||
| class MethodApacheSerializationUtilsDeserialize extends Method { | ||
| MethodApacheSerializationUtilsDeserialize() { | ||
| ( | ||
| this.getDeclaringType().hasQualifiedName("org.apache.commons.lang", "SerializationUtils") or | ||
| this.getDeclaringType().hasQualifiedName("org.apache.commons.lang3", "SerializationUtils") | ||
| ) and | ||
| this.getDeclaringType() | ||
| .hasQualifiedName(["org.apache.commons.lang", "org.apache.commons.lang3"], | ||
| "SerializationUtils") and | ||
| this.hasName("deserialize") | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * A taint preserving method on `org.apache.commons.lang.ArrayUtils` or `org.apache.commons.lang3.ArrayUtils` | ||
| */ | ||
| private class ApacheLangArrayUtilsTaintPreservingMethod extends TaintPreservingCallable { | ||
| ApacheLangArrayUtilsTaintPreservingMethod() { | ||
| this.getDeclaringType() instanceof TypeApacheArrayUtils | ||
| } | ||
|
|
||
| override predicate returnsTaintFrom(int src) { | ||
| this.hasName(["addAll", "addFirst"]) and | ||
| src = [0 .. getNumberOfParameters() - 1] | ||
| or | ||
| this.hasName([ | ||
| "clone", "nullToEmpty", "remove", "removeAll", "removeElement", "removeElements", "reverse", | ||
| "shift", "shuffle", "subarray", "swap", "toArray", "toMap", "toObject", "toPrimitive", | ||
| "toString", "toStringArray" | ||
| ]) and | ||
| src = 0 | ||
| or | ||
| this.hasName("add") and | ||
| this.getNumberOfParameters() = 2 and | ||
| src = [0, 1] | ||
| or | ||
| this.hasName("add") and | ||
| this.getNumberOfParameters() = 3 and | ||
| src = [0, 2] | ||
| } | ||
| } | ||
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.
This needs bidirectional import to work, i.e. you need to add
private import java/ql/src/semmle/code/java/frameworks/apache/Lang.qllinFlowSteps.qll