mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Data flow: Order provenance output by textual representation
This commit is contained in:
@@ -26,15 +26,36 @@ private module TranslateModels<
|
||||
)
|
||||
}
|
||||
|
||||
private predicate rankedMadIds(string madId, int r) {
|
||||
madId = rank[r](string madId0 | madIds(madId0) | madId0 order by madId0.toInt())
|
||||
private QlBuiltins::ExtensionId getModelId(string model) {
|
||||
madIds(result.toString()) and
|
||||
interpretModelForTest(result, model)
|
||||
}
|
||||
|
||||
// collapse models with the same textual representation, in order to not rely
|
||||
// on the order of `ExtensionId`s
|
||||
private module ExtensionIdSets =
|
||||
QlBuiltins::InternSets<string, QlBuiltins::ExtensionId, getModelId/1>;
|
||||
|
||||
private predicate rankedMadIds(ExtensionIdSets::Set extIdSet, int r) {
|
||||
extIdSet =
|
||||
rank[r](ExtensionIdSets::Set extIdSet0, string model |
|
||||
extIdSet0 = ExtensionIdSets::getSet(model)
|
||||
|
|
||||
extIdSet0 order by model
|
||||
)
|
||||
}
|
||||
|
||||
private predicate translateModel(string id, int r) {
|
||||
exists(QlBuiltins::ExtensionId madId, ExtensionIdSets::Set extIdSet |
|
||||
id = madId.toString() and
|
||||
extIdSet.contains(madId) and
|
||||
rankedMadIds(extIdSet, r)
|
||||
)
|
||||
}
|
||||
|
||||
/** Lists the renumbered and pretty-printed models used in the edges relation. */
|
||||
predicate models(int r, string model) {
|
||||
exists(QlBuiltins::ExtensionId madId |
|
||||
rankedMadIds(madId.toString(), r) and interpretModelForTest(madId, model)
|
||||
)
|
||||
exists(string madId | translateModel(madId, r) and getModelId(model).toString() = madId)
|
||||
}
|
||||
|
||||
private predicate translateModelsPart(string model1, string model2, int i) {
|
||||
@@ -46,7 +67,7 @@ private module TranslateModels<
|
||||
translateModelsPart(model1, part, i - 1) and
|
||||
madId = s.regexpCapture("([0-9]*)(.*)", 1) and
|
||||
rest = s.regexpCapture("([0-9]*)(.*)", 2) and
|
||||
rankedMadIds(madId, r) and
|
||||
translateModel(madId, r) and
|
||||
model2 = part + "MaD:" + r + rest
|
||||
)
|
||||
)
|
||||
@@ -102,17 +123,6 @@ module TestPostProcessing {
|
||||
|
||||
private module Models = TranslateModels<interpretModelForTest/2, provenance/1>;
|
||||
|
||||
private newtype TModelRow = TMkModelRow(int r, string model) { Models::models(r, model) }
|
||||
|
||||
private predicate rankedModels(int i, int r, string model) {
|
||||
TMkModelRow(r, model) =
|
||||
rank[i](TModelRow row, int r0, string model0 |
|
||||
row = TMkModelRow(r0, model0)
|
||||
|
|
||||
row order by r0, model0
|
||||
)
|
||||
}
|
||||
|
||||
query predicate results(string relation, int row, int column, string data) {
|
||||
queryResults(relation, row, column, data) and
|
||||
(relation != "edges" or column != provenanceColumn())
|
||||
@@ -124,11 +134,11 @@ module TestPostProcessing {
|
||||
Models::translateModels(model, data)
|
||||
)
|
||||
or
|
||||
exists(int r, string model |
|
||||
exists(string model |
|
||||
relation = "models" and
|
||||
rankedModels(row, r, model)
|
||||
Models::models(row, model)
|
||||
|
|
||||
column = 0 and data = r.toString()
|
||||
column = 0 and data = row.toString()
|
||||
or
|
||||
column = 1 and data = model
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user