Skip to content

Commit 5cee9da

Browse files
committed
C++: Pretty print MaD ids in test output
1 parent ec09d36 commit 5cee9da

File tree

6 files changed

+129
-49
lines changed

6 files changed

+129
-49
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/ExternalFlow.qll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,49 @@ private predicate summaryModel0(
229229
)
230230
}
231231

232+
/**
233+
* Holds if the given extension tuple `madId` should pretty-print as `model`.
234+
*
235+
* This predicate should only be used in tests.
236+
*/
237+
predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
238+
exists(
239+
string package, string type, boolean subtypes, string name, string signature, string ext,
240+
string output, string kind, string provenance
241+
|
242+
Extensions::sourceModel(package, type, subtypes, name, signature, ext, output, kind, provenance,
243+
madId)
244+
|
245+
model =
246+
"Source: " + package + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
247+
ext + "; " + output + "; " + kind + "; " + provenance
248+
)
249+
or
250+
exists(
251+
string package, string type, boolean subtypes, string name, string signature, string ext,
252+
string input, string kind, string provenance
253+
|
254+
Extensions::sinkModel(package, type, subtypes, name, signature, ext, input, kind, provenance,
255+
madId)
256+
|
257+
model =
258+
"Sink: " + package + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
259+
ext + "; " + input + "; " + kind + "; " + provenance
260+
)
261+
or
262+
exists(
263+
string package, string type, boolean subtypes, string name, string signature, string ext,
264+
string input, string output, string kind, string provenance
265+
|
266+
Extensions::summaryModel(package, type, subtypes, name, signature, ext, input, output, kind,
267+
provenance, madId)
268+
|
269+
model =
270+
"Summary: " + package + "; " + type + "; " + subtypes + "; " + name + "; " + signature + "; " +
271+
ext + "; " + input + "; " + output + "; " + kind + "; " + provenance
272+
)
273+
}
274+
232275
/**
233276
* Holds if `input` is `input0`, but with all occurrences of `@` replaced
234277
* by `n` repetitions of `*` (and similarly for `output` and `output0`).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @kind test-postprocess
3+
*/
4+
5+
import semmle.code.cpp.dataflow.ExternalFlow
6+
import codeql.dataflow.test.ProvenancePathGraph::TestPostProcessing::TranslateProvenanceResults<interpretModelForTest/2>

0 commit comments

Comments
 (0)