Skip to content

Commit 43de3a1

Browse files
committed
PS: Use the existing MaD rows to model file reads as flow sources.
1 parent 1637df0 commit 43de3a1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

powershell/ql/lib/semmle/code/powershell/dataflow/flowsources/FlowSources.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
private import semmle.code.powershell.dataflow.internal.DataFlowPublic as DataFlow
33
import semmle.code.powershell.dataflow.flowsources.Remote
44
import semmle.code.powershell.dataflow.flowsources.Local
5+
import semmle.code.powershell.dataflow.flowsources.Stored
56
import semmle.code.powershell.frameworks.data.internal.ApiGraphModels
67

78
/**
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Provides classes representing sources of stored data.
3+
*/
4+
5+
import powershell
6+
private import FlowSources
7+
8+
/** A data flow source of stored user input. */
9+
abstract class StoredFlowSource extends SourceNode {
10+
override string getThreatModel() { result = "local" }
11+
}
12+
13+
/**
14+
* A node with input from a database.
15+
*/
16+
abstract class DatabaseInputSource extends StoredFlowSource {
17+
override string getThreatModel() { result = "database" }
18+
19+
override string getSourceType() { result = "database input" }
20+
}
21+
22+
private class ExternalDatabaseInputSource extends DatabaseInputSource {
23+
ExternalDatabaseInputSource() { this = ModelOutput::getASourceNode("database", _).asSource() }
24+
}
25+
26+
/** A file stream source is considered a stored flow source. */
27+
abstract class FileStreamStoredFlowSource extends StoredFlowSource {
28+
override string getThreatModel() { result = "file" }
29+
30+
override string getSourceType() { result = "file stream" }
31+
}
32+
33+
private class ExternalFileStreamStoredFlowSource extends FileStreamStoredFlowSource {
34+
ExternalFileStreamStoredFlowSource() { this = ModelOutput::getASourceNode("file", _).asSource() }
35+
}

0 commit comments

Comments
 (0)