-
Notifications
You must be signed in to change notification settings - Fork 1.8k
java: Added Java/Kotlin Sensitive Logging barriers (substrings) #20741
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
Open
aegilops
wants to merge
14
commits into
github:main
Choose a base branch
from
aegilops:java-kotlin-sensitive-logging-substring-barriers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+117
−13
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
26087f6
Added java-kotlin Sensitive Logging barriers (substrings)
aegilops d1eceee
Fixed format/docs issues
aegilops fa703e3
Test cases for sensitive logging sanitizer
aegilops 0c0fbc1
Fixed sensitive logging barriers for substring to allow single-arg use
aegilops 528c451
Added change note, adjusted spacing in comment
aegilops 7b25e22
Merge branch 'main' into java-kotlin-sensitive-logging-substring-barr…
aegilops 62ee6d3
Made changes requested by reviewers - bounded() for range checking, s…
aegilops 1e67907
Merge commit
aegilops 801cd72
Merge branch 'main' into java-kotlin-sensitive-logging-substring-barr…
aegilops 29a5b27
Removed bounds checking and only using literals - bounded() predicate…
aegilops e904520
Fixed formatting
aegilops ce13668
Fixed formatting
aegilops ec381e4
Use range analysis and improve tests
owen-mc d2fc6a7
Merge branch 'main' into java-kotlin-sensitive-logging-substring-barr…
owen-mc 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
Some comments aren't visible on the classic Files Changed page.
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
4 changes: 4 additions & 0 deletions
4
java/ql/src/change-notes/2025-11-17-sensitive-logging-new-sanitizers.md
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 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * Operations that extract only a fixed-length prefix or suffix of a string (for example, `substring` in Java or `take` in Kotlin), when limited to a length of at most 7 characters, are now treated as sanitizers for the `java/sensitive-log` query. |
29 changes: 21 additions & 8 deletions
29
java/ql/test/query-tests/security/CWE-532/SensitiveLogInfo.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 |
|---|---|---|
| @@ -1,15 +1,28 @@ | ||
| #select | ||
| | Test.java:7:21:7:53 | ... + ... | Test.java:7:46:7:53 | password : String | Test.java:7:21:7:53 | ... + ... | This $@ is written to a log file. | Test.java:7:46:7:53 | password | potentially sensitive information | | ||
| | Test.java:8:22:8:52 | ... + ... | Test.java:8:44:8:52 | authToken : String | Test.java:8:22:8:52 | ... + ... | This $@ is written to a log file. | Test.java:8:44:8:52 | authToken | potentially sensitive information | | ||
| | Test.java:11:21:11:53 | ... + ... | Test.java:11:46:11:53 | password : String | Test.java:11:21:11:53 | ... + ... | This $@ is written to a log file. | Test.java:11:46:11:53 | password | potentially sensitive information | | ||
| | Test.java:12:22:12:52 | ... + ... | Test.java:12:44:12:52 | authToken : String | Test.java:12:22:12:52 | ... + ... | This $@ is written to a log file. | Test.java:12:44:12:52 | authToken | potentially sensitive information | | ||
| | Test.java:21:22:21:75 | ... + ... | Test.java:21:44:21:52 | authToken : String | Test.java:21:22:21:75 | ... + ... | This $@ is written to a log file. | Test.java:21:44:21:52 | authToken | potentially sensitive information | | ||
| | Test.java:22:22:22:75 | ... + ... | Test.java:22:44:22:52 | authToken : String | Test.java:22:22:22:75 | ... + ... | This $@ is written to a log file. | Test.java:22:44:22:52 | authToken | potentially sensitive information | | ||
| edges | ||
| | Test.java:7:46:7:53 | password : String | Test.java:7:21:7:53 | ... + ... | provenance | Sink:MaD:2 | | ||
| | Test.java:8:44:8:52 | authToken : String | Test.java:8:22:8:52 | ... + ... | provenance | Sink:MaD:1 | | ||
| | Test.java:11:46:11:53 | password : String | Test.java:11:21:11:53 | ... + ... | provenance | Sink:MaD:2 | | ||
| | Test.java:12:44:12:52 | authToken : String | Test.java:12:22:12:52 | ... + ... | provenance | Sink:MaD:1 | | ||
| | Test.java:21:44:21:52 | authToken : String | Test.java:21:44:21:67 | substring(...) : String | provenance | MaD:3 | | ||
| | Test.java:21:44:21:67 | substring(...) : String | Test.java:21:22:21:75 | ... + ... | provenance | Sink:MaD:1 | | ||
| | Test.java:22:44:22:52 | authToken : String | Test.java:22:44:22:67 | substring(...) : String | provenance | MaD:3 | | ||
| | Test.java:22:44:22:67 | substring(...) : String | Test.java:22:22:22:75 | ... + ... | provenance | Sink:MaD:1 | | ||
| models | ||
| | 1 | Sink: org.apache.logging.log4j; Logger; true; error; (String); ; Argument[0]; log-injection; manual | | ||
| | 2 | Sink: org.apache.logging.log4j; Logger; true; info; (String); ; Argument[0]; log-injection; manual | | ||
| | 3 | Summary: java.lang; String; false; substring; ; ; Argument[this]; ReturnValue; taint; manual | | ||
| nodes | ||
| | Test.java:7:21:7:53 | ... + ... | semmle.label | ... + ... | | ||
| | Test.java:7:46:7:53 | password : String | semmle.label | password : String | | ||
| | Test.java:8:22:8:52 | ... + ... | semmle.label | ... + ... | | ||
| | Test.java:8:44:8:52 | authToken : String | semmle.label | authToken : String | | ||
| | Test.java:11:21:11:53 | ... + ... | semmle.label | ... + ... | | ||
| | Test.java:11:46:11:53 | password : String | semmle.label | password : String | | ||
| | Test.java:12:22:12:52 | ... + ... | semmle.label | ... + ... | | ||
| | Test.java:12:44:12:52 | authToken : String | semmle.label | authToken : String | | ||
| | Test.java:21:22:21:75 | ... + ... | semmle.label | ... + ... | | ||
| | Test.java:21:44:21:52 | authToken : String | semmle.label | authToken : String | | ||
| | Test.java:21:44:21:67 | substring(...) : String | semmle.label | substring(...) : String | | ||
| | Test.java:22:22:22:75 | ... + ... | semmle.label | ... + ... | | ||
| | Test.java:22:44:22:52 | authToken : String | semmle.label | authToken : String | | ||
| | Test.java:22:44:22:67 | substring(...) : String | semmle.label | substring(...) : String | | ||
| subpaths |
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
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.
Uh oh!
There was an error while loading. Please reload this page.