Skip to content

Commit a9ed412

Browse files
Driver apps framework (#165)
* framework for writing queries for apps that interact with drivers * remove extra print
1 parent fa33730 commit a9ed412

11 files changed

+574
-2
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
2+
<qhelp>
3+
<overview>
4+
<p>
5+
TODO overview
6+
</p>
7+
</overview>
8+
<recommendation>
9+
<p>
10+
TODO recommendation
11+
</p>
12+
</recommendation>
13+
<example>
14+
<p>
15+
TODO example
16+
</p>
17+
<sample language="c"> <![CDATA[
18+
// Example code
19+
}]]>
20+
</sample>
21+
<p>
22+
TODO example 2
23+
</p>
24+
<sample language="c"> <![CDATA[
25+
// Example code
26+
}]]>
27+
</sample>
28+
</example>
29+
<semmleNotes>
30+
<p>
31+
TODO notes
32+
</p>
33+
</semmleNotes>
34+
<references>
35+
<li>
36+
<a href="example.com">
37+
Example link
38+
</a>
39+
</li>
40+
</references>
41+
</qhelp>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
/**
4+
* @id cpp/drivers/TODO
5+
* @kind problem
6+
* @name TODO
7+
* @description TODO
8+
* @platform Desktop
9+
* @feature.area Multiple
10+
* @impact Insecure Coding Practice
11+
* @repro.text
12+
* @owner.email: [email protected]
13+
* @opaqueid CQLD-TODO
14+
* @problem.severity warning
15+
* @precision medium
16+
* @tags correctness
17+
* @scope domainspecific
18+
* @query-version v1
19+
*/
20+
21+
22+
import cpp
23+
24+
from Function f
25+
where
26+
f.getName().matches("DriverEntry")
27+
select f, "TODO"
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
{
2+
"$schema" : "https://json.schemastore.org/sarif-2.1.0.json",
3+
"version" : "2.1.0",
4+
"runs" : [ {
5+
"tool" : {
6+
"driver" : {
7+
"name" : "CodeQL",
8+
"organization" : "GitHub",
9+
"semanticVersion" : "2.15.4",
10+
"notifications" : [ {
11+
"id" : "cpp/baseline/expected-extracted-files",
12+
"name" : "cpp/baseline/expected-extracted-files",
13+
"shortDescription" : {
14+
"text" : "Expected extracted files"
15+
},
16+
"fullDescription" : {
17+
"text" : "Files appearing in the source archive that are expected to be extracted."
18+
},
19+
"defaultConfiguration" : {
20+
"enabled" : true
21+
},
22+
"properties" : {
23+
"tags" : [ "expected-extracted-files", "telemetry" ]
24+
}
25+
} ],
26+
"rules" : [ {
27+
"id" : "cpp/drivers/TODO",
28+
"name" : "cpp/drivers/TODO",
29+
"shortDescription" : {
30+
"text" : "TODO"
31+
},
32+
"fullDescription" : {
33+
"text" : "TODO"
34+
},
35+
"defaultConfiguration" : {
36+
"enabled" : true,
37+
"level" : "warning"
38+
},
39+
"properties" : {
40+
"tags" : [ "correctness" ],
41+
"description" : "TODO",
42+
"feature.area" : "Multiple",
43+
"id" : "cpp/drivers/TODO",
44+
"impact" : "Insecure Coding Practice",
45+
"kind" : "problem",
46+
"name" : "TODO",
47+
"opaqueid" : "CQLD-TODO",
48+
"owner.email:" : "[email protected]",
49+
"platform" : "Desktop",
50+
"precision" : "medium",
51+
"problem.severity" : "warning",
52+
"query-version" : "v1",
53+
"repro.text" : "",
54+
"scope" : "domainspecific"
55+
}
56+
} ]
57+
},
58+
"extensions" : [ {
59+
"name" : "microsoft/windows-drivers",
60+
"semanticVersion" : "1.0.13+4cf80ade609037becb8999823de45e08bd818a20",
61+
"locations" : [ {
62+
"uri" : "file:///C:/codeql-home/WDDST/src/",
63+
"description" : {
64+
"text" : "The QL pack root directory."
65+
}
66+
}, {
67+
"uri" : "file:///C:/codeql-home/WDDST/src/qlpack.yml",
68+
"description" : {
69+
"text" : "The QL pack definition file."
70+
}
71+
} ]
72+
} ]
73+
},
74+
"invocations" : [ {
75+
"toolExecutionNotifications" : [ {
76+
"locations" : [ {
77+
"physicalLocation" : {
78+
"artifactLocation" : {
79+
"uri" : "driver/driver_snippet.c",
80+
"uriBaseId" : "%SRCROOT%",
81+
"index" : 1
82+
}
83+
}
84+
} ],
85+
"message" : {
86+
"text" : ""
87+
},
88+
"level" : "none",
89+
"descriptor" : {
90+
"id" : "cpp/baseline/expected-extracted-files",
91+
"index" : 0
92+
},
93+
"properties" : {
94+
"formattedMessage" : {
95+
"text" : ""
96+
}
97+
}
98+
}, {
99+
"locations" : [ {
100+
"physicalLocation" : {
101+
"artifactLocation" : {
102+
"uri" : "driver/fail_driver1.c",
103+
"uriBaseId" : "%SRCROOT%",
104+
"index" : 0
105+
}
106+
}
107+
} ],
108+
"message" : {
109+
"text" : ""
110+
},
111+
"level" : "none",
112+
"descriptor" : {
113+
"id" : "cpp/baseline/expected-extracted-files",
114+
"index" : 0
115+
},
116+
"properties" : {
117+
"formattedMessage" : {
118+
"text" : ""
119+
}
120+
}
121+
}, {
122+
"locations" : [ {
123+
"physicalLocation" : {
124+
"artifactLocation" : {
125+
"uri" : "driver/fail_driver1.h",
126+
"uriBaseId" : "%SRCROOT%",
127+
"index" : 2
128+
}
129+
}
130+
} ],
131+
"message" : {
132+
"text" : ""
133+
},
134+
"level" : "none",
135+
"descriptor" : {
136+
"id" : "cpp/baseline/expected-extracted-files",
137+
"index" : 0
138+
},
139+
"properties" : {
140+
"formattedMessage" : {
141+
"text" : ""
142+
}
143+
}
144+
} ],
145+
"executionSuccessful" : true
146+
} ],
147+
"artifacts" : [ {
148+
"location" : {
149+
"uri" : "driver/fail_driver1.c",
150+
"uriBaseId" : "%SRCROOT%",
151+
"index" : 0
152+
}
153+
}, {
154+
"location" : {
155+
"uri" : "driver/driver_snippet.c",
156+
"uriBaseId" : "%SRCROOT%",
157+
"index" : 1
158+
}
159+
}, {
160+
"location" : {
161+
"uri" : "driver/fail_driver1.h",
162+
"uriBaseId" : "%SRCROOT%",
163+
"index" : 2
164+
}
165+
} ],
166+
"results" : [ {
167+
"ruleId" : "cpp/drivers/TODO",
168+
"ruleIndex" : 0,
169+
"rule" : {
170+
"id" : "cpp/drivers/TODO",
171+
"index" : 0
172+
},
173+
"message" : {
174+
"text" : "TODO"
175+
},
176+
"locations" : [ {
177+
"physicalLocation" : {
178+
"artifactLocation" : {
179+
"uri" : "driver/fail_driver1.c",
180+
"uriBaseId" : "%SRCROOT%",
181+
"index" : 0
182+
},
183+
"region" : {
184+
"startLine" : 56,
185+
"endColumn" : 12
186+
}
187+
}
188+
} ],
189+
"partialFingerprints" : {
190+
"primaryLocationLineHash" : "60c6386a5ee58eb6:1",
191+
"primaryLocationStartColumnFingerprint" : "0"
192+
}
193+
} ],
194+
"columnKind" : "utf16CodeUnits",
195+
"properties" : {
196+
"semmle.formatSpecifier" : "sarifv2.1.0"
197+
}
198+
} ]
199+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
// Macros to enable or disable a code section that may or may not conflict with this test.
5+
#define SET_DISPATCH 1
6+
7+
// Template function. Not used for this test.
8+
void top_level_call()
9+
{
10+
}
11+
12+
// TODO add tests for query
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ApplicationForDriversTestTemplate", "ApplicationForDriversTestTemplate.vcxproj", "{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|ARM = Debug|ARM
11+
Debug|ARM64 = Debug|ARM64
12+
Debug|x64 = Debug|x64
13+
Debug|x86 = Debug|x86
14+
Release|ARM = Release|ARM
15+
Release|ARM64 = Release|ARM64
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|ARM.ActiveCfg = Debug|ARM
21+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|ARM.Build.0 = Debug|ARM
22+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|ARM64.ActiveCfg = Debug|ARM64
23+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|ARM64.Build.0 = Debug|ARM64
24+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|x64.ActiveCfg = Debug|x64
25+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|x64.Build.0 = Debug|x64
26+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|x86.ActiveCfg = Debug|Win32
27+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Debug|x86.Build.0 = Debug|Win32
28+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|ARM.ActiveCfg = Release|ARM
29+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|ARM.Build.0 = Release|ARM
30+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|ARM64.ActiveCfg = Release|ARM64
31+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|ARM64.Build.0 = Release|ARM64
32+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|x64.ActiveCfg = Release|x64
33+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|x64.Build.0 = Release|x64
34+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|x86.ActiveCfg = Release|Win32
35+
{7EB8FC7A-AD1E-4560-8513-A986DDE4F05F}.Release|x86.Build.0 = Release|Win32
36+
EndGlobalSection
37+
GlobalSection(SolutionProperties) = preSolution
38+
HideSolutionNode = FALSE
39+
EndGlobalSection
40+
EndGlobal

0 commit comments

Comments
 (0)