mirror of
https://github.com/github/codeql.git
synced 2026-03-02 22:03:42 +01:00
https://github.com/d10c/codeql/blob/d10c/diff-informed-phase-3/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayIndexCodeSpecified.ql#L48 https://github.com/d10c/codeql/blob/d10c/diff-informed-phase-3/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayConstructionCodeSpecified.ql#L28 https://github.com/d10c/codeql/blob/d10c/diff-informed-phase-3/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayConstruction.ql#L26 https://github.com/d10c/codeql/blob/d10c/diff-informed-phase-3/java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayIndex.ql#L24
35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
/** Provides a dataflow configuration to reason about improper validation of code-specified size used for array construction. */
|
|
|
|
import java
|
|
private import semmle.code.java.security.internal.ArraySizing
|
|
private import semmle.code.java.dataflow.TaintTracking
|
|
|
|
/**
|
|
* A dataflow configuration to reason about improper validation of code-specified size used for array construction.
|
|
*/
|
|
module BoundedFlowSourceConfig implements DataFlow::ConfigSig {
|
|
predicate isSource(DataFlow::Node source) {
|
|
source instanceof BoundedFlowSource and
|
|
// There is not a fixed lower bound which is greater than zero.
|
|
not source.(BoundedFlowSource).lowerBound() > 0
|
|
}
|
|
|
|
predicate isSink(DataFlow::Node sink) {
|
|
any(CheckableArrayAccess caa).canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), _)
|
|
}
|
|
|
|
predicate observeDiffInformedIncrementalMode() { any() }
|
|
|
|
Location getASelectedSinkLocation(DataFlow::Node sink) {
|
|
exists(ArrayCreationExpr arrayCreation, CheckableArrayAccess arrayAccess |
|
|
result = [arrayCreation, arrayAccess.getIndexExpr()].getLocation() and
|
|
arrayAccess.canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), arrayCreation)
|
|
)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Dataflow flow for improper validation of code-specified size used for array construction.
|
|
*/
|
|
module BoundedFlowSourceFlow = DataFlow::Global<BoundedFlowSourceConfig>;
|