|
| 1 | +/** |
| 2 | + * Provides abstract classes representing generic concepts such as file system |
| 3 | + * access or system command execution, for which individual framework libraries |
| 4 | + * provide concrete subclasses. |
| 5 | + */ |
| 6 | + |
| 7 | +import python |
| 8 | +private import experimental.dataflow.DataFlow |
| 9 | +private import experimental.semmle.python.Frameworks |
| 10 | + |
| 11 | +/** |
| 12 | + * A data-flow node that executes an operating system command, |
| 13 | + * for instance by spawning a new process. |
| 14 | + * |
| 15 | + * Extend this class to refine existing API models. If you want to model new APIs, |
| 16 | + * extend `SystemCommandExecution::Range` instead. |
| 17 | + */ |
| 18 | +class SystemCommandExecution extends DataFlow::Node { |
| 19 | + SystemCommandExecution::Range self; |
| 20 | + |
| 21 | + SystemCommandExecution() { this = self } |
| 22 | + |
| 23 | + /** Gets the argument that specifies the command to be executed. */ |
| 24 | + DataFlow::Node getCommand() { result = self.getCommand() } |
| 25 | +} |
| 26 | + |
| 27 | +/** Provides a class for modeling new system-command execution APIs. */ |
| 28 | +module SystemCommandExecution { |
| 29 | + /** |
| 30 | + * A data-flow node that executes an operating system command, |
| 31 | + * for instance by spawning a new process. |
| 32 | + * |
| 33 | + * Extend this class to model new APIs. If you want to refine existing API models, |
| 34 | + * extend `SystemCommandExecution` instead. |
| 35 | + */ |
| 36 | + abstract class Range extends DataFlow::Node { |
| 37 | + /** Gets the argument that specifies the command to be executed. */ |
| 38 | + abstract DataFlow::Node getCommand(); |
| 39 | + } |
| 40 | +} |
0 commit comments