-
Notifications
You must be signed in to change notification settings - Fork 1.7k
java inline expectations proof-of-concept with tests #16911
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
Draft
ginsbach
wants to merge
5
commits into
main
Choose a base branch
from
ginsbach/InlineExpectationsPrototype
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.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
65655db
java inline expectations prototype with tests
ginsbach 7370a2e
add '@kind test-postprocess' to postprocess queries
ginsbach c86e008
JavaInlineExpectations: remove actualLines()
ginsbach fba8ebe
add test for extensible predicate in postprocess
ginsbach 9c78793
add test for sorted test postprocess result
ginsbach 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
|
||
import java | ||
|
||
external predicate queryResults(string relation, int row, int column, string data); | ||
|
||
predicate parsedExpectedResults(string filename, int line, string content) { | ||
exists(Javadoc doc | | ||
isEolComment(doc) and | ||
filename = doc.getLocation().getFile().getBaseName() and | ||
line = doc.getLocation().getStartLine() and | ||
line = doc.getLocation().getEndLine() and | ||
content = doc.getChild(0).getText().trim() | ||
) | ||
} | ||
|
||
predicate expectError(string filename, int line) { | ||
exists(string content | | ||
parsedExpectedResults(filename, line, content) and content.indexOf("NOT OK") = 0 | ||
) | ||
} | ||
|
||
predicate expectPass(string filename, int line) { | ||
exists(string content | | ||
parsedExpectedResults(filename, line, content) and content.indexOf("OK") = 0 | ||
) | ||
} | ||
|
||
predicate parsedActualResults(string filename, int line, int colStart, int colEnd, string content) { | ||
exists(int i, string posString, string lineString | | ||
queryResults("#select", i, 0, posString) and | ||
filename = posString.substring(0, posString.indexOf(":", 0, 0)) and | ||
lineString = posString.substring(posString.indexOf(":", 0, 0) + 1, posString.indexOf(":", 1, 0)) and | ||
lineString = posString.substring(posString.indexOf(":", 2, 0) + 1, posString.indexOf(":", 3, 0)) and | ||
colStart = | ||
posString.substring(posString.indexOf(":", 1, 0) + 1, posString.indexOf(":", 2, 0)).toInt() and | ||
colEnd = posString.substring(posString.indexOf(":", 3, 0) + 1, posString.length()).toInt() and | ||
line = lineString.toInt() and | ||
queryResults("#select", i, 2, content) | ||
) | ||
} | ||
|
||
predicate actualExpectedDiff(string type, string position, string error) { | ||
exists(string filename, int line, int colStart, int colEnd | | ||
parsedActualResults(filename, line, colStart, colEnd, error) and | ||
expectPass(filename, line) and | ||
type = "unexpected alert" and | ||
position = filename + ":" + line + ":" + colStart + ":" + line + ":" + colEnd | ||
) | ||
or | ||
exists(string filename, int line | | ||
expectError(filename, line) and | ||
not parsedActualResults(filename, line, _, _, _) and | ||
type = "expected alert" and | ||
position = filename + ":" + line and | ||
parsedExpectedResults(filename, line, error) | ||
) | ||
or | ||
exists(string filename, int line, string content | | ||
parsedExpectedResults(filename, line, content) and | ||
not expectPass(filename, line) and | ||
not expectError(filename, line) and | ||
type = "invalid inline expectation" and | ||
position = filename + ":" + line and | ||
error = content | ||
) | ||
} | ||
|
||
from int line, string position, int column, string content | ||
where | ||
position = rank[line](string p | actualExpectedDiff(_, p, _) | p) and | ||
( | ||
column = 0 and content = position | ||
or | ||
column = 1 and actualExpectedDiff(content, position, _) | ||
or | ||
column = 2 and actualExpectedDiff(_, position, content) | ||
) | ||
select "#select", line, column, content |
6 changes: 6 additions & 0 deletions
6
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations1.ql
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,6 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
module; | ||
|
||
query predicate resultRelations(string name) { name = "#select" } | ||
|
8 changes: 8 additions & 0 deletions
8
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations2.ql
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,8 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
module; | ||
|
||
query predicate learnEdits(string name) { none() } | ||
|
||
|
||
select "#select", 1, 1, "foo" |
8 changes: 8 additions & 0 deletions
8
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations3.ql
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,8 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
module; | ||
|
||
query predicate extraQuery(string name) { none() } | ||
|
||
|
||
select "#select", 1, 1, "foo" |
8 changes: 8 additions & 0 deletions
8
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations4.ql
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,8 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
module; | ||
|
||
query predicate resultRelations(string name, int arity) { name = "#select" and arity = 5 } | ||
|
||
|
||
select "#select", 1, 1, "foo" |
5 changes: 5 additions & 0 deletions
5
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations5.ql
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,5 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
|
||
select "#select", "1", 1, "foo" |
5 changes: 5 additions & 0 deletions
5
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations6.ql
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,5 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
|
||
select "#select", 1, 1, ["foo", "bar"] |
10 changes: 10 additions & 0 deletions
10
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations7.ql
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,10 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
|
||
from int i, int j | ||
where | ||
i in [1, 2] and | ||
j in [1, 2] and | ||
not (i = 2 and j = 2) | ||
select "#select", i, j, "foo" |
1 change: 1 addition & 0 deletions
1
java/ql/test/TestUtilities/ProblematicJavaInlineExpectations8.ql
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 @@ | ||
select "#select", 1, 1, "foo" |
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,17 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
|
||
import semmle.code.java.dataflow.ExternalFlow | ||
|
||
string sinkModuleNamespaceRoots() { | ||
exists(string namespace, int dotIdx | | ||
sinkModel(namespace, _, _, _, _, _, _, _, _, _) and | ||
dotIdx = namespace.indexOf(".", 0, 0) and | ||
result = namespace.substring(0, dotIdx) | ||
) | ||
} | ||
|
||
from int line, string content | ||
where content = rank[line](string c | c = sinkModuleNamespaceRoots() | c) | ||
select "#select", line, 0, content |
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,8 @@ | ||
/** | ||
* @kind test-postprocess | ||
*/ | ||
query predicate resultRelations(string name) { name in ["B", "D", "F"] } | ||
|
||
from int line, string name | ||
where name = rank[line](string n | n in ["A", "C", "E"] | n) | ||
select name, 0, 0, "empty" |
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/SortedResults/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/TestResultSorting.ql |
19 changes: 19 additions & 0 deletions
19
java/ql/test/query-tests/Postprocessing/WithExtensible/OverlyLargeRangeQuery.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,19 @@ | ||
| android | | ||
| androidx | | ||
| ch | | ||
| com | | ||
| freemarker | | ||
| groovy | | ||
| hudson | | ||
| io | | ||
| jakarta | | ||
| java | | ||
| javafx | | ||
| javax | | ||
| kotlin | | ||
| liquibase | | ||
| net | | ||
| ognl | | ||
| org | | ||
| play | | ||
| sun | |
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/WithExtensible/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/SinkModelNamespaceRoots.ql |
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/failing/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/JavaInlineExpectations.ql |
37 changes: 37 additions & 0 deletions
37
java/ql/test/query-tests/Postprocessing/failing/SuspiciousRegexpRange.java
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,37 @@ | ||
import java.util.regex.Pattern; | ||
|
||
class SuspiciousRegexpRange { | ||
void test() { | ||
Pattern overlap1 = Pattern.compile("^[0-93-5]*$"); // NOT OK | ||
|
||
Pattern overlap2 = Pattern.compile("[A-ZA-z]*"); // OK | ||
|
||
Pattern isEmpty = Pattern.compile("^[z-a]*$"); // NOT OK | ||
|
||
Pattern isAscii = Pattern.compile("^[\\x00-\\x7F]*$"); // NOT OK | ||
|
||
Pattern printable = Pattern.compile("[!-~]*"); // OK - used to select most printable ASCII characters | ||
|
||
Pattern codePoints = Pattern.compile("[^\\x21-\\x7E]|[[\\](){}<>/%]*"); // OK | ||
|
||
Pattern NON_ALPHANUMERIC_REGEXP = Pattern.compile("([^\\#-~| |!])*"); // OK | ||
|
||
Pattern smallOverlap = Pattern.compile("[0-9a-fA-f]*"); // NOT OK | ||
|
||
Pattern weirdRange = Pattern.compile("[$-`]*"); // NOT OK | ||
|
||
Pattern keywordOperator = Pattern.compile("[!\\~\\*\\/%+-<>\\^|=&]*"); // NOT OK | ||
|
||
Pattern notYoutube = Pattern.compile("youtu.be/[a-z1-9.-_]+"); // NOT OK | ||
|
||
Pattern numberToLetter = Pattern.compile("[7-F]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass1 = Pattern.compile("[0-9\\d]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass2 = Pattern.compile("[\\w,.-?:*+]*"); // NOT OK | ||
|
||
Pattern nested = Pattern.compile("[[A-Za-z_][A-Za-z0-9._-]]*"); // OK, the dash it at the end | ||
|
||
Pattern octal = Pattern.compile("[\000-\037\040-\045]*"); // OK | ||
} | ||
} |
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/passing/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/JavaInlineExpectations.ql |
37 changes: 37 additions & 0 deletions
37
java/ql/test/query-tests/Postprocessing/passing/SuspiciousRegexpRange.java
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,37 @@ | ||
import java.util.regex.Pattern; | ||
|
||
class SuspiciousRegexpRange { | ||
void test() { | ||
Pattern overlap1 = Pattern.compile("^[0-93-5]*$"); // NOT OK | ||
|
||
Pattern overlap2 = Pattern.compile("[A-ZA-z]*"); // NOT OK | ||
|
||
Pattern isEmpty = Pattern.compile("^[z-a]*$"); // NOT OK | ||
|
||
Pattern isAscii = Pattern.compile("^[\\x00-\\x7F]*$"); // OK | ||
|
||
Pattern printable = Pattern.compile("[!-~]*"); // OK - used to select most printable ASCII characters | ||
|
||
Pattern codePoints = Pattern.compile("[^\\x21-\\x7E]|[[\\](){}<>/%]*"); // OK | ||
|
||
Pattern NON_ALPHANUMERIC_REGEXP = Pattern.compile("([^\\#-~| |!])*"); // OK | ||
|
||
Pattern smallOverlap = Pattern.compile("[0-9a-fA-f]*"); // NOT OK | ||
|
||
Pattern weirdRange = Pattern.compile("[$-`]*"); // NOT OK | ||
|
||
Pattern keywordOperator = Pattern.compile("[!\\~\\*\\/%+-<>\\^|=&]*"); // NOT OK | ||
|
||
Pattern notYoutube = Pattern.compile("youtu.be/[a-z1-9.-_]+"); // NOT OK | ||
|
||
Pattern numberToLetter = Pattern.compile("[7-F]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass1 = Pattern.compile("[0-9\\d]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass2 = Pattern.compile("[\\w,.-?:*+]*"); // NOT OK | ||
|
||
Pattern nested = Pattern.compile("[[A-Za-z_][A-Za-z0-9._-]]*"); // OK, the dash it at the end | ||
|
||
Pattern octal = Pattern.compile("[\000-\037\040-\045]*"); // OK | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/passingWithDiff/OverlyLargeRangeQuery.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,2 @@ | ||
| SuspiciousRegexpRange.java:11 | expected alert | NOT OK | | ||
| SuspiciousRegexpRange.java:7:49:7:51 | unexpected alert | Suspicious character range that overlaps with A-Z in the same character class, and is equivalent to [A-Z\\[\\\\\\]^_`a-z]. | |
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/passingWithDiff/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/JavaInlineExpectations.ql |
37 changes: 37 additions & 0 deletions
37
java/ql/test/query-tests/Postprocessing/passingWithDiff/SuspiciousRegexpRange.java
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,37 @@ | ||
import java.util.regex.Pattern; | ||
|
||
class SuspiciousRegexpRange { | ||
void test() { | ||
Pattern overlap1 = Pattern.compile("^[0-93-5]*$"); // NOT OK | ||
|
||
Pattern overlap2 = Pattern.compile("[A-ZA-z]*"); // OK | ||
|
||
Pattern isEmpty = Pattern.compile("^[z-a]*$"); // NOT OK | ||
|
||
Pattern isAscii = Pattern.compile("^[\\x00-\\x7F]*$"); // NOT OK | ||
|
||
Pattern printable = Pattern.compile("[!-~]*"); // OK - used to select most printable ASCII characters | ||
|
||
Pattern codePoints = Pattern.compile("[^\\x21-\\x7E]|[[\\](){}<>/%]*"); // OK | ||
|
||
Pattern NON_ALPHANUMERIC_REGEXP = Pattern.compile("([^\\#-~| |!])*"); // OK | ||
|
||
Pattern smallOverlap = Pattern.compile("[0-9a-fA-f]*"); // NOT OK | ||
|
||
Pattern weirdRange = Pattern.compile("[$-`]*"); // NOT OK | ||
|
||
Pattern keywordOperator = Pattern.compile("[!\\~\\*\\/%+-<>\\^|=&]*"); // NOT OK | ||
|
||
Pattern notYoutube = Pattern.compile("youtu.be/[a-z1-9.-_]+"); // NOT OK | ||
|
||
Pattern numberToLetter = Pattern.compile("[7-F]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass1 = Pattern.compile("[0-9\\d]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass2 = Pattern.compile("[\\w,.-?:*+]*"); // NOT OK | ||
|
||
Pattern nested = Pattern.compile("[[A-Za-z_][A-Za-z0-9._-]]*"); // OK, the dash it at the end | ||
|
||
Pattern octal = Pattern.compile("[\000-\037\040-\045]*"); // OK | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ql/test/query-tests/Postprocessing/passingWithUnrecognised/OverlyLargeRangeQuery.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 @@ | ||
| SuspiciousRegexpRange.java:13 | invalid inline expectation | IS OK - used to select most printable ASCII characters | |
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/passingWithUnrecognised/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/JavaInlineExpectations.ql |
37 changes: 37 additions & 0 deletions
37
java/ql/test/query-tests/Postprocessing/passingWithUnrecognised/SuspiciousRegexpRange.java
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,37 @@ | ||
import java.util.regex.Pattern; | ||
|
||
class SuspiciousRegexpRange { | ||
void test() { | ||
Pattern overlap1 = Pattern.compile("^[0-93-5]*$"); // NOT OK | ||
|
||
Pattern overlap2 = Pattern.compile("[A-ZA-z]*"); // NOT OK | ||
|
||
Pattern isEmpty = Pattern.compile("^[z-a]*$"); // NOT OK | ||
|
||
Pattern isAscii = Pattern.compile("^[\\x00-\\x7F]*$"); // OK | ||
|
||
Pattern printable = Pattern.compile("[!-~]*"); // IS OK - used to select most printable ASCII characters | ||
|
||
Pattern codePoints = Pattern.compile("[^\\x21-\\x7E]|[[\\](){}<>/%]*"); // OK | ||
|
||
Pattern NON_ALPHANUMERIC_REGEXP = Pattern.compile("([^\\#-~| |!])*"); // OK | ||
|
||
Pattern smallOverlap = Pattern.compile("[0-9a-fA-f]*"); // NOT OK | ||
|
||
Pattern weirdRange = Pattern.compile("[$-`]*"); // NOT OK | ||
|
||
Pattern keywordOperator = Pattern.compile("[!\\~\\*\\/%+-<>\\^|=&]*"); // NOT OK | ||
|
||
Pattern notYoutube = Pattern.compile("youtu.be/[a-z1-9.-_]+"); // NOT OK | ||
|
||
Pattern numberToLetter = Pattern.compile("[7-F]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass1 = Pattern.compile("[0-9\\d]*"); // NOT OK | ||
|
||
Pattern overlapsWithClass2 = Pattern.compile("[\\w,.-?:*+]*"); // NOT OK | ||
|
||
Pattern nested = Pattern.compile("[[A-Za-z_][A-Za-z0-9._-]]*"); // OK, the dash it at the end | ||
|
||
Pattern octal = Pattern.compile("[\000-\037\040-\045]*"); // OK | ||
} | ||
} |
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug1/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations1.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug2/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations2.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug3/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations3.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug4/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations4.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug5/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations5.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug6/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations6.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug7/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations7.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/postprocessingBug8/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/ProblematicJavaInlineExpectations8.ql |
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions
2
java/ql/test/query-tests/Postprocessing/unrecognised/OverlyLargeRangeQuery.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,2 @@ | ||
query: Security/CWE/CWE-020/OverlyLargeRange.ql | ||
postprocess: TestUtilities/JavaInlineExpectations.ql |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.