|
| 1 | +private import csharp as Language |
| 2 | +private import codeql.quantum.experimental.Model |
| 3 | + |
| 4 | +private class UnknownLocation extends Language::Location { |
| 5 | + UnknownLocation() { this.getFile().getAbsolutePath() = "" } |
| 6 | +} |
| 7 | + |
| 8 | +/** |
| 9 | + * A dummy location which is used when something doesn't have a location in |
| 10 | + * the source code but needs to have a `Location` associated with it. There |
| 11 | + * may be several distinct kinds of unknown locations. For example: one for |
| 12 | + * expressions, one for statements and one for other program elements. |
| 13 | + */ |
| 14 | +private class UnknownDefaultLocation extends UnknownLocation { |
| 15 | + UnknownDefaultLocation() { locations_default(this, _, 0, 0, 0, 0) } |
| 16 | +} |
| 17 | + |
| 18 | +module CryptoInput implements InputSig<Language::Location> { |
| 19 | + class DataFlowNode = DataFlow::Node; |
| 20 | + |
| 21 | + class LocatableElement = Language::Element; |
| 22 | + |
| 23 | + class UnknownLocation = UnknownDefaultLocation; |
| 24 | + |
| 25 | + string locationToFileBaseNameAndLineNumberString(Location location) { |
| 26 | + result = location.getFile().getBaseName() + ":" + location.getStartLine() |
| 27 | + } |
| 28 | + |
| 29 | + LocatableElement dfn_to_element(DataFlow::Node node) { |
| 30 | + result = node.asExpr() or |
| 31 | + result = node.asParameter() |
| 32 | + } |
| 33 | + |
| 34 | + predicate artifactOutputFlowsToGenericInput( |
| 35 | + DataFlow::Node artifactOutput, DataFlow::Node otherInput |
| 36 | + ) { |
| 37 | + ArtifactFlow::flow(artifactOutput, otherInput) |
| 38 | + } |
| 39 | +} |
| 40 | + |
| 41 | +// Instantiate the `CryptographyBase` module |
| 42 | +module Crypto = CryptographyBase<Language::Location, CryptoInput>; |
0 commit comments