Rust: Add source models for io.

This commit is contained in:
Geoffrey White
2025-04-11 17:00:36 +01:00
parent 4f9f550ba6
commit 7a9ea52bc7
4 changed files with 60 additions and 14 deletions

View File

@@ -128,6 +128,32 @@ module FileSource {
}
}
/**
* A data flow source corresponding to standard input.
*/
final class StdInSource = StdInSource::Range;
/**
* An externally modeled source for data from standard input.
*/
class ModeledStdInSourceSource extends StdInSource::Range {
ModeledStdInSourceSource() { sourceNode(this, "stdin") }
}
/**
* Provides a class for modeling new sources for standard input.
*/
module StdInSource {
/**
* A data flow source corresponding to standard input.
*/
abstract class Range extends ThreatModelSource::Range {
override string getThreatModel() { result = "stdin" }
override string getSourceType() { result = "StdInSource" }
}
}
/**
* A data flow source corresponding to the program's database reads.
*/

View File

@@ -0,0 +1,6 @@
extensions:
- addsTo:
pack: codeql/rust-all
extensible: sourceModel
data:
- ["lang:std", "crate::io::stdio::stdin", "ReturnValue", "stdin", "manual"]