Skip to content

Commit 9decd51

Browse files
committed
Initial quantum support for C#
1 parent fb0f12b commit 9decd51

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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>;

csharp/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dependencies:
99
codeql/controlflow: ${workspace}
1010
codeql/dataflow: ${workspace}
1111
codeql/mad: ${workspace}
12+
codeql/quantum: ${workspace}
1213
codeql/ssa: ${workspace}
1314
codeql/threat-models: ${workspace}
1415
codeql/tutorial: ${workspace}

0 commit comments

Comments
 (0)