From 68ddae291861ac94de542e8aa24ba8855ea198ac Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Mon, 15 Apr 2024 13:29:59 +0200 Subject: [PATCH] Python: Add support for pretty-printed provenace in tests. --- .../data/internal/ApiGraphModels.qll | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll b/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll index 7215bd71550..c04a85487ac 100644 --- a/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll +++ b/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll @@ -369,6 +369,28 @@ private predicate typeVariableModel(string name, string path) { Extensions::typeVariableModel(name, path) } +/** + * Holds if the given extension tuple `madId` should pretty-print as `model`. + * + * This predicate should only be used in tests. + */ +predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) { + exists(string type, string path, string kind | + Extensions::sourceModel(type, path, kind, madId) and + model = "Source: " + type + "; " + path + "; " + kind + ) + or + exists(string type, string path, string kind | + Extensions::sinkModel(type, path, kind, madId) and + model = "Sink: " + type + "; " + path + "; " + kind + ) + or + exists(string type, string path, string input, string output, string kind | + Extensions::summaryModel(type, path, input, output, kind, madId) and + model = "Summary: " + type + "; " + path + "; " + input + "; " + output + "; " + kind + ) +} + /** * Holds if rows involving `type` might be relevant for the analysis of this database. */