Skip to content

Commit dbc1fa6

Browse files
author
Dave Bartolomeo
committed
Merge Actions queries from github/codeql-actions
2 parents 023f48f + ee7680d commit dbc1fa6

File tree

1,310 files changed

+38329
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,310 files changed

+38329
-4
lines changed

actions/ql/lib/actions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
predicate placeholder(int x) { x = 0 }
1+
import codeql.actions.Ast

actions/ql/lib/codeql-pack.lock.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
lockVersion: 1.0.0
3+
dependencies:
4+
codeql/controlflow:
5+
version: 1.0.12
6+
codeql/dataflow:
7+
version: 1.1.6
8+
codeql/javascript-all:
9+
version: 2.1.1
10+
codeql/mad:
11+
version: 1.0.12
12+
codeql/regex:
13+
version: 1.0.12
14+
codeql/ssa:
15+
version: 1.0.12
16+
codeql/threat-models:
17+
version: 1.0.12
18+
codeql/tutorial:
19+
version: 1.0.12
20+
codeql/typetracking:
21+
version: 1.0.12
22+
codeql/util:
23+
version: 1.0.12
24+
codeql/xml:
25+
version: 1.0.12
26+
codeql/yaml:
27+
version: 1.0.12
28+
compiled: false

actions/ql/lib/codeql/Locations.qll

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/** Provides classes for working with locations. */
2+
3+
import files.FileSystem
4+
import codeql.actions.ast.internal.Ast
5+
6+
bindingset[loc]
7+
pragma[inline_late]
8+
private string locationToString(Location loc) {
9+
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
10+
loc.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
11+
result = filepath + "@" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
12+
)
13+
}
14+
15+
newtype TLocation =
16+
TBaseLocation(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
17+
exists(File file |
18+
file.getAbsolutePath() = filepath and
19+
locations_default(_, file, startline, startcolumn, endline, endcolumn)
20+
)
21+
or
22+
exists(ExpressionImpl e |
23+
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
24+
)
25+
or
26+
filepath = "" and startline = 0 and startcolumn = 0 and endline = 0 and endcolumn = 0
27+
}
28+
29+
/**
30+
* A location as given by a file, a start line, a start column,
31+
* an end line, and an end column.
32+
*
33+
* For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
34+
*/
35+
class Location extends TLocation, TBaseLocation {
36+
string filepath;
37+
int startline;
38+
int startcolumn;
39+
int endline;
40+
int endcolumn;
41+
42+
Location() { this = TBaseLocation(filepath, startline, startcolumn, endline, endcolumn) }
43+
44+
/** Gets the file for this location. */
45+
File getFile() {
46+
exists(File file |
47+
file.getAbsolutePath() = filepath and
48+
result = file
49+
)
50+
}
51+
52+
/** Gets the 1-based line number (inclusive) where this location starts. */
53+
int getStartLine() { result = startline }
54+
55+
/** Gets the 1-based column number (inclusive) where this location starts. */
56+
int getStartColumn() { result = startcolumn }
57+
58+
/** Gets the 1-based line number (inclusive) where this.getLocationDefault() location ends. */
59+
int getEndLine() { result = endline }
60+
61+
/** Gets the 1-based column number (inclusive) where this.getLocationDefault() location ends. */
62+
int getEndColumn() { result = endcolumn }
63+
64+
/** Gets the number of lines covered by this location. */
65+
int getNumLines() { result = endline - startline + 1 }
66+
67+
/** Gets a textual representation of this element. */
68+
pragma[inline]
69+
string toString() { result = locationToString(this) }
70+
71+
/**
72+
* Holds if this element is at the specified location.
73+
* The location spans column `startcolumn` of line `startline` to
74+
* column `endcolumn` of line `endline` in file `filepath`.
75+
* For more information, see
76+
* [Providing locations in CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
77+
*/
78+
predicate hasLocationInfo(string p, int sl, int sc, int el, int ec) {
79+
p = filepath and
80+
sl = startline and
81+
sc = startcolumn and
82+
el = endline and
83+
ec = endcolumn
84+
}
85+
86+
/** Holds if this location starts strictly before the specified location. */
87+
pragma[inline]
88+
predicate strictlyBefore(Location other) {
89+
this.getStartLine() < other.getStartLine()
90+
or
91+
this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn()
92+
}
93+
}
94+
95+
/** An entity representing an empty location. */
96+
class EmptyLocation extends Location {
97+
EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) }
98+
}

0 commit comments

Comments
 (0)