Skip to content

Commit 772b972

Browse files
authored
Merge pull request #18321 from github/dbartol/actions-merge
Migrate Actions queries to public repo
2 parents 22b35f5 + e4bce70 commit 772b972

File tree

1,318 files changed

+38197
-48
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,318 files changed

+38197
-48
lines changed

.github/workflows/check-qldoc.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
run: |
3131
EXIT_CODE=0
3232
# TODO: remove the shared exception from the regex when coverage of qlpacks without dbschemes is supported
33-
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!(shared))[a-z]*/ql/lib' || true; } | sort -u)"
33+
# TODO: remove the actions exception once https://github.com/github/codeql-team/issues/3656 is fixed
34+
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!(shared|actions))[a-z]*/ql/lib' || true; } | sort -u)"
3435
for pack_dir in ${changed_lib_packs}; do
3536
lang="${pack_dir%/ql/lib}"
3637
codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"

actions/ql/lib/actions.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
predicate placeholder(int x) { x = 0 }
1+
import codeql.actions.Ast
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Initial public preview release

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

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
lockVersion: 1.0.0
3+
dependencies: {}
4+
compiled: false

actions/ql/lib/codeql/Locations.qll

+98
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)