mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
refactor isAdditionalTaintStep to a utility predicate in InsecureRandomness
This commit is contained in:
@@ -36,16 +36,7 @@ module InsecureRandomness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
|
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
|
||||||
// Assume that all operations on tainted values preserve taint: crypto is hard
|
InsecureRandomness::isAdditionalTaintStep(pred, succ)
|
||||||
succ.asExpr().(BinaryExpr).getAnOperand() = pred.asExpr()
|
|
||||||
or
|
|
||||||
succ.asExpr().(UnaryExpr).getOperand() = pred.asExpr()
|
|
||||||
or
|
|
||||||
exists(DataFlow::MethodCallNode mc |
|
|
||||||
mc = DataFlow::globalVarRef("Math").getAMemberCall(_) and
|
|
||||||
pred = mc.getAnArgument() and
|
|
||||||
succ = mc
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,4 +78,20 @@ module InsecureRandomness {
|
|||||||
class CryptoKeySink extends Sink {
|
class CryptoKeySink extends Sink {
|
||||||
CryptoKeySink() { this instanceof CryptographicKey }
|
CryptoKeySink() { this instanceof CryptographicKey }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds if the step `pred` -> `succ` is an additional taint-step for random values that are not cryptographically secure.
|
||||||
|
*/
|
||||||
|
predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
|
||||||
|
// Assume that all operations on tainted values preserve taint: crypto is hard
|
||||||
|
succ.asExpr().(BinaryExpr).getAnOperand() = pred.asExpr()
|
||||||
|
or
|
||||||
|
succ.asExpr().(UnaryExpr).getOperand() = pred.asExpr()
|
||||||
|
or
|
||||||
|
exists(DataFlow::MethodCallNode mc |
|
||||||
|
mc = DataFlow::globalVarRef("Math").getAMemberCall(_) and
|
||||||
|
pred = mc.getAnArgument() and
|
||||||
|
succ = mc
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user