mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
condense code
This commit is contained in:
@@ -96,20 +96,22 @@ private predicate hasKeySizeInInitMethod(DataFlow::Node node, string typeFlag) {
|
||||
jcaSpec instanceof JavaSecurityKeyPairGenerator and typeFlag.matches("asymmetric%")
|
||||
) and
|
||||
(
|
||||
jcaSpec.getAlgoSpec().(StringLiteral).getValue().toUpperCase() = "AES" and
|
||||
typeFlag = "symmetric"
|
||||
getAlgoName(jcaSpec) = "AES" and typeFlag = "symmetric"
|
||||
or
|
||||
jcaSpec.getAlgoSpec().(StringLiteral).getValue().toUpperCase().matches(["RSA", "DSA", "DH"]) and
|
||||
typeFlag = "asymmetric-non-ec"
|
||||
getAlgoName(jcaSpec).matches(["RSA", "DSA", "DH"]) and typeFlag = "asymmetric-non-ec"
|
||||
or
|
||||
jcaSpec.getAlgoSpec().(StringLiteral).getValue().toUpperCase().matches("EC%") and
|
||||
typeFlag = "asymmetric-ec"
|
||||
getAlgoName(jcaSpec).matches("EC%") and typeFlag = "asymmetric-ec"
|
||||
) and
|
||||
DataFlow::localExprFlow(jcaSpec, ma.getQualifier()) and
|
||||
node.asExpr() = ma.getArgument(0)
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: this predicate is just a poc for more code condensing; redo this
|
||||
private string getAlgoName(JavaxCryptoAlgoSpec jca) {
|
||||
result = jca.getAlgoSpec().(StringLiteral).getValue().toUpperCase()
|
||||
}
|
||||
|
||||
// TODO: rethink the predicate name; also think about whether this could/should be a class instead; or a predicate within the sink class so can do sink.predicate()...
|
||||
// TODO: can prbly re-work way using the typeFlag to be better and less repetitive
|
||||
private predicate hasKeySizeInSpec(DataFlow::Node node, string typeFlag) {
|
||||
|
||||
Reference in New Issue
Block a user