Skip to content

Commit

Permalink
JS: Sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
aschackmull committed Feb 9, 2024
1 parent b5a7c3e commit db9b7b8
Showing 1 changed file with 47 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,41 +229,49 @@ private predicate typeModel(string row) { any(TypeModelCsv s).row(inversePad(row
private predicate typeVariableModel(string row) { any(TypeVariableModelCsv s).row(inversePad(row)) }

/** Holds if a source model exists for the given parameters. */
predicate sourceModel(string type, string path, string kind) {
predicate sourceModel(string type, string path, string kind, string model) {
exists(string row |
sourceModel(row) and
row.splitAt(";", 0) = type and
row.splitAt(";", 1) = path and
row.splitAt(";", 2) = kind
row.splitAt(";", 2) = kind and
model = "SourceModelCsv"
)
or
Extensions::sourceModel(type, path, kind)
Extensions::sourceModel(type, path, kind) and
model = "" // TODO: Insert MaD provenance from sourceModel
}

/** Holds if a sink model exists for the given parameters. */
private predicate sinkModel(string type, string path, string kind) {
private predicate sinkModel(string type, string path, string kind, string model) {
exists(string row |
sinkModel(row) and
row.splitAt(";", 0) = type and
row.splitAt(";", 1) = path and
row.splitAt(";", 2) = kind
row.splitAt(";", 2) = kind and
model = "SinkModelCsv"
)
or
Extensions::sinkModel(type, path, kind)
Extensions::sinkModel(type, path, kind) and
model = "" // TODO: Insert MaD provenance from sinkModel
}

/** Holds if a summary model `row` exists for the given parameters. */
private predicate summaryModel(string type, string path, string input, string output, string kind) {
private predicate summaryModel(
string type, string path, string input, string output, string kind, string model
) {
exists(string row |
summaryModel(row) and
row.splitAt(";", 0) = type and
row.splitAt(";", 1) = path and
row.splitAt(";", 2) = input and
row.splitAt(";", 3) = output and
row.splitAt(";", 4) = kind
row.splitAt(";", 4) = kind and
model = "SummaryModelCsv"
)
or
Extensions::summaryModel(type, path, input, output, kind)
Extensions::summaryModel(type, path, input, output, kind) and
model = "" // TODO: Insert MaD provenance from summaryModel
}

/** Holds if a type model exists for the given parameters. */
Expand Down Expand Up @@ -294,9 +302,9 @@ private predicate typeVariableModel(string name, string path) {
*/
predicate isRelevantType(string type) {
(
sourceModel(type, _, _) or
sinkModel(type, _, _) or
summaryModel(type, _, _, _, _) or
sourceModel(type, _, _, _) or
sinkModel(type, _, _, _) or
summaryModel(type, _, _, _, _, _) or
typeModel(_, type, _)
) and
(
Expand All @@ -319,9 +327,9 @@ pragma[nomagic]
predicate isRelevantFullPath(string type, string path) {
isRelevantType(type) and
(
sourceModel(type, path, _) or
sinkModel(type, path, _) or
summaryModel(type, path, _, _, _) or
sourceModel(type, path, _, _) or
sinkModel(type, path, _, _) or
summaryModel(type, path, _, _, _, _) or
typeModel(_, type, path)
)
}
Expand All @@ -331,8 +339,8 @@ private predicate accessPathRange(string s) {
isRelevantFullPath(_, s)
or
exists(string type | isRelevantType(type) |
summaryModel(type, _, s, _, _) or
summaryModel(type, _, _, s, _)
summaryModel(type, _, s, _, _, _) or
summaryModel(type, _, _, s, _, _)
)
or
typeVariableModel(_, s)
Expand Down Expand Up @@ -543,7 +551,7 @@ private API::Node getNodeFromPath(string type, AccessPath path) {

pragma[nomagic]
private predicate typeStepModel(string type, AccessPath basePath, AccessPath output) {
summaryModel(type, basePath, "", output, "type")
summaryModel(type, basePath, "", output, "type", _)
}

pragma[nomagic]
Expand Down Expand Up @@ -621,9 +629,9 @@ module ModelOutput {
* Holds if a CSV source model contributed `source` with the given `kind`.
*/
cached
API::Node getASourceNode(string kind) {
API::Node getASourceNode(string kind, string model) {
exists(string type, string path |
sourceModel(type, path, kind) and
sourceModel(type, path, kind, model) and
result = getNodeFromPath(type, path)
)
}
Expand All @@ -632,9 +640,9 @@ module ModelOutput {
* Holds if a CSV sink model contributed `sink` with the given `kind`.
*/
cached
API::Node getASinkNode(string kind) {
API::Node getASinkNode(string kind, string model) {
exists(string type, string path |
sinkModel(type, path, kind) and
sinkModel(type, path, kind, model) and
result = getNodeFromPath(type, path)
)
}
Expand All @@ -644,18 +652,18 @@ module ModelOutput {
*/
cached
predicate relevantSummaryModel(
string type, string path, string input, string output, string kind
string type, string path, string input, string output, string kind, string model
) {
isRelevantType(type) and
summaryModel(type, path, input, output, kind)
summaryModel(type, path, input, output, kind, model)
}

/**
* Holds if a `baseNode` is an invocation identified by the `type,path` part of a summary row.
*/
cached
predicate resolvedSummaryBase(string type, string path, Specific::InvokeNode baseNode) {
summaryModel(type, path, _, _, _) and
summaryModel(type, path, _, _, _, _) and
baseNode = getInvocationFromPath(type, path)
}

Expand All @@ -664,7 +672,7 @@ module ModelOutput {
*/
cached
predicate resolvedSummaryRefBase(string type, string path, API::Node baseNode) {
summaryModel(type, path, _, _, _) and
summaryModel(type, path, _, _, _, _) and
baseNode = getNodeFromPath(type, path)
}

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

/**
* Holds if a CSV source model contributed `source` with the given `kind`.
*/
API::Node getASourceNode(string kind) { result = getASourceNode(kind, _) }

/**
* Holds if a CSV sink model contributed `sink` with the given `kind`.
*/
API::Node getASinkNode(string kind) { result = getASinkNode(kind, _) }

private module KindValConfig implements SharedModelVal::KindValidationConfigSig {
predicate summaryKind(string kind) { summaryModel(_, _, _, _, kind) }
predicate summaryKind(string kind) { summaryModel(_, _, _, _, kind, _) }

predicate sinkKind(string kind) { sinkModel(_, _, kind) }
predicate sinkKind(string kind) { sinkModel(_, _, kind, _) }

predicate sourceKind(string kind) { sourceModel(_, _, kind) }
predicate sourceKind(string kind) { sourceModel(_, _, kind, _) }
}

private module KindVal = SharedModelVal::KindValidation<KindValConfig>;
Expand Down

0 comments on commit db9b7b8

Please sign in to comment.