mirror of
https://github.com/github/codeql.git
synced 2026-04-24 00:05:14 +02:00
Add generic artifact data-flow
The relation between RNG and other artifacts has been added Nonce has been completed to report its source
This commit is contained in:
@@ -2,6 +2,7 @@ private import codeql.cryptography.Model
|
||||
private import java as Language
|
||||
private import semmle.code.java.security.InsecureRandomnessQuery
|
||||
private import semmle.code.java.security.RandomQuery
|
||||
private import semmle.code.java.dataflow.DataFlow
|
||||
|
||||
private class UnknownLocation extends Language::Location {
|
||||
UnknownLocation() { this.getFile().getAbsolutePath() = "" }
|
||||
@@ -36,6 +37,10 @@ module Crypto = CryptographyBase<Language::Location, CryptoInput>;
|
||||
*/
|
||||
abstract class RandomnessInstance extends Crypto::RandomNumberGenerationInstance {
|
||||
override DataFlow::Node asOutputData() { result.asExpr() = this }
|
||||
|
||||
override predicate flowsTo(Crypto::ArtifactLocatableElement other) {
|
||||
RNGToArtifactFlow::flow(this.asOutputData(), other.getInput())
|
||||
}
|
||||
}
|
||||
|
||||
class SecureRandomnessInstance extends RandomnessInstance {
|
||||
@@ -50,5 +55,20 @@ class InsecureRandomnessInstance extends RandomnessInstance {
|
||||
InsecureRandomnessInstance() { exists(InsecureRandomnessSource node | this = node.asExpr()) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Random number generation artifact to other artifact flow configuration
|
||||
*/
|
||||
module RNGToArtifactFlowConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source = any(Crypto::RandomNumberGenerationInstance rng).asOutputData()
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
sink = any(Crypto::ArtifactLocatableElement other).getInput()
|
||||
}
|
||||
}
|
||||
|
||||
module RNGToArtifactFlow = DataFlow::Global<RNGToArtifactFlowConfig>;
|
||||
|
||||
// Import library-specific modeling
|
||||
import JCA
|
||||
|
||||
Reference in New Issue
Block a user