From 0fcfb4742323fd4d65c22da74e94ead8fd3ba781 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Wed, 7 Aug 2024 13:18:19 +0200 Subject: [PATCH] Sync shared files --- .../internal/ApiGraphModelsExtensions.qll | 22 +++++++++++++++++++ .../internal/ApiGraphModelsExtensions.qll | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsExtensions.qll b/javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsExtensions.qll index 51e71f68b1e..b86d7de457e 100644 --- a/javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsExtensions.qll +++ b/javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsExtensions.qll @@ -45,3 +45,25 @@ extensible predicate typeModel(string type1, string type2, string path); * Holds if `path` can be substituted for a token `TypeVar[name]`. */ extensible predicate typeVariableModel(string name, string 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 | + sourceModel(type, path, kind, madId) and + model = "Source: " + type + "; " + path + "; " + kind + ) + or + exists(string type, string path, string kind | + sinkModel(type, path, kind, madId) and + model = "Sink: " + type + "; " + path + "; " + kind + ) + or + exists(string type, string path, string input, string output, string kind | + summaryModel(type, path, input, output, kind, madId) and + model = "Summary: " + type + "; " + path + "; " + input + "; " + output + "; " + kind + ) +} diff --git a/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModelsExtensions.qll b/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModelsExtensions.qll index 51e71f68b1e..b86d7de457e 100644 --- a/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModelsExtensions.qll +++ b/python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModelsExtensions.qll @@ -45,3 +45,25 @@ extensible predicate typeModel(string type1, string type2, string path); * Holds if `path` can be substituted for a token `TypeVar[name]`. */ extensible predicate typeVariableModel(string name, string 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 | + sourceModel(type, path, kind, madId) and + model = "Source: " + type + "; " + path + "; " + kind + ) + or + exists(string type, string path, string kind | + sinkModel(type, path, kind, madId) and + model = "Sink: " + type + "; " + path + "; " + kind + ) + or + exists(string type, string path, string input, string output, string kind | + summaryModel(type, path, input, output, kind, madId) and + model = "Summary: " + type + "; " + path + "; " + input + "; " + output + "; " + kind + ) +}