|
| 1 | +/** |
| 2 | + * Provides classes representing sources of local input. |
| 3 | + */ |
| 4 | + |
| 5 | +import powershell |
| 6 | +private import FlowSources |
| 7 | + |
| 8 | +/** A data flow source of local data. */ |
| 9 | +abstract class LocalFlowSource extends SourceNode { |
| 10 | + override string getSourceType() { result = "local flow source" } |
| 11 | + |
| 12 | + override string getThreatModel() { result = "local" } |
| 13 | +} |
| 14 | + |
| 15 | +private class ExternalLocalFlowSource extends LocalFlowSource { |
| 16 | + ExternalLocalFlowSource() { this = ModelOutput::getASourceNode("local", _).asSource() } |
| 17 | + |
| 18 | + override string getSourceType() { result = "external" } |
| 19 | +} |
| 20 | + |
| 21 | +/** A data flow source of local user input. */ |
| 22 | +abstract class LocalUserInputSource extends LocalFlowSource { } |
| 23 | + |
| 24 | +/** |
| 25 | + * A dataflow source that represents the access of an environment variable. |
| 26 | + */ |
| 27 | +abstract class EnvironmentVariableSource extends LocalFlowSource { |
| 28 | + override string getThreatModel() { result = "environment" } |
| 29 | + |
| 30 | + override string getSourceType() { result = "environment variable" } |
| 31 | +} |
| 32 | + |
| 33 | +private class ExternalEnvironmentVariableSource extends EnvironmentVariableSource { |
| 34 | + ExternalEnvironmentVariableSource() { |
| 35 | + this = ModelOutput::getASourceNode("environment", _).asSource() |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * A dataflow source that represents the access of a command line argument. |
| 41 | + */ |
| 42 | +abstract class CommandLineArgumentSource extends LocalFlowSource { |
| 43 | + override string getThreatModel() { result = "commandargs" } |
| 44 | + |
| 45 | + override string getSourceType() { result = "command line argument" } |
| 46 | +} |
| 47 | + |
| 48 | +private class ExternalCommandLineArgumentSource extends CommandLineArgumentSource { |
| 49 | + ExternalCommandLineArgumentSource() { |
| 50 | + this = ModelOutput::getASourceNode("command-line", _).asSource() |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +/** |
| 55 | + * A data flow source that represents the parameters of the `Main` method of a program. |
| 56 | + */ |
| 57 | +private class MainMethodArgumentSource extends CommandLineArgumentSource { |
| 58 | + MainMethodArgumentSource() { this.asParameter().getFunction() instanceof TopLevel } |
| 59 | +} |
| 60 | + |
| 61 | +/** |
| 62 | + * A data flow source that represents the access of a value from the Windows registry. |
| 63 | + */ |
| 64 | +abstract class WindowsRegistrySource extends LocalFlowSource { |
| 65 | + override string getThreatModel() { result = "windows-registry" } |
| 66 | + |
| 67 | + override string getSourceType() { result = "a value from the Windows registry" } |
| 68 | +} |
| 69 | + |
| 70 | +private class ExternalWindowsRegistrySource extends WindowsRegistrySource { |
| 71 | + ExternalWindowsRegistrySource() { |
| 72 | + this = ModelOutput::getASourceNode("windows-registry", _).asSource() |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +/** |
| 77 | + * A dataflow source that represents the reading from stdin. |
| 78 | + */ |
| 79 | +abstract class StdinSource extends LocalFlowSource { |
| 80 | + override string getThreatModel() { result = "stdin" } |
| 81 | + |
| 82 | + override string getSourceType() { result = "read from stdin" } |
| 83 | +} |
| 84 | + |
| 85 | +private class ExternalStdinSource extends StdinSource { |
| 86 | + ExternalStdinSource() { this = ModelOutput::getASourceNode("stdin", _).asSource() } |
| 87 | +} |
0 commit comments