Skip to content

Commit 1464560

Browse files
committed
JS: Sync.
1 parent acb1191 commit 1464560

File tree

1 file changed

+47
-29
lines changed

1 file changed

+47
-29
lines changed

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -229,41 +229,49 @@ private predicate typeModel(string row) { any(TypeModelCsv s).row(inversePad(row
229229
private predicate typeVariableModel(string row) { any(TypeVariableModelCsv s).row(inversePad(row)) }
230230

231231
/** Holds if a source model exists for the given parameters. */
232-
predicate sourceModel(string type, string path, string kind) {
232+
predicate sourceModel(string type, string path, string kind, string model) {
233233
exists(string row |
234234
sourceModel(row) and
235235
row.splitAt(";", 0) = type and
236236
row.splitAt(";", 1) = path and
237-
row.splitAt(";", 2) = kind
237+
row.splitAt(";", 2) = kind and
238+
model = "SourceModelCsv"
238239
)
239240
or
240-
Extensions::sourceModel(type, path, kind)
241+
Extensions::sourceModel(type, path, kind) and
242+
model = "" // TODO: Insert MaD provenance from sourceModel
241243
}
242244

243245
/** Holds if a sink model exists for the given parameters. */
244-
private predicate sinkModel(string type, string path, string kind) {
246+
private predicate sinkModel(string type, string path, string kind, string model) {
245247
exists(string row |
246248
sinkModel(row) and
247249
row.splitAt(";", 0) = type and
248250
row.splitAt(";", 1) = path and
249-
row.splitAt(";", 2) = kind
251+
row.splitAt(";", 2) = kind and
252+
model = "SinkModelCsv"
250253
)
251254
or
252-
Extensions::sinkModel(type, path, kind)
255+
Extensions::sinkModel(type, path, kind) and
256+
model = "" // TODO: Insert MaD provenance from sinkModel
253257
}
254258

255259
/** Holds if a summary model `row` exists for the given parameters. */
256-
private predicate summaryModel(string type, string path, string input, string output, string kind) {
260+
private predicate summaryModel(
261+
string type, string path, string input, string output, string kind, string model
262+
) {
257263
exists(string row |
258264
summaryModel(row) and
259265
row.splitAt(";", 0) = type and
260266
row.splitAt(";", 1) = path and
261267
row.splitAt(";", 2) = input and
262268
row.splitAt(";", 3) = output and
263-
row.splitAt(";", 4) = kind
269+
row.splitAt(";", 4) = kind and
270+
model = "SummaryModelCsv"
264271
)
265272
or
266-
Extensions::summaryModel(type, path, input, output, kind)
273+
Extensions::summaryModel(type, path, input, output, kind) and
274+
model = "" // TODO: Insert MaD provenance from summaryModel
267275
}
268276

269277
/** Holds if a type model exists for the given parameters. */
@@ -294,9 +302,9 @@ private predicate typeVariableModel(string name, string path) {
294302
*/
295303
predicate isRelevantType(string type) {
296304
(
297-
sourceModel(type, _, _) or
298-
sinkModel(type, _, _) or
299-
summaryModel(type, _, _, _, _) or
305+
sourceModel(type, _, _, _) or
306+
sinkModel(type, _, _, _) or
307+
summaryModel(type, _, _, _, _, _) or
300308
typeModel(_, type, _)
301309
) and
302310
(
@@ -319,9 +327,9 @@ pragma[nomagic]
319327
predicate isRelevantFullPath(string type, string path) {
320328
isRelevantType(type) and
321329
(
322-
sourceModel(type, path, _) or
323-
sinkModel(type, path, _) or
324-
summaryModel(type, path, _, _, _) or
330+
sourceModel(type, path, _, _) or
331+
sinkModel(type, path, _, _) or
332+
summaryModel(type, path, _, _, _, _) or
325333
typeModel(_, type, path)
326334
)
327335
}
@@ -331,8 +339,8 @@ private predicate accessPathRange(string s) {
331339
isRelevantFullPath(_, s)
332340
or
333341
exists(string type | isRelevantType(type) |
334-
summaryModel(type, _, s, _, _) or
335-
summaryModel(type, _, _, s, _)
342+
summaryModel(type, _, s, _, _, _) or
343+
summaryModel(type, _, _, s, _, _)
336344
)
337345
or
338346
typeVariableModel(_, s)
@@ -543,7 +551,7 @@ private API::Node getNodeFromPath(string type, AccessPath path) {
543551

544552
pragma[nomagic]
545553
private predicate typeStepModel(string type, AccessPath basePath, AccessPath output) {
546-
summaryModel(type, basePath, "", output, "type")
554+
summaryModel(type, basePath, "", output, "type", _)
547555
}
548556

549557
pragma[nomagic]
@@ -621,9 +629,9 @@ module ModelOutput {
621629
* Holds if a CSV source model contributed `source` with the given `kind`.
622630
*/
623631
cached
624-
API::Node getASourceNode(string kind) {
632+
API::Node getASourceNode(string kind, string model) {
625633
exists(string type, string path |
626-
sourceModel(type, path, kind) and
634+
sourceModel(type, path, kind, model) and
627635
result = getNodeFromPath(type, path)
628636
)
629637
}
@@ -632,9 +640,9 @@ module ModelOutput {
632640
* Holds if a CSV sink model contributed `sink` with the given `kind`.
633641
*/
634642
cached
635-
API::Node getASinkNode(string kind) {
643+
API::Node getASinkNode(string kind, string model) {
636644
exists(string type, string path |
637-
sinkModel(type, path, kind) and
645+
sinkModel(type, path, kind, model) and
638646
result = getNodeFromPath(type, path)
639647
)
640648
}
@@ -644,18 +652,18 @@ module ModelOutput {
644652
*/
645653
cached
646654
predicate relevantSummaryModel(
647-
string type, string path, string input, string output, string kind
655+
string type, string path, string input, string output, string kind, string model
648656
) {
649657
isRelevantType(type) and
650-
summaryModel(type, path, input, output, kind)
658+
summaryModel(type, path, input, output, kind, model)
651659
}
652660

653661
/**
654662
* Holds if a `baseNode` is an invocation identified by the `type,path` part of a summary row.
655663
*/
656664
cached
657665
predicate resolvedSummaryBase(string type, string path, Specific::InvokeNode baseNode) {
658-
summaryModel(type, path, _, _, _) and
666+
summaryModel(type, path, _, _, _, _) and
659667
baseNode = getInvocationFromPath(type, path)
660668
}
661669

@@ -664,7 +672,7 @@ module ModelOutput {
664672
*/
665673
cached
666674
predicate resolvedSummaryRefBase(string type, string path, API::Node baseNode) {
667-
summaryModel(type, path, _, _, _) and
675+
summaryModel(type, path, _, _, _, _) and
668676
baseNode = getNodeFromPath(type, path)
669677
}
670678

@@ -680,12 +688,22 @@ module ModelOutput {
680688
import Specific::ModelOutputSpecific
681689
private import codeql.mad.ModelValidation as SharedModelVal
682690

691+
/**
692+
* Holds if a CSV source model contributed `source` with the given `kind`.
693+
*/
694+
API::Node getASourceNode(string kind) { result = getASourceNode(kind, _) }
695+
696+
/**
697+
* Holds if a CSV sink model contributed `sink` with the given `kind`.
698+
*/
699+
API::Node getASinkNode(string kind) { result = getASinkNode(kind, _) }
700+
683701
private module KindValConfig implements SharedModelVal::KindValidationConfigSig {
684-
predicate summaryKind(string kind) { summaryModel(_, _, _, _, kind) }
702+
predicate summaryKind(string kind) { summaryModel(_, _, _, _, kind, _) }
685703

686-
predicate sinkKind(string kind) { sinkModel(_, _, kind) }
704+
predicate sinkKind(string kind) { sinkModel(_, _, kind, _) }
687705

688-
predicate sourceKind(string kind) { sourceModel(_, _, kind) }
706+
predicate sourceKind(string kind) { sourceModel(_, _, kind, _) }
689707
}
690708

691709
private module KindVal = SharedModelVal::KindValidation<KindValConfig>;

0 commit comments

Comments
 (0)