Skip to content

Commit

Permalink
Merge pull request #18321 from github/dbartol/actions-merge
Browse files Browse the repository at this point in the history
Migrate Actions queries to public repo
  • Loading branch information
dbartol authored Dec 19, 2024
2 parents 22b35f5 + e4bce70 commit 772b972
Show file tree
Hide file tree
Showing 1,318 changed files with 38,197 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check-qldoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
run: |
EXIT_CODE=0
# TODO: remove the shared exception from the regex when coverage of qlpacks without dbschemes is supported
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!(shared))[a-z]*/ql/lib' || true; } | sort -u)"
# TODO: remove the actions exception once https://github.com/github/codeql-team/issues/3656 is fixed
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!(shared|actions))[a-z]*/ql/lib' || true; } | sort -u)"
for pack_dir in ${changed_lib_packs}; do
lang="${pack_dir%/ql/lib}"
codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"
Expand Down
2 changes: 1 addition & 1 deletion actions/ql/lib/actions.qll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
predicate placeholder(int x) { x = 0 }
import codeql.actions.Ast
4 changes: 4 additions & 0 deletions actions/ql/lib/change-notes/2024-12-19-initial-release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: feature
---
* Initial public preview release
4 changes: 4 additions & 0 deletions actions/ql/lib/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
lockVersion: 1.0.0
dependencies: {}
compiled: false
98 changes: 98 additions & 0 deletions actions/ql/lib/codeql/Locations.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/** Provides classes for working with locations. */

import files.FileSystem
import codeql.actions.ast.internal.Ast

bindingset[loc]
pragma[inline_late]
private string locationToString(Location loc) {
exists(string filepath, int startline, int startcolumn, int endline, int endcolumn |
loc.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
result = filepath + "@" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
)
}

newtype TLocation =
TBaseLocation(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
exists(File file |
file.getAbsolutePath() = filepath and
locations_default(_, file, startline, startcolumn, endline, endcolumn)
)
or
exists(ExpressionImpl e |
e.hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
)
or
filepath = "" and startline = 0 and startcolumn = 0 and endline = 0 and endcolumn = 0
}

/**
* A location as given by a file, a start line, a start column,
* an end line, and an end column.
*
* For more information about locations see [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
class Location extends TLocation, TBaseLocation {
string filepath;
int startline;
int startcolumn;
int endline;
int endcolumn;

Location() { this = TBaseLocation(filepath, startline, startcolumn, endline, endcolumn) }

/** Gets the file for this location. */
File getFile() {
exists(File file |
file.getAbsolutePath() = filepath and
result = file
)
}

/** Gets the 1-based line number (inclusive) where this location starts. */
int getStartLine() { result = startline }

/** Gets the 1-based column number (inclusive) where this location starts. */
int getStartColumn() { result = startcolumn }

/** Gets the 1-based line number (inclusive) where this.getLocationDefault() location ends. */
int getEndLine() { result = endline }

/** Gets the 1-based column number (inclusive) where this.getLocationDefault() location ends. */
int getEndColumn() { result = endcolumn }

/** Gets the number of lines covered by this location. */
int getNumLines() { result = endline - startline + 1 }

/** Gets a textual representation of this element. */
pragma[inline]
string toString() { result = locationToString(this) }

/**
* 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
* [Providing locations in CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
*/
predicate hasLocationInfo(string p, int sl, int sc, int el, int ec) {
p = filepath and
sl = startline and
sc = startcolumn and
el = endline and
ec = endcolumn
}

/** Holds if this location starts strictly before the specified location. */
pragma[inline]
predicate strictlyBefore(Location other) {
this.getStartLine() < other.getStartLine()
or
this.getStartLine() = other.getStartLine() and this.getStartColumn() < other.getStartColumn()
}
}

/** An entity representing an empty location. */
class EmptyLocation extends Location {
EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) }
}
Loading

0 comments on commit 772b972

Please sign in to comment.