Skip to content

Commit be6dbb5

Browse files
committed
Java: ImproperValidationOfArray...
1 parent 4159e76 commit be6dbb5

4 files changed

+28
-8
lines changed

java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionCodeSpecifiedQuery.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ module BoundedFlowSourceConfig implements DataFlow::ConfigSig {
1818
any(CheckableArrayAccess caa).canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), _)
1919
}
2020

21-
predicate observeDiffInformedIncrementalMode() {
22-
any() // TODO: Make sure that the location overrides match the query's select clause: Column 1 does not select a source or sink originating from the flow call on line 27 (/Users/d10c/src/semmle-code/ql/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayConstructionCodeSpecified.ql@28:8:28:33), Column 5 does not select a source or sink originating from the flow call on line 27 (/Users/d10c/src/semmle-code/ql/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayConstructionCodeSpecified.ql@29:85:29:97)
21+
predicate observeDiffInformedIncrementalMode() { any() }
22+
23+
Location getASelectedSinkLocation(DataFlow::Node sink) {
24+
exists(ArrayCreationExpr arrayCreation, CheckableArrayAccess arrayAccess |
25+
result = [arrayCreation, arrayAccess.getIndexExpr()].getLocation() and
26+
arrayAccess.canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), arrayCreation)
27+
)
2328
}
2429
}
2530

java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayConstructionQuery.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ module ImproperValidationOfArrayConstructionConfig implements DataFlow::ConfigSi
1515
any(CheckableArrayAccess caa).canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), _)
1616
}
1717

18-
predicate observeDiffInformedIncrementalMode() {
19-
any() // TODO: Make sure that the location overrides match the query's select clause: Column 1 does not select a source or sink originating from the flow call on line 25 (/Users/d10c/src/semmle-code/ql/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayConstruction.ql@26:8:26:33), Column 5 does not select a source or sink originating from the flow call on line 25 (/Users/d10c/src/semmle-code/ql/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayConstruction.ql@27:87:27:99)
18+
predicate observeDiffInformedIncrementalMode() { any() }
19+
20+
Location getASelectedSinkLocation(DataFlow::Node sink) {
21+
exists(ArrayCreationExpr arrayCreation, CheckableArrayAccess arrayAccess |
22+
result = [arrayCreation, arrayAccess.getIndexExpr()].getLocation() and
23+
arrayAccess.canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), arrayCreation)
24+
)
2025
}
2126
}
2227

java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayIndexCodeSpecifiedQuery.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ module BoundedFlowSourceConfig implements DataFlow::ConfigSig {
1515
exists(CheckableArrayAccess arrayAccess | arrayAccess.canThrowOutOfBounds(sink.asExpr()))
1616
}
1717

18-
predicate observeDiffInformedIncrementalMode() {
19-
any() // TODO: Make sure that the location overrides match the query's select clause: Column 1 does not select a source or sink originating from the flow call on line 26 (/Users/d10c/src/semmle-code/ql/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayIndexCodeSpecified.ql@48:8:48:33)
18+
predicate observeDiffInformedIncrementalMode() { any() }
19+
20+
Location getASelectedSinkLocation(DataFlow::Node sink) {
21+
exists(CheckableArrayAccess arrayAccess |
22+
result = arrayAccess.getIndexExpr().getLocation() and
23+
arrayAccess.canThrowOutOfBounds(sink.asExpr())
24+
)
2025
}
2126
}
2227

java/ql/lib/semmle/code/java/security/ImproperValidationOfArrayIndexQuery.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ module ImproperValidationOfArrayIndexConfig implements DataFlow::ConfigSig {
1919

2020
predicate isBarrierIn(DataFlow::Node node) { isSource(node) }
2121

22-
predicate observeDiffInformedIncrementalMode() {
23-
any() // TODO: Make sure that the location overrides match the query's select clause: Column 1 does not select a source or sink originating from the flow call on line 23 (/Users/d10c/src/semmle-code/ql/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayIndex.ql@24:8:24:33)
22+
predicate observeDiffInformedIncrementalMode() { any() }
23+
24+
Location getASelectedSinkLocation(DataFlow::Node sink) {
25+
exists(CheckableArrayAccess arrayAccess |
26+
result = arrayAccess.getIndexExpr().getLocation() and
27+
arrayAccess.canThrowOutOfBounds(sink.asExpr())
28+
)
2429
}
2530
}
2631

0 commit comments

Comments
 (0)