Skip to content

Commit 7910bf6

Browse files
committed
all: sync API graph files
1 parent 11383d0 commit 7910bf6

File tree

4 files changed

+168
-4
lines changed

4 files changed

+168
-4
lines changed

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

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,26 @@ private predicate sinkModel(string type, string path, string kind, string model)
344344
)
345345
}
346346

347+
/** Holds if a barrier model exists for the given parameters. */
348+
private predicate barrierModel(string type, string path, string kind, string model) {
349+
// No deprecation adapter for barrier models, they were not around back then.
350+
exists(QlBuiltins::ExtensionId madId |
351+
Extensions::barrierModel(type, path, kind, madId) and
352+
model = "MaD:" + madId.toString()
353+
)
354+
}
355+
356+
/** Holds if a barrier guard model exists for the given parameters. */
357+
private predicate barrierGuardModel(
358+
string type, string path, string branch, string kind, string model
359+
) {
360+
// No deprecation adapter for barrier models, they were not around back then.
361+
exists(QlBuiltins::ExtensionId madId |
362+
Extensions::barrierGuardModel(type, path, branch, kind, madId) and
363+
model = "MaD:" + madId.toString()
364+
)
365+
}
366+
347367
/** Holds if a summary model `row` exists for the given parameters. */
348368
private predicate summaryModel(
349369
string type, string path, string input, string output, string kind, string model
@@ -400,6 +420,8 @@ predicate isRelevantType(string type) {
400420
(
401421
sourceModel(type, _, _, _) or
402422
sinkModel(type, _, _, _) or
423+
barrierModel(type, _, _, _) or
424+
barrierGuardModel(type, _, _, _, _) or
403425
summaryModel(type, _, _, _, _, _) or
404426
typeModel(_, type, _)
405427
) and
@@ -427,6 +449,8 @@ predicate isRelevantFullPath(string type, string path) {
427449
(
428450
sourceModel(type, path, _, _) or
429451
sinkModel(type, path, _, _) or
452+
barrierModel(type, path, _, _) or
453+
barrierGuardModel(type, path, _, _, _) or
430454
summaryModel(type, path, _, _, _, _) or
431455
typeModel(_, type, path)
432456
)
@@ -745,6 +769,32 @@ module ModelOutput {
745769
)
746770
}
747771

772+
/**
773+
* Holds if a barrier model contributed `barrier` with the given `kind`.
774+
*/
775+
cached
776+
API::Node getABarrierNode(string kind, string model) {
777+
exists(string type, string path |
778+
barrierModel(type, path, kind, model) and
779+
result = getNodeFromPath(type, path)
780+
)
781+
}
782+
783+
/**
784+
* Holds if a barrier model contributed `barrier` with the given `kind`.
785+
*/
786+
cached
787+
API::Node getABarrierGuardNode(string kind, boolean branch, string model) {
788+
exists(string type, string path, string branch_str |
789+
branch = true and branch_str = "true"
790+
or
791+
branch = false and branch_str = "false"
792+
|
793+
barrierGuardModel(type, path, branch_str, kind, model) and
794+
result = getNodeFromPath(type, path)
795+
)
796+
}
797+
748798
/**
749799
* Holds if a relevant summary exists for these parameters.
750800
*/
@@ -787,15 +837,27 @@ module ModelOutput {
787837
private import codeql.mad.ModelValidation as SharedModelVal
788838

789839
/**
790-
* Holds if a CSV source model contributed `source` with the given `kind`.
840+
* Holds if an external model contributed `source` with the given `kind`.
791841
*/
792842
API::Node getASourceNode(string kind) { result = getASourceNode(kind, _) }
793843

794844
/**
795-
* Holds if a CSV sink model contributed `sink` with the given `kind`.
845+
* Holds if an external model contributed `sink` with the given `kind`.
796846
*/
797847
API::Node getASinkNode(string kind) { result = getASinkNode(kind, _) }
798848

849+
/**
850+
* Holds if an external model contributed `barrier` with the given `kind`.
851+
*/
852+
API::Node getABarrierNode(string kind) { result = getABarrierNode(kind, _) }
853+
854+
/**
855+
* Holds if an external model contributed `barrier-guard` with the given `kind` and `branch`.
856+
*/
857+
API::Node getABarrierGuardNode(string kind, boolean branch) {
858+
result = getABarrierGuardNode(kind, branch, _)
859+
}
860+
799861
private module KindValConfig implements SharedModelVal::KindValidationConfigSig {
800862
predicate summaryKind(string kind) { summaryModel(_, _, _, _, kind, _) }
801863

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ extensible predicate sourceModel(
2020
*/
2121
extensible predicate sinkModel(string type, string path, string kind, QlBuiltins::ExtensionId madId);
2222

23+
/**
24+
* Holds if the value at `(type, path)` should be seen as a barrier
25+
* of the given `kind` and `madId` is the data extension row number.
26+
*/
27+
extensible predicate barrierModel(
28+
string type, string path, string kind, QlBuiltins::ExtensionId madId
29+
);
30+
31+
/**
32+
* Holds if the value at `(type, path)` should be seen as a barrier guard
33+
* of the given `kind` and `madId` is the data extension row number.
34+
* `path` is assumed to lead to a parameter of a call (possibly `self`), and
35+
* the call is guarding the parameter.
36+
* `branch` is either `true` or `false`, indicating which branch of the guard
37+
* is protecting the parameter.
38+
*/
39+
extensible predicate barrierGuardModel(
40+
string type, string path, string branch, string kind, QlBuiltins::ExtensionId madId
41+
);
42+
2343
/**
2444
* Holds if in calls to `(type, path)`, the value referred to by `input`
2545
* can flow to the value referred to by `output` and `madId` is the data

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,26 @@ private predicate sinkModel(string type, string path, string kind, string model)
344344
)
345345
}
346346

347+
/** Holds if a barrier model exists for the given parameters. */
348+
private predicate barrierModel(string type, string path, string kind, string model) {
349+
// No deprecation adapter for barrier models, they were not around back then.
350+
exists(QlBuiltins::ExtensionId madId |
351+
Extensions::barrierModel(type, path, kind, madId) and
352+
model = "MaD:" + madId.toString()
353+
)
354+
}
355+
356+
/** Holds if a barrier guard model exists for the given parameters. */
357+
private predicate barrierGuardModel(
358+
string type, string path, string branch, string kind, string model
359+
) {
360+
// No deprecation adapter for barrier models, they were not around back then.
361+
exists(QlBuiltins::ExtensionId madId |
362+
Extensions::barrierGuardModel(type, path, branch, kind, madId) and
363+
model = "MaD:" + madId.toString()
364+
)
365+
}
366+
347367
/** Holds if a summary model `row` exists for the given parameters. */
348368
private predicate summaryModel(
349369
string type, string path, string input, string output, string kind, string model
@@ -400,6 +420,8 @@ predicate isRelevantType(string type) {
400420
(
401421
sourceModel(type, _, _, _) or
402422
sinkModel(type, _, _, _) or
423+
barrierModel(type, _, _, _) or
424+
barrierGuardModel(type, _, _, _, _) or
403425
summaryModel(type, _, _, _, _, _) or
404426
typeModel(_, type, _)
405427
) and
@@ -427,6 +449,8 @@ predicate isRelevantFullPath(string type, string path) {
427449
(
428450
sourceModel(type, path, _, _) or
429451
sinkModel(type, path, _, _) or
452+
barrierModel(type, path, _, _) or
453+
barrierGuardModel(type, path, _, _, _) or
430454
summaryModel(type, path, _, _, _, _) or
431455
typeModel(_, type, path)
432456
)
@@ -745,6 +769,32 @@ module ModelOutput {
745769
)
746770
}
747771

772+
/**
773+
* Holds if a barrier model contributed `barrier` with the given `kind`.
774+
*/
775+
cached
776+
API::Node getABarrierNode(string kind, string model) {
777+
exists(string type, string path |
778+
barrierModel(type, path, kind, model) and
779+
result = getNodeFromPath(type, path)
780+
)
781+
}
782+
783+
/**
784+
* Holds if a barrier model contributed `barrier` with the given `kind`.
785+
*/
786+
cached
787+
API::Node getABarrierGuardNode(string kind, boolean branch, string model) {
788+
exists(string type, string path, string branch_str |
789+
branch = true and branch_str = "true"
790+
or
791+
branch = false and branch_str = "false"
792+
|
793+
barrierGuardModel(type, path, branch_str, kind, model) and
794+
result = getNodeFromPath(type, path)
795+
)
796+
}
797+
748798
/**
749799
* Holds if a relevant summary exists for these parameters.
750800
*/
@@ -787,15 +837,27 @@ module ModelOutput {
787837
private import codeql.mad.ModelValidation as SharedModelVal
788838

789839
/**
790-
* Holds if a CSV source model contributed `source` with the given `kind`.
840+
* Holds if an external model contributed `source` with the given `kind`.
791841
*/
792842
API::Node getASourceNode(string kind) { result = getASourceNode(kind, _) }
793843

794844
/**
795-
* Holds if a CSV sink model contributed `sink` with the given `kind`.
845+
* Holds if an external model contributed `sink` with the given `kind`.
796846
*/
797847
API::Node getASinkNode(string kind) { result = getASinkNode(kind, _) }
798848

849+
/**
850+
* Holds if an external model contributed `barrier` with the given `kind`.
851+
*/
852+
API::Node getABarrierNode(string kind) { result = getABarrierNode(kind, _) }
853+
854+
/**
855+
* Holds if an external model contributed `barrier-guard` with the given `kind` and `branch`.
856+
*/
857+
API::Node getABarrierGuardNode(string kind, boolean branch) {
858+
result = getABarrierGuardNode(kind, branch, _)
859+
}
860+
799861
private module KindValConfig implements SharedModelVal::KindValidationConfigSig {
800862
predicate summaryKind(string kind) { summaryModel(_, _, _, _, kind, _) }
801863

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModelsExtensions.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ extensible predicate sourceModel(
2020
*/
2121
extensible predicate sinkModel(string type, string path, string kind, QlBuiltins::ExtensionId madId);
2222

23+
/**
24+
* Holds if the value at `(type, path)` should be seen as a barrier
25+
* of the given `kind` and `madId` is the data extension row number.
26+
*/
27+
extensible predicate barrierModel(
28+
string type, string path, string kind, QlBuiltins::ExtensionId madId
29+
);
30+
31+
/**
32+
* Holds if the value at `(type, path)` should be seen as a barrier guard
33+
* of the given `kind` and `madId` is the data extension row number.
34+
* `path` is assumed to lead to a parameter of a call (possibly `self`), and
35+
* the call is guarding the parameter.
36+
* `branch` is either `true` or `false`, indicating which branch of the guard
37+
* is protecting the parameter.
38+
*/
39+
extensible predicate barrierGuardModel(
40+
string type, string path, string branch, string kind, QlBuiltins::ExtensionId madId
41+
);
42+
2343
/**
2444
* Holds if in calls to `(type, path)`, the value referred to by `input`
2545
* can flow to the value referred to by `output` and `madId` is the data

0 commit comments

Comments
 (0)