Use getLocation instead of hasLocationInfo

This commit is contained in:
Owen Mansel-Chan
2025-02-27 11:51:56 +00:00
parent ca0b363be3
commit f322cb7968
101 changed files with 413 additions and 654 deletions

View File

@@ -19,20 +19,10 @@ private class Diagnostic extends @diagnostic {
string getMessage() { diagnostics(this, _, _, result, _, _) }
/** Gets the file that this error is associated with, if any. */
File getFile() { this.hasLocationInfo(result.getAbsolutePath(), _, _, _, _) }
File getFile() { result = this.getLocation().getFile() }
/**
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
exists(Location loc | diagnostics(this, _, _, _, _, loc) |
loc.hasLocationInfo(path, sl, sc, el, ec)
)
}
/** Gets the location for this error. */
Location getLocation() { diagnostics(this, _, _, _, _, result) }
string toString() { result = this.getMessage() }
}
@@ -69,7 +59,7 @@ predicate reportableDiagnostics(Diagnostic d, string msg, int sev) {
exists(File f | f = d.getFile() |
exists(f.getAChild()) and
msg =
"Extraction failed in " + d.getFile().getRelativePath() + " with error " +
"Extraction failed in " + f.getRelativePath() + " with error " +
removeAbsolutePaths(d.getMessage())
)
or

View File

@@ -144,36 +144,34 @@ class Entity extends @object {
/** Gets a textual representation of this entity. */
string toString() { result = this.getName() }
private predicate hasRealLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
// take the location of the declaration if there is one
this.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) or
any(CaseClause cc | this = cc.getImplicitlyDeclaredVariable())
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
/** Gets the location of this entity. */
Location getLocation() {
result = this.getDeclaration().getLocation()
or
result = any(CaseClause cc | this = cc.getImplicitlyDeclaredVariable()).getLocation()
}
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
// take the location of the declaration if there is one
if this.hasRealLocationInfo(_, _, _, _, _)
then this.hasRealLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
else (
// otherwise fall back on dummy location
filepath = "" and
startline = 0 and
startcolumn = 0 and
endline = 0 and
endcolumn = 0
)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
// otherwise fall back on dummy location
not exists(this.getLocation()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and
endline = 0 and
endcolumn = 0
}
}
@@ -680,16 +678,22 @@ class Callable extends TCallable {
result = this.asFuncLit().getName()
}
/** Gets the location of this callable. */
Location getLocation() {
result = this.asFunction().getLocation() or result = this.asFuncLit().getLocation()
}
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `sc` of line `sl` to
* column `ec` of line `el` in file `fp`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(string fp, int sl, int sc, int el, int ec) {
this.asFunction().hasLocationInfo(fp, sl, sc, el, ec) or
this.asFuncLit().hasLocationInfo(fp, sl, sc, el, ec)
deprecated predicate hasLocationInfo(string fp, int sl, int sc, int el, int ec) {
this.getLocation().hasLocationInfo(fp, sl, sc, el, ec)
}
}

View File

@@ -548,20 +548,25 @@ module StringOps {
else result = "concatenation element"
}
/** Gets the location of this element. */
Location getLocation() { result = this.asNode().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.asNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
// use dummy location for elements that don't have a corresponding node
not exists(this.asNode()) and
not exists(this.getLocation()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and

View File

@@ -144,19 +144,24 @@ class Type extends @type {
*/
string toString() { result = this.getName() }
/** Gets the location of this type. */
Location getLocation() { result = this.getEntity().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getEntity().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
not exists(this.getEntity()) and
not exists(this.getLocation()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and

View File

@@ -183,16 +183,21 @@ class VariableWithFields extends TVariableWithFields {
*/
string getElement() { this = TVariableElementStep(_, result) }
/** Gets the location of this variable with fields. */
Location getLocation() { result = this.getBaseVariable().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getBaseVariable().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}

View File

@@ -114,17 +114,22 @@ class BasicBlock extends TControlFlowNode {
/** Gets a textual representation of this basic block. */
string toString() { result = "basic block" }
/** Gets the source location for this element. */
Location getLocation() { result = this.getFirstNode().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this basic block is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getFirstNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}

View File

@@ -77,23 +77,31 @@ module ControlFlow {
Root getRoot() { none() }
/** Gets the file to which this node belongs. */
File getFile() { this.hasLocationInfo(result.getAbsolutePath(), _, _, _, _) }
File getFile() { result = this.getLocation().getFile() }
/**
* Gets a textual representation of this control flow node.
*/
string toString() { result = "control-flow node" }
/** Gets the source location for this element. */
Location getLocation() { none() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
not exists(this.getLocation()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and
@@ -244,11 +252,7 @@ module ControlFlow {
override string toString() { result = cond + " is " + outcome }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
cond.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = cond.getLocation() }
}
/**

View File

@@ -418,11 +418,7 @@ class SkipNode extends ControlFlow::Node, MkSkipNode {
override string toString() { result = "skip" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
skip.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = skip.getLocation() }
}
/**
@@ -437,11 +433,7 @@ class EntryNode extends ControlFlow::Node, MkEntryNode {
override string toString() { result = "entry" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
root.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = root.getLocation() }
}
/**
@@ -456,11 +448,7 @@ class ExitNode extends ControlFlow::Node, MkExitNode {
override string toString() { result = "exit" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
root.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = root.getLocation() }
}
/**

View File

@@ -218,11 +218,7 @@ module IR {
override string toString() { result = e.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = e.getLocation() }
}
/**
@@ -364,11 +360,7 @@ module IR {
override string toString() { result = "implicit read of field " + field.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
e.getBase().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = e.getBase().getLocation() }
}
/**
@@ -483,11 +475,7 @@ module IR {
override string toString() { result = "init of " + elt }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
elt.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = elt.getLocation() }
}
/**
@@ -644,11 +632,7 @@ module IR {
override string toString() { result = "element index" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
elt.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = elt.getLocation() }
}
/**
@@ -682,11 +666,7 @@ module IR {
override string toString() { result = "assignment to " + this.getLhs() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getLhs().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = this.getLhs().getLocation() }
}
/** An instruction computing the value of the right-hand side of a compound assignment. */
@@ -704,11 +684,7 @@ module IR {
override string toString() { result = assgn.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
assgn.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = assgn.getLocation() }
}
/**
@@ -792,11 +768,7 @@ module IR {
override string toString() { result = s + "[" + i + "]" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
s.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = s.getLocation() }
}
/**
@@ -840,11 +812,7 @@ module IR {
override string toString() { result = "zero value for " + v }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
v.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = v.getDeclaration().getLocation() }
}
/**
@@ -859,11 +827,7 @@ module IR {
override string toString() { result = fd.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
fd.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = fd.getLocation() }
}
/**
@@ -878,11 +842,7 @@ module IR {
override string toString() { result = defer.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
defer.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = defer.getLocation() }
}
/**
@@ -897,11 +857,7 @@ module IR {
override string toString() { result = go.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
go.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = go.getLocation() }
}
/**
@@ -918,11 +874,7 @@ module IR {
override string toString() { result = ids.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
ids.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = ids.getLocation() }
}
/**
@@ -943,11 +895,7 @@ module IR {
override string toString() { result = "rhs of " + ids }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
ids.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = ids.getLocation() }
}
/**
@@ -975,11 +923,7 @@ module IR {
override string toString() { result = "1" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
ids.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = ids.getLocation() }
}
/**
@@ -1014,11 +958,7 @@ module IR {
override string toString() { result = ret.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
ret.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = ret.getLocation() }
}
/**
@@ -1048,11 +988,7 @@ module IR {
override string toString() { result = "implicit write of " + var }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
ret.getResult(i).hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = ret.getResult(i).getLocation() }
}
/**
@@ -1072,11 +1008,7 @@ module IR {
override string toString() { result = "implicit read of " + var }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
var.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = var.getDeclaration().getLocation() }
}
/**
@@ -1091,11 +1023,7 @@ module IR {
override string toString() { result = sel.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
sel.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = sel.getLocation() }
}
/**
@@ -1110,11 +1038,7 @@ module IR {
override string toString() { result = send.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
send.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = send.getLocation() }
}
/**
@@ -1131,11 +1055,7 @@ module IR {
override string toString() { result = "initialization of " + parm }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
parm.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = parm.getDeclaration().getLocation() }
}
/**
@@ -1152,11 +1072,7 @@ module IR {
override string toString() { result = "argument corresponding to " + parm }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
parm.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = parm.getDeclaration().getLocation() }
}
/**
@@ -1173,11 +1089,7 @@ module IR {
override string toString() { result = "initialization of " + res }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
res.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = res.getDeclaration().getLocation() }
}
/**
@@ -1197,11 +1109,7 @@ module IR {
override string toString() { result = "next key-value pair in range" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
rs.getDomain().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = rs.getDomain().getLocation() }
}
/**
@@ -1226,11 +1134,7 @@ module IR {
override string toString() { result = "true" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
stmt.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = stmt.getLocation() }
}
/**
@@ -1259,11 +1163,7 @@ module IR {
override string toString() { result = "case " + cc.getExpr(i) }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
cc.getExpr(i).hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = cc.getExpr(i).getLocation() }
}
/**
@@ -1305,11 +1205,7 @@ module IR {
override string toString() { result = "implicit type switch variable declaration" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
cc.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = cc.getLocation() }
}
/**
@@ -1335,11 +1231,7 @@ module IR {
override string toString() { result = "0" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
slice.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = slice.getLocation() }
}
/**
@@ -1357,11 +1249,7 @@ module IR {
override string toString() { result = "len" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
slice.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = slice.getLocation() }
}
/**
@@ -1379,11 +1267,7 @@ module IR {
override string toString() { result = "cap" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
slice.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = slice.getLocation() }
}
/**
@@ -1406,11 +1290,7 @@ module IR {
override string toString() { result = "implicit dereference" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = e.getLocation() }
}
/** A representation of the target of a write instruction. */
@@ -1438,17 +1318,29 @@ module IR {
/** Gets a textual representation of this target. */
string toString() { result = "write target" }
/** Gets the source location for this element. */
Location getLocation() { none() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
filepath = "" and startline = 0 and startcolumn = 0 and endline = 0 and endcolumn = 0
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
not exists(this.getLocation()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and
endline = 0 and
endcolumn = 0
}
}
@@ -1501,11 +1393,7 @@ module IR {
override string toString() { result = this.getName() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
loc.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = loc.getLocation() }
}
/** A reference to a field, used as the target of a write. */
@@ -1545,14 +1433,10 @@ module IR {
result = "field " + w.(InitLiteralStructFieldInstruction).getFieldName()
}
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
exists(SelectorExpr sel | this = MkLhs(_, sel) |
sel.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
override Location getLocation() {
exists(SelectorExpr sel | this = MkLhs(_, sel) | result = sel.getLocation())
or
w.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
result = w.(InitLiteralStructFieldInstruction).getLocation()
}
}
@@ -1582,14 +1466,10 @@ module IR {
override string toString() { result = "element" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
exists(IndexExpr idx | this = MkLhs(_, idx) |
idx.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
override Location getLocation() {
exists(IndexExpr idx | this = MkLhs(_, idx) | result = idx.getLocation())
or
w.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
result = w.(InitLiteralElementInstruction).getLocation()
}
}
@@ -1613,11 +1493,7 @@ module IR {
override string toString() { result = lhs.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
lhs.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = lhs.getLocation() }
}
/**

View File

@@ -300,7 +300,9 @@ class GVN extends GvnBase {
// just an arbitrary way to pick an expression with this `GVN`.
result =
min(DataFlow::Node e, string f, int l, int c, string k |
e = this.getANode() and e.hasLocationInfo(f, l, c, _, _) and k = e.getNodeKind()
e = this.getANode() and
e.getLocation().hasLocationInfo(f, l, c, _, _) and
k = e.getNodeKind()
|
e order by f, l, c, k
)
@@ -309,17 +311,22 @@ class GVN extends GvnBase {
/** Gets a textual representation of this element. */
string toString() { result = this.exampleNode().toString() }
/** Gets the location of this element. */
Location getLocation() { result = this.exampleNode().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.exampleNode().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}

View File

@@ -85,17 +85,22 @@ class SsaVariable extends TSsaDefinition {
/** Gets a textual representation of this element. */
string toString() { result = this.getDefinition().prettyPrintRef() }
/** Gets the location of this SSA variable. */
Location getLocation() { result = this.getDefinition().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getDefinition().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}
@@ -144,16 +149,23 @@ class SsaDefinition extends TSsaDefinition {
/** Gets a textual representation of this element. */
string toString() { result = this.prettyPrintDef() }
/** Gets the source location for this element. */
abstract Location getLocation();
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
abstract predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
);
) {
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}
/**
@@ -177,16 +189,14 @@ class SsaExplicitDefinition extends SsaDefinition, TExplicitDef {
override SsaSourceVariable getSourceVariable() { this = TExplicitDef(_, _, result) }
override string prettyPrintRef() {
exists(int l, int c | this.hasLocationInfo(_, l, c, _, _) | result = "def@" + l + ":" + c)
exists(Location loc | loc = this.getLocation() |
result = "def@" + loc.getStartLine() + ":" + loc.getStartColumn()
)
}
override string prettyPrintDef() { result = "definition of " + this.getSourceVariable() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getInstruction().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = this.getInstruction().getLocation() }
}
/** Provides a helper predicate for working with explicit SSA definitions. */
@@ -209,16 +219,12 @@ abstract class SsaImplicitDefinition extends SsaDefinition {
abstract string getKind();
override string prettyPrintRef() {
exists(int l, int c | this.hasLocationInfo(_, l, c, _, _) |
result = this.getKind() + "@" + l + ":" + c
exists(Location loc | loc = this.getLocation() |
result = this.getKind() + "@" + loc.getStartLine() + ":" + loc.getStartColumn()
)
}
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getBasicBlock().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = this.getBasicBlock().getLocation() }
}
/**
@@ -241,11 +247,9 @@ class SsaVariableCapture extends SsaImplicitDefinition, TCapture {
override string prettyPrintDef() { result = "capture variable " + this.getSourceVariable() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
override Location getLocation() {
exists(ReachableBasicBlock bb, int i | this.definesAt(bb, i, _) |
bb.getNode(i).hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
result = bb.getNode(i).getLocation()
)
}
}
@@ -291,11 +295,7 @@ class SsaPhiNode extends SsaPseudoDefinition, TPhi {
result = this.getSourceVariable() + " = phi(" + this.ppInputs() + ")"
}
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getBasicBlock().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = this.getBasicBlock().getLocation() }
}
/**
@@ -383,17 +383,22 @@ class SsaWithFields extends TSsaWithFields {
)
}
/** Gets the location of this SSA variable with fields. */
Location getLocation() { result = this.getBaseVariable().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.getBaseVariable().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}

View File

@@ -78,9 +78,7 @@ module Private {
result = this.getSummaryNode().getSummarizedCallable()
}
override predicate hasLocationInfo(string fp, int sl, int sc, int el, int ec) {
this.getSummarizedCallable().hasLocationInfo(fp, sl, sc, el, ec)
}
override Location getLocation() { result = this.getSummarizedCallable().getLocation() }
override string toString() { result = this.getSummaryNode().toString() }
@@ -140,45 +138,38 @@ module Public {
/** Gets a textual representation of this element. */
string toString() { result = "data-flow node" } // overridden in subclasses
/** Gets the location of this node. */
Location getLocation() { none() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
filepath = "" and
startline = 0 and
startcolumn = 0 and
endline = 0 and
endcolumn = 0
}
/** Gets the location of this node. */
Location getLocation() {
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
this.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
result.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
/** Gets the file in which this node appears. */
File getFile() { this.hasLocationInfo(result.getAbsolutePath(), _, _, _, _) }
File getFile() { result = this.getLocation().getFile() }
/** Gets the start line of the location of this node. */
int getStartLine() { this.hasLocationInfo(_, result, _, _, _) }
int getStartLine() { result = this.getLocation().getStartLine() }
/** Gets the start column of the location of this node. */
int getStartColumn() { this.hasLocationInfo(_, _, result, _, _) }
int getStartColumn() { result = this.getLocation().getStartColumn() }
/** Gets the end line of the location of this node. */
int getEndLine() { this.hasLocationInfo(_, _, _, result, _) }
int getEndLine() { result = this.getLocation().getEndLine() }
/** Gets the end column of the location of this node. */
int getEndColumn() { this.hasLocationInfo(_, _, _, _, result) }
int getEndColumn() { result = this.getLocation().getEndColumn() }
/**
* Gets an upper bound on the type of this node.
@@ -262,11 +253,7 @@ module Public {
override string toString() { result = insn.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
insn.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = insn.getLocation() }
}
/**
@@ -312,11 +299,7 @@ module Public {
override string toString() { result = ssa.toString() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
ssa.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = ssa.getLocation() }
}
private module FunctionNode {
@@ -408,11 +391,7 @@ module Public {
override string toString() { result = "function " + func.getName() }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
func.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = func.getLocation() }
override ResultNode getAResult() {
result.getRoot() = this.getFunction().(DeclaredFunction).getFuncDecl()
@@ -464,11 +443,7 @@ module Public {
override string toString() { result = "[]type{args}" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
call.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = call.getLocation() }
}
/**
@@ -1077,11 +1052,7 @@ module Public {
override string toString() { result = "slice element node" }
override predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
si.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
override Location getLocation() { result = si.getLocation() }
/** Gets the `SliceNode` which this node relates to. */
SliceNode getSliceNode() { result = DataFlow::instructionNode(si) }

View File

@@ -301,35 +301,27 @@ class DataFlowCallable extends TDataFlowCallable {
result = "Summary: " + this.asSummarizedCallable().toString()
}
/** Gets the location of this callable. */
Location getLocation() {
result = this.asCallable().getLocation() or
result = this.asFileScope().getLocation() or
result = this.asSummarizedCallable().getLocation()
}
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this callable is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.asCallable().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) or
this.asFileScope().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) or
this.asSummarizedCallable()
.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
/** Gets the location of this callable. */
Location getLocation() {
result = getCallableLocation(this.asCallable()) or
result = this.asFileScope().getLocation() or
result = getCallableLocation(this.asSummarizedCallable())
}
}
private Location getCallableLocation(Callable c) {
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
c.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
result.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
}
/** A function call relevant for data flow. */

View File

@@ -170,17 +170,29 @@ class Content extends TContent {
/** Gets a textual representation of this element. */
abstract string toString();
/** Gets the location of this element. */
Location getLocation() { none() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
filepath = "" and startline = 0 and startcolumn = 0 and endline = 0 and endcolumn = 0
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
not exists(this.getLocation()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and
endline = 0 and
endcolumn = 0
}
/**
@@ -202,9 +214,7 @@ class FieldContent extends Content, TFieldContent {
override string toString() { result = f.toString() }
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
f.getDeclaration().hasLocationInfo(path, sl, sc, el, ec)
}
override Location getLocation() { result = f.getDeclaration().getLocation() }
}
/** A reference through the contents of some collection-like container. */
@@ -277,26 +287,31 @@ class ContentSet instanceof TContentSet {
/** Gets a textual representation of this content set. */
string toString() {
exists(Content c | this = TOneContent(c) | result = c.toString())
result = this.asOneContent().toString()
or
this = TAllContent() and result = "all content"
}
/**
* Gets the location of this content set, if it contains only one `Content`.
*/
Location getLocation() { result = this.asOneContent().getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
exists(Content c | this = TOneContent(c) |
c.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
or
this = TAllContent() and
not exists(this.getLocation()) and
filepath = "" and
startline = 0 and
startcolumn = 0 and

View File

@@ -222,16 +222,17 @@ module SourceSinkInterpretationInput implements
/** Gets the location of this element. */
Location getLocation() {
exists(string fp, int sl, int sc, int el, int ec |
this.hasLocationInfo(fp, sl, sc, el, ec) and
result.hasLocationInfo(fp, sl, sc, el, ec)
)
result = this.asEntity().getLocation() or
result = this.asAstNode().getLocation()
}
/** Holds if this element is at the specified location. */
predicate hasLocationInfo(string fp, int sl, int sc, int el, int ec) {
this.asEntity().hasLocationInfo(fp, sl, sc, el, ec) or
this.asAstNode().hasLocationInfo(fp, sl, sc, el, ec)
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
*/
deprecated predicate hasLocationInfo(string fp, int sl, int sc, int el, int ec) {
this.getLocation().hasLocationInfo(fp, sl, sc, el, ec)
}
}
@@ -280,17 +281,18 @@ module SourceSinkInterpretationInput implements
}
/** Gets the location of this node. */
predicate hasLocationInfo(string fp, int sl, int sc, int el, int ec) {
this.asElement().hasLocationInfo(fp, sl, sc, el, ec)
or
this.asNode().hasLocationInfo(fp, sl, sc, el, ec)
Location getLocation() {
result = this.asElement().getLocation() or
result = this.asNode().getLocation()
}
Location getLocation() {
exists(string fp, int sl, int sc, int el, int ec |
this.hasLocationInfo(fp, sl, sc, el, ec) and
result.hasLocationInfo(fp, sl, sc, el, ec)
)
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Gets the location of this node.
*/
deprecated predicate hasLocationInfo(string fp, int sl, int sc, int el, int ec) {
this.getLocation().hasLocationInfo(fp, sl, sc, el, ec)
}
}

View File

@@ -35,7 +35,7 @@ module GoMicro {
*/
class ProtocMessageType extends Type {
ProtocMessageType() {
this.hasLocationInfo(any(ProtocGeneratedFile f).getAbsolutePath(), _, _, _, _) and
this.getLocation().getFile() instanceof ProtocGeneratedFile and
exists(MethodDecl md |
md.getName() = "ProtoMessage" and
this = md.getReceiverDecl().getTypeExpr().getAChild().(TypeName).getType()
@@ -51,7 +51,7 @@ module GoMicro {
ServiceInterfaceType() {
this = definedType.getUnderlyingType() and
definedType.hasLocationInfo(any(ProtocGeneratedFile f).getAbsolutePath(), _, _, _, _)
definedType.getLocation().getFile() instanceof ProtocGeneratedFile
}
/**
@@ -75,7 +75,7 @@ module GoMicro {
ServiceServerType() {
this.implements(any(ServiceInterfaceType i)) and
this.getName().regexpMatch("(?i).*Handler") and
this.hasLocationInfo(any(ProtocGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ProtocGeneratedFile
}
}
@@ -86,7 +86,7 @@ module GoMicro {
ClientServiceType() {
this.implements(any(ServiceInterfaceType i)) and
this.getName().regexpMatch("(?i).*Service") and
this.hasLocationInfo(any(ProtocGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ProtocGeneratedFile
}
}
@@ -97,7 +97,7 @@ module GoMicro {
ServiceRegisterHandler() {
this.getName().regexpMatch("(?i)register" + any(ServiceServerType c).getName()) and
this.getParameterType(0) instanceof GoMicroServerType and
this.hasLocationInfo(any(ProtocGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ProtocGeneratedFile
}
}
@@ -128,7 +128,7 @@ module GoMicro {
this.getName().regexpMatch("(?i)new" + any(ClientServiceType c).getName()) and
this.getParameterType(0) instanceof StringType and
this.getParameterType(1) instanceof GoMicroClientType and
this.hasLocationInfo(any(ProtocGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ProtocGeneratedFile
}
}

View File

@@ -37,9 +37,7 @@ module Twirp {
/** A type representing a protobuf message. */
class ProtobufMessageType extends Type {
ProtobufMessageType() {
this.hasLocationInfo(any(ProtobufGeneratedFile f).getAbsolutePath(), _, _, _, _)
}
ProtobufMessageType() { this.getLocation().getFile() instanceof ProtobufGeneratedFile }
}
/** An interface type representing a Twirp service. */
@@ -48,7 +46,7 @@ module Twirp {
ServiceInterfaceType() {
definedType.getUnderlyingType() = this and
definedType.hasLocationInfo(any(ServicesGeneratedFile f).getAbsolutePath(), _, _, _, _)
definedType.getLocation().getFile() instanceof ServicesGeneratedFile
}
/** Gets the name of the interface. */
@@ -68,7 +66,7 @@ module Twirp {
p.implements(i) and
this = p.getBaseType() and
this.getName().regexpMatch("(?i)" + i.getName() + "(protobuf|json)client") and
this.hasLocationInfo(any(ServicesGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ServicesGeneratedFile
)
}
}
@@ -79,7 +77,7 @@ module Twirp {
exists(ServiceInterfaceType i |
this.implements(i) and
this.getName().regexpMatch("(?i)" + i.getName() + "server") and
this.hasLocationInfo(any(ServicesGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ServicesGeneratedFile
)
}
}
@@ -90,7 +88,7 @@ module Twirp {
this.getName().regexpMatch("(?i)new" + any(ServiceClientType c).getName()) and
this.getParameterType(0) instanceof StringType and
this.getParameterType(1).getName() = "HTTPClient" and
this.hasLocationInfo(any(ServicesGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ServicesGeneratedFile
}
}
@@ -103,7 +101,7 @@ module Twirp {
ServerConstructor() {
this.getName().regexpMatch("(?i)new" + any(ServiceServerType c).getName()) and
this.getParameterType(0) = any(ServiceInterfaceType i).getDefinedType() and
this.hasLocationInfo(any(ServicesGeneratedFile f).getAbsolutePath(), _, _, _, _)
this.getLocation().getFile() instanceof ServicesGeneratedFile
}
}

View File

@@ -66,7 +66,7 @@ module HtmlTemplate {
string getBody() { result = text.regexpCapture("(?s)\\{\\{(.*)\\}\\}", 1) } // matches the inside of the curly bracket delimiters
/** Gets the file in which this statement appears. */
File getFile() { this.hasLocationInfo(result.getAbsolutePath(), _, _, _, _) }
File getFile() { result = this.getLocation().getFile() }
/** Gets a textual representation of this statement. */
string toString() { result = "HTML template statement" }
@@ -74,17 +74,22 @@ module HtmlTemplate {
/** Get the HTML element that contains this template statement. */
HTML::TextNode getEnclosingTextNode() { result = parent }
/** Gets the location of this template statement. */
Location getLocation() { result = parent.getLocation() }
/**
* DEPRECATED: Use `getLocation()` instead.
*
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
deprecated predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
parent.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
}
@@ -114,7 +119,7 @@ module HtmlTemplate {
}
/** Gets the file in which this read appears. */
File getFile() { this.hasLocationInfo(result.getAbsolutePath(), _, _, _, _) }
File getFile() { result = this.getLocation().getFile() }
/** Gets a textual representation of this statement. */
string toString() { result = "HTML template read of " + text }
@@ -122,17 +127,21 @@ module HtmlTemplate {
/** Get the HTML element that contains this template read. */
HTML::TextNode getEnclosingTextNode() { result = parent.getEnclosingTextNode() }
/**
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
* column `endcolumn` of line `endline` in file `filepath`.
* For more information, see
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
parent.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
/** Gets the location of this template statement. */
Location getLocation() { result = parent.getLocation() }
// /**
// * DEPRECATED: Use `getLocation()` instead.
// *
// * Holds if this element is at the specified location.
// * The location spans column `startcolumn` of line `startline` to
// * column `endcolumn` of line `endline` in file `filepath`.
// * For more information, see
// * [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
// */
// predicate hasLocationInfo(
// string filepath, int startline, int startcolumn, int endline, int endcolumn
// ) {
// this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
// }
}
}

View File

@@ -72,11 +72,14 @@ predicate interestingNesting(BinaryExpr inner, BinaryExpr outer) {
/** Gets the number of whitespace characters around the operator `op` of `be`. */
int getWhitespaceAroundOperator(BinaryExpr be, string op) {
exists(string file, int line, int left, int right |
be.getLeftOperand().hasLocationInfo(file, _, _, line, left) and
be.getRightOperand().hasLocationInfo(file, line, right, _, _) and
exists(Location left, Location right |
be.getLeftOperand().getLocation() = left and
be.getRightOperand().getLocation() = right and
left.getFile() = right.getFile() and
left.getStartLine() = right.getStartLine()
|
op = be.getOperator() and
result = (right - left - op.length() - 1) / 2
result = (right.getStartColumn() - left.getEndColumn() - op.length() - 1) / 2
)
}

View File

@@ -10,8 +10,7 @@ module TestDecompressionBombs implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasValueFlow" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = "\"" + sink.toString() + "\""
)

View File

@@ -8,8 +8,7 @@ module HttpHeaderWriteTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
// Dynamic key-value header:
exists(Http::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
hw.getLocation() = location and
(
element = hw.getName().toString() and
value = hw.getName().toString() and
@@ -23,8 +22,7 @@ module HttpHeaderWriteTest implements TestSig {
or
// Static key, dynamic value header:
exists(Http::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
hw.getLocation() = location and
(
element = hw.getHeaderName().toString() and
value = hw.getHeaderName() and
@@ -38,8 +36,7 @@ module HttpHeaderWriteTest implements TestSig {
or
// Static key, static value header:
exists(Http::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
hw.getLocation() = location and
(
element = hw.getHeaderName().toString() and
value = hw.getHeaderName() and

View File

@@ -8,8 +8,7 @@ module HttpRedirectTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "redirectUrl" and
exists(Http::Redirect rd |
rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
rd.getLocation() = location and
element = rd.getUrl().toString() and
value = rd.getUrl().toString()
)

View File

@@ -7,8 +7,7 @@ module HttpResponseBodyTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Http::ResponseBody rd |
rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
rd.getLocation() = location and
(
element = rd.getAContentType().toString() and
value = rd.getAContentType().toString() and

View File

@@ -14,8 +14,7 @@ module RemoteFlowSourceTest implements TestSig {
|
element = arg.toString() and
value = "" and
arg.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn())
arg.getLocation() = location
)
}
}

View File

@@ -8,8 +8,7 @@ module HttpHeaderWriteTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
// Dynamic key-value header:
exists(Http::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
hw.getLocation() = location and
(
element = hw.getName().toString() and
value = hw.getName().toString() and
@@ -23,8 +22,7 @@ module HttpHeaderWriteTest implements TestSig {
or
// Static key, dynamic value header:
exists(Http::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
hw.getLocation() = location and
(
element = hw.getHeaderName().toString() and
value = hw.getHeaderName() and
@@ -38,8 +36,7 @@ module HttpHeaderWriteTest implements TestSig {
or
// Static key, static value header:
exists(Http::HeaderWrite hw |
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
hw.getLocation() = location and
(
element = hw.getHeaderName().toString() and
value = hw.getHeaderName() and

View File

@@ -8,8 +8,7 @@ module HttpRedirectTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "redirectUrl" and
exists(Http::Redirect rd |
rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
rd.getLocation() = location and
element = rd.getUrl().toString() and
value = rd.getUrl().toString()
)

View File

@@ -14,8 +14,7 @@ module RemoteFlowSourceTest implements TestSig {
|
element = arg.toString() and
value = "" and
arg.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn())
arg.getLocation() = location
)
}
}

View File

@@ -7,8 +7,7 @@ module HttpResponseBodyTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(Http::ResponseBody rd |
rd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
rd.getLocation() = location and
(
element = rd.getAContentType().toString() and
value = rd.getAContentType().toString() and

View File

@@ -1,7 +1,7 @@
import go
query predicate numberOfTypeParameters(TypeParamParentEntity parent, int n) {
exists(string file | file != "" | parent.hasLocationInfo(file, _, _, _, _)) and
exists(parent.getLocation().getFile()) and
n = strictcount(TypeParamType tpt | tpt.getParent() = parent)
}

View File

@@ -7,8 +7,7 @@ module FunctionIsVariadicTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(CallExpr ce |
ce.getTarget().isVariadic() and
ce.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
ce.getLocation() = location and
element = ce.toString() and
value = "" and
tag = "isVariadic"

View File

@@ -5,9 +5,9 @@ import go
* that contains the substring "`kind`,`dep`,`ver`".
*/
predicate metadata(Locatable l, string kind, string mod, string dep, string ver) {
exists(string f, int line, Comment c, string text |
l.hasLocationInfo(f, line, _, _, _) and
c.hasLocationInfo(f, line, _, _, _)
exists(Comment c, string text |
l.getFile() = c.getFile() and
l.getLocation().getStartLine() = c.getLocation().getStartLine()
|
text = c.getText().regexpFind("\\b([^,\\s]+,[^,]+,[^,]+,[^,\\s]+)", _, _) and
kind = text.regexpCapture("([^,]+),([^,]+),([^,]+),([^,]+)", 1) and
@@ -19,27 +19,27 @@ predicate metadata(Locatable l, string kind, string mod, string dep, string ver)
query predicate missingRequire(string mod, string dep, string ver, int line) {
exists(Locatable l | metadata(l, "RequireLine", mod, dep, ver) |
l.hasLocationInfo(_, line, _, _, _)
line = l.getLocation().getStartLine()
) and
not exists(GoModRequireLine req |
req.getModulePath() = mod and
req.getPath() = dep and
req.getVersion() = ver and
metadata(req, "RequireLine", mod, dep, ver) and
req.hasLocationInfo(_, line, _, _, _)
line = req.getLocation().getStartLine()
)
}
query predicate missingExclude(string mod, string dep, string ver, int line) {
exists(Locatable l | metadata(l, "ExcludeLine", mod, dep, ver) |
l.hasLocationInfo(_, line, _, _, _)
line = l.getLocation().getStartLine()
) and
not exists(GoModExcludeLine exc |
exc.getModulePath() = mod and
exc.getPath() = dep and
exc.getVersion() = ver and
metadata(exc, "ExcludeLine", mod, dep, ver) and
exc.hasLocationInfo(_, line, _, _, _)
line = exc.getLocation().getStartLine()
)
}
@@ -48,9 +48,9 @@ query predicate missingExclude(string mod, string dep, string ver, int line) {
* that contains the substring "ReplaceLine,`mod`,`dep`,`dver`,`rep`,`rver`".
*/
predicate repmetadata(Locatable l, string mod, string dep, string dver, string rep, string rver) {
exists(string f, int line, Comment c, string text |
l.hasLocationInfo(f, line, _, _, _) and
c.hasLocationInfo(f, line, _, _, _)
exists(Comment c, string text |
l.getFile() = c.getFile() and
l.getLocation().getStartLine() = c.getLocation().getStartLine()
|
text = c.getText().regexpFind("\\b(ReplaceLine,[^,]*,[^,]*,[^,]*,[^,]*,[^,\\s]*)", _, _) and
mod = text.regexpCapture("ReplaceLine,([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)", 1) and
@@ -65,7 +65,7 @@ query predicate missingReplace(
string mod, string dep, string dver, string rep, string rver, int line
) {
exists(Locatable l | repmetadata(l, mod, dep, dver, rep, rver) |
l.hasLocationInfo(_, line, _, _, _)
line = l.getLocation().getStartLine()
) and
not exists(GoModReplaceLine repl |
(
@@ -85,6 +85,6 @@ query predicate missingReplace(
repl.getOriginalPath() = dep and
repl.getReplacementPath() = rep and
repmetadata(repl, mod, dep, dver, rep, rver) and
repl.hasLocationInfo(_, line, _, _, _)
line = repl.getLocation().getStartLine()
)
}

View File

@@ -12,10 +12,9 @@ query predicate entities(string fp, Entity e, int c, Type ty) {
)
}
from string fp, FuncDecl decl, SignatureType sig
from FuncDecl decl, SignatureType sig
where
decl.hasLocationInfo(fp, _, _, _, _) and
decl.getFile().getAbsolutePath().matches("%aliases.go%") and
decl.getName() = ["F", "G", "H"] and
sig = decl.getType() and
fp.matches("%aliases.go%")
sig = decl.getType()
select decl.getName(), sig.pp()

View File

@@ -11,8 +11,7 @@ module ImplementsComparableTest implements TestSig {
ts.getName().matches("testComparable%") and
ts.getATypeParameterDecl().getTypeConstraint().implementsComparable()
|
ts.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
ts.getLocation() = location and
element = ts.getName() and
value = ""
)

View File

@@ -7,8 +7,7 @@ module SignatureTypeIsVariadicTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(FuncDef fd |
fd.isVariadic() and
fd.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
fd.getLocation() = location and
element = fd.toString() and
value = "" and
tag = "isVariadic"

View File

@@ -11,11 +11,7 @@ class EntityWithDeclInfo extends TEntityWithDeclInfo {
string toString() { result = e.toString() + " (" + nDecls + " declaration sites)" }
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
Location getLocation() { result = e.getLocation() }
}
query predicate distinctDefinedFs(int ct) { ct = count(DeclaredFunction e | e.toString() = "F") }

View File

@@ -11,11 +11,7 @@ class EntityWithDeclInfo extends TEntityWithDeclInfo {
result = e.toString() + " (" + count(e.getDeclaration()) + " declaration sites)"
}
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
Location getLocation() { result = e.getLocation() }
}
query predicate lowLevelDefs(Ident i, EntityWithDeclInfo ewrapped) {

View File

@@ -9,8 +9,7 @@ module HttpHandler implements TestSig {
exists(Http::RequestHandler h, DataFlow::Node check |
element = h.toString() and value = check.toString()
|
h.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
h.getLocation() = location and
h.guardedBy(check)
)
}

View File

@@ -8,8 +8,7 @@ module LoggerTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(LoggerCall log |
log.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
log.getLocation() = location and
element = log.toString() and
value = log.getAMessageComponent().toString() and
tag = "logger"

View File

@@ -5,9 +5,9 @@ import go
* that contains the substring `key: val`.
*/
string metadata(Locatable l, string key) {
exists(string f, int line, Comment c, string kv |
l.hasLocationInfo(f, line, _, _, _) and
c.hasLocationInfo(f, line, _, _, _) and
exists(Comment c, string kv |
l.getFile() = c.getFile() and
l.getLocation().getStartLine() = c.getLocation().getStartLine() and
kv = c.getText().regexpFind("\\b(\\w+: \\S+)", _, _) and
key = kv.regexpCapture("(\\w+): (\\S+)", 1) and
result = kv.regexpCapture("(\\w+): (\\S+)", 2)

View File

@@ -6,9 +6,9 @@ import semmle.go.dataflow.internal.DataFlowDispatch
* that contains the substring `key: val`.
*/
string metadata(Locatable l, string key) {
exists(string f, int line, Comment c, string kv |
l.hasLocationInfo(f, line, _, _, _) and
c.hasLocationInfo(f, line, _, _, _) and
exists(Comment c, string kv |
l.getFile() = c.getFile() and
l.getLocation().getStartLine() = c.getLocation().getStartLine() and
kv = c.getText().regexpFind("\\b(\\w+: \\S+)", _, _) and
key = kv.regexpCapture("(\\w+): (\\S+)", 1) and
result = kv.regexpCapture("(\\w+): (\\S+)", 2)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "I1[f]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "I1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "I2[f]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "I2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "IEmbedI1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "IEmbedI2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "PImplEmbedI1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "PImplEmbedI2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "S1[f]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "S1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedI1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedI2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedP1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedP2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedPtrP1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedPtrP2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedPtrS1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedPtrS2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedS1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SEmbedS2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SImplEmbedI1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SImplEmbedI2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SImplEmbedS1[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -17,8 +17,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "SImplEmbedS2[t]" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -27,8 +27,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "ql_I1" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -37,8 +37,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "ql_P1" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -37,8 +37,7 @@ module FlowTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "ql_S1" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = ""
)

View File

@@ -11,8 +11,7 @@ module PromotedMethodsTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(DataFlow::Node source, DataFlow::Node sink | ValueFlow::flow(source, sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString() and
value = source.getEnclosingCallable().getName() and
tag = "promotedmethods"

View File

@@ -7,8 +7,7 @@ module SourceTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ActiveThreatModelSource s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
s.getLocation() = location and
element = s.toString() and
value = "" and
tag = "source"

View File

@@ -7,8 +7,7 @@ module SourceTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ActiveThreatModelSource s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
s.getLocation() = location and
element = s.toString() and
value = "" and
tag = "source"

View File

@@ -7,8 +7,7 @@ module SourceTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ActiveThreatModelSource s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
s.getLocation() = location and
element = s.toString() and
value = "" and
tag = "source"

View File

@@ -7,8 +7,7 @@ module SourceTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ActiveThreatModelSource s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
s.getLocation() = location and
element = s.toString() and
value = "" and
tag = "source"

View File

@@ -7,8 +7,7 @@ module SourceTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(ActiveThreatModelSource s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
s.getLocation() = location and
element = s.toString() and
value = "" and
tag = "source"

View File

@@ -8,8 +8,7 @@ module FileSystemAccessTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(FileSystemAccess fsa |
fsa.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
fsa.getLocation() = location and
element = fsa.getAPathArgument().toString() and
value = fsa.getAPathArgument().toString() and
tag = "FileSystemAccess"
@@ -18,14 +17,12 @@ module FileSystemAccessTest implements TestSig {
exists(DataFlow::Node succ, DataFlow::Node pred |
any(Afero::AdditionalTaintStep adts).step(pred, succ)
|
succ.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
succ.getLocation() = location and
element = succ.toString() and
value = succ.asExpr().(StructLit).getType().getName() and
tag = "succ"
or
pred.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
pred.getLocation() = location and
element = pred.toString() and
value = pred.toString() and
tag = "pred"

View File

@@ -9,8 +9,7 @@ module SqlTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "query" and
exists(SQL::Query q, SQL::QueryString qs | qs = q.getAQueryString() |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = qs.toString()
)
@@ -24,8 +23,7 @@ module QueryString implements TestSig {
tag = "querystring" and
element = "" and
exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) |
qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
qs.getLocation() = location and
value = qs.toString()
)
}
@@ -48,9 +46,7 @@ module TaintFlow implements TestSig {
tag = "flowfrom" and
element = "" and
exists(DataFlow::Node fromNode, DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flow(fromNode, toNode) and
value = fromNode.asExpr().(StringLit).getValue()
)

View File

@@ -12,8 +12,7 @@ module SqlInjectionTest implements TestSig {
exists(DataFlow::Node sink | SqlInjection::Flow::flowTo(sink) |
element = sink.toString() and
value = sink.toString() and
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn())
sink.getLocation() = location
)
}
}

View File

@@ -10,8 +10,7 @@ module RemoteFlowSourceTest implements TestSig {
tag = "remoteflowsource" and
value = element and
exists(RemoteFlowSource src | value = "\"" + src.toString() + "\"" |
src.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn())
src.getLocation() = location
)
}
}
@@ -24,8 +23,7 @@ module HeaderWriteTest implements TestSig {
exists(Http::HeaderWrite hw, string name, string val | element = hw.toString() |
hw.definesHeader(name, val) and
value = name + ":" + val and
hw.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn())
hw.getLocation() = location
)
}
}
@@ -35,8 +33,7 @@ module LoggerTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(LoggerCall log |
log.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
log.getLocation() = location and
element = log.toString() and
value = log.getAMessageComponent().toString() and
tag = "logger"
@@ -64,9 +61,7 @@ module TaintFlow implements TestSig {
value = "" and
element = "" and
exists(DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flowTo(toNode)
)
}

View File

@@ -6,8 +6,7 @@ module FasthttpTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(EscapeFunction ef, DataFlow::CallNode cn | cn = ef.getACall() |
cn.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
cn.getLocation() = location and
element = cn.getArgument(1).toString() and
value = cn.getArgument(1).toString() and
tag = "Sanitizer"

View File

@@ -8,9 +8,7 @@ module FasthttpFileSystemAccessTest implements TestSig {
exists(FileSystemAccess fileSystemAccess, DataFlow::Node aPathArgument |
aPathArgument = fileSystemAccess.getAPathArgument()
|
aPathArgument
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
aPathArgument.getLocation() = location and
element = aPathArgument.toString() and
value = aPathArgument.toString() and
tag = "FileSystemAccess"

View File

@@ -7,8 +7,7 @@ module FasthttpTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(OpenUrlRedirect::Sink s |
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
s.getLocation() = location and
element = s.toString() and
value = s.toString() and
tag = "OpenRedirect"

View File

@@ -6,9 +6,7 @@ module FasthttpTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(RemoteFlowSource source |
source
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
source.getLocation() = location and
element = source.toString() and
value = "\"" + source.toString() + "\"" and
tag = "RemoteFlowSource"

View File

@@ -7,9 +7,7 @@ module FasthttpTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(RequestForgery::Sink ssrfSink |
ssrfSink
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
ssrfSink.getLocation() = location and
element = ssrfSink.toString() and
value = ssrfSink.toString() and
tag = "SsrfSink"

View File

@@ -6,9 +6,7 @@ module FasthttpTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(SharedXss::Sink xssSink |
xssSink
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
xssSink.getLocation() = location and
element = xssSink.toString() and
value = xssSink.toString() and
tag = "XssSink"

View File

@@ -8,8 +8,7 @@ module FileSystemAccessTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(FileSystemAccess fsa |
fsa.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
fsa.getLocation() = location and
element = fsa.getAPathArgument().toString() and
value = fsa.getAPathArgument().toString() and
tag = "FileSystemAccess"

View File

@@ -8,9 +8,7 @@ module RemoteFlowSourceTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(RemoteFlowSource source |
source
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
source.getLocation() = location and
element = source.toString() and
value = "\"" + source.toString() + "\"" and
tag = "source"

View File

@@ -8,8 +8,7 @@ module GoMicroTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(DataFlow::Node node |
node.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
node.getLocation() = location and
(
node instanceof GoMicro::Request and
element = node.toString() and

View File

@@ -8,8 +8,7 @@ module FileSystemAccessTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(FileSystemAccess fsa |
fsa.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
fsa.getLocation() = location and
element = fsa.getAPathArgument().toString() and
value = fsa.getAPathArgument().toString() and
tag = "FileSystemAccess"

View File

@@ -8,9 +8,7 @@ module K8sIoApimachineryPkgRuntimeTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(K8sIoClientGo::SecretInterfaceSource source |
source
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
source.getLocation() = location and
element = source.toString() and
value = "" and
tag = "KsIoClientGo"

View File

@@ -8,8 +8,7 @@ module RemoteFlowSourceTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(RemoteFlowSource src |
src.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
src.getLocation() = location and
element = src.toString() and
value = "" and
tag = "RemoteFlowSource"

View File

@@ -8,8 +8,7 @@ module NoSqlQueryTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(NoSql::Query q |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = q.toString() and
tag = "nosqlquery"

View File

@@ -23,8 +23,7 @@ module MissingDataFlowTest implements TestSig {
value = "" and
exists(Sink sink |
not TestFlow::flowTo(sink) and
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
sink.getLocation() = location and
element = sink.toString()
)
}
@@ -36,8 +35,7 @@ module HttpResponseBodyTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "responsebody" and
exists(Http::ResponseBody rb |
rb.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
rb.getLocation() = location and
element = rb.toString() and
value = "'" + rb.toString() + "'"
)

View File

@@ -9,8 +9,7 @@ module SqlTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "query" and
exists(SQL::Query q, SQL::QueryString qs | qs = q.getAQueryString() |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = qs.toString()
)
@@ -24,8 +23,7 @@ module QueryString implements TestSig {
tag = "querystring" and
element = "" and
exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) |
qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
qs.getLocation() = location and
value = qs.toString()
)
}
@@ -48,9 +46,7 @@ module TaintFlow implements TestSig {
tag = "flowfrom" and
element = "" and
exists(DataFlow::Node fromNode, DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flow(fromNode, toNode) and
value = fromNode.asExpr().(StringLit).getValue()
)

View File

@@ -9,8 +9,7 @@ module SqlTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "query" and
exists(SQL::Query q, SQL::QueryString qs | qs = q.getAQueryString() |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = qs.toString()
)
@@ -24,8 +23,7 @@ module QueryString implements TestSig {
tag = "querystring" and
element = "" and
exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) |
qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
qs.getLocation() = location and
value = qs.toString()
)
}
@@ -48,9 +46,7 @@ module TaintFlow implements TestSig {
tag = "flowfrom" and
element = "" and
exists(DataFlow::Node fromNode, DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flow(fromNode, toNode) and
value = fromNode.asExpr().(StringLit).getValue()
)

View File

@@ -9,8 +9,7 @@ module SqlTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "query" and
exists(SQL::Query q, SQL::QueryString qs | qs = q.getAQueryString() |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = qs.toString()
)
@@ -24,8 +23,7 @@ module QueryString implements TestSig {
tag = "querystring" and
element = "" and
exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) |
qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
qs.getLocation() = location and
value = qs.toString()
)
}
@@ -48,9 +46,7 @@ module TaintFlow implements TestSig {
tag = "flowfrom" and
element = "" and
exists(DataFlow::Node fromNode, DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flow(fromNode, toNode) and
value = fromNode.asExpr().(StringLit).getValue()
)

View File

@@ -9,8 +9,7 @@ module SqlTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "query" and
exists(SQL::Query q, SQL::QueryString qs | qs = q.getAQueryString() |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = qs.toString()
)
@@ -24,8 +23,7 @@ module QueryString implements TestSig {
tag = "querystring" and
element = "" and
exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) |
qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
qs.getLocation() = location and
value = qs.toString()
)
}
@@ -48,9 +46,7 @@ module TaintFlow implements TestSig {
tag = "flowfrom" and
element = "" and
exists(DataFlow::Node fromNode, DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flow(fromNode, toNode) and
value = fromNode.asExpr().(StringLit).getValue()
)

View File

@@ -9,8 +9,7 @@ module SqlTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "query" and
exists(SQL::Query q, SQL::QueryString qs | qs = q.getAQueryString() |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = qs.toString()
)
@@ -24,8 +23,7 @@ module QueryString implements TestSig {
tag = "querystring" and
element = "" and
exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) |
qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
qs.getLocation() = location and
value = qs.toString()
)
}
@@ -48,9 +46,7 @@ module TaintFlow implements TestSig {
tag = "flowfrom" and
element = "" and
exists(DataFlow::Node fromNode, DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flow(fromNode, toNode) and
value = fromNode.asExpr().(StringLit).getValue()
)

View File

@@ -9,8 +9,7 @@ module SqlTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "query" and
exists(SQL::Query q, SQL::QueryString qs | qs = q.getAQueryString() |
q.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
q.getLocation() = location and
element = q.toString() and
value = qs.toString()
)
@@ -24,8 +23,7 @@ module QueryString implements TestSig {
tag = "querystring" and
element = "" and
exists(SQL::QueryString qs | not exists(SQL::Query q | qs = q.getAQueryString()) |
qs.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
qs.getLocation() = location and
value = qs.toString()
)
}
@@ -48,9 +46,7 @@ module TaintFlow implements TestSig {
tag = "flowfrom" and
element = "" and
exists(DataFlow::Node fromNode, DataFlow::Node toNode |
toNode
.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
toNode.getLocation() = location and
Flow::flow(fromNode, toNode) and
value = fromNode.asExpr().(StringLit).getValue()
)

View File

@@ -8,8 +8,7 @@ module FileSystemAccessTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(FileSystemAccess f |
f.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
f.getLocation() = location and
element = f.toString() and
value = f.getAPathArgument().toString() and
tag = "fsaccess"

View File

@@ -39,8 +39,7 @@ module TaintFunctionModelTest implements TestSig {
tag = "ttfnmodelstep" and
(
exists(TaintTracking::FunctionModel model, DataFlow::CallNode call | call = model.getACall() |
call.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
call.getLocation() = location and
element = call.toString() and
value = "\"" + model.getAnInputNode(call) + " -> " + model.getAnOutputNode(call) + "\""
)
@@ -48,8 +47,7 @@ module TaintFunctionModelTest implements TestSig {
exists(DataFlow::Node arg, DataFlow::Node output |
TaintTransitsFunctionFlow::flow(arg, output) and
isSourceSinkPair(arg, output) and
arg.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
arg.getLocation() = location and
element = arg.toString() and
value = "\"" + arg + " -> " + output + "\""
)
@@ -63,8 +61,7 @@ module MarshalerTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "marshaler" and
exists(MarshalingFunction m, DataFlow::CallNode call | call = m.getACall() |
call.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
call.getLocation() = location and
element = call.toString() and
value =
"\"" + m.getFormat() + ": " + m.getAnInput().getNode(call) + " -> " +
@@ -79,8 +76,7 @@ module UnmarshalerTest implements TestSig {
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "unmarshaler" and
exists(UnmarshalingFunction m, DataFlow::CallNode call | call = m.getACall() |
call.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
call.getLocation() = location and
element = call.toString() and
value =
"\"" + m.getFormat() + ": " + m.getAnInput().getNode(call) + " -> " +

View File

@@ -11,8 +11,7 @@ module ResolveParameterTest implements TestSig {
exists(Gqlgen::ResolverParameter p |
element = p.toString() and
value = "\"" + p.toString() + "\"" and
p.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn())
p.getLocation() = location
)
}
}

Some files were not shown because too many files have changed in this diff Show More