Skip to content

Commit b75e19a

Browse files
authored
QL: Merge branch 'main' into tausbn/update-extractor-generator
2 parents 8020040 + 53e362c commit b75e19a

16 files changed

Lines changed: 474 additions & 64 deletions

File tree

.github/workflows/codeql-analysis.yml renamed to .github/workflows/bleeding-codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "CodeQL"
1+
name: "CodeQL with bleeding edge queries and extractor"
22

33
on:
44
workflow_dispatch:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "CodeQL with published queries and extractor"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
# The branches below must be a subset of the branches above
9+
branches: [ main ]
10+
11+
jobs:
12+
13+
analyze:
14+
name: Analyze
15+
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
actions: read
20+
contents: read
21+
security-events: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v2
26+
27+
- name: Download pack
28+
run: |
29+
# adjust this line to make the workflow work in other repositories
30+
# the ql-qlpack.zip file can be downloaded at:
31+
# - https://github.com/github/codeql-ql/releases
32+
# - https://github.com/github/codeql-ql/actions/workflows/bleeding-codeql-analysis.yml
33+
gh release download latest --pattern ql-qlpack.zip
34+
unzip ql-qlpack.zip -d "${PACK}"
35+
env:
36+
PACK: ${{ runner.temp }}/ql-qlpack
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Hack codeql-action options
40+
run: |
41+
JSON=$(jq -nc --arg pack "${PACK}" '.resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .database.init=["--search-path", $pack]')
42+
echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV}
43+
env:
44+
PACK: ${{ runner.temp }}/ql-qlpack
45+
46+
- name: Initialize CodeQL
47+
uses: github/codeql-action/init@esbena/ql
48+
with:
49+
languages: ql
50+
db-location: ${{ runner.temp }}/db
51+
52+
- name: Perform CodeQL Analysis
53+
uses: github/codeql-action/analyze@esbena/ql
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import codeql_ql.ast.internal.Builtins::BuildinsConsistency

ql/src/codeql/files/FileSystem.qll

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ abstract class Container extends @container {
99
Container getAChildContainer() { this = result.getParentContainer() }
1010

1111
/** Gets a file in this container. */
12-
File getAFile() { result = getAChildContainer() }
12+
File getAFile() { result = this.getAChildContainer() }
1313

1414
/** Gets a sub-folder in this container. */
15-
Folder getAFolder() { result = getAChildContainer() }
15+
Folder getAFolder() { result = this.getAChildContainer() }
1616

1717
/**
1818
* Gets the absolute, canonical path of this container, using forward slashes
@@ -58,7 +58,7 @@ abstract class Container extends @container {
5858
* </table>
5959
*/
6060
string getBaseName() {
61-
result = getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
61+
result = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
6262
}
6363

6464
/**
@@ -84,17 +84,19 @@ abstract class Container extends @container {
8484
* <tr><td>"/tmp/x.tar.gz"</td><td>"gz"</td></tr>
8585
* </table>
8686
*/
87-
string getExtension() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3) }
87+
string getExtension() {
88+
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3)
89+
}
8890

8991
/** Gets the file in this container that has the given `baseName`, if any. */
9092
File getFile(string baseName) {
91-
result = getAFile() and
93+
result = this.getAFile() and
9294
result.getBaseName() = baseName
9395
}
9496

9597
/** Gets the sub-folder in this container that has the given `baseName`, if any. */
9698
Folder getFolder(string baseName) {
97-
result = getAFolder() and
99+
result = this.getAFolder() and
98100
result.getBaseName() = baseName
99101
}
100102

@@ -111,7 +113,7 @@ abstract class Container extends @container {
111113
*/
112114
string getRelativePath() {
113115
exists(string absPath, string pref |
114-
absPath = getAbsolutePath() and sourceLocationPrefix(pref)
116+
absPath = this.getAbsolutePath() and sourceLocationPrefix(pref)
115117
|
116118
absPath = pref and result = ""
117119
or
@@ -137,7 +139,9 @@ abstract class Container extends @container {
137139
* <tr><td>"/tmp/x.tar.gz"</td><td>"x.tar"</td></tr>
138140
* </table>
139141
*/
140-
string getStem() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1) }
142+
string getStem() {
143+
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1)
144+
}
141145

142146
/**
143147
* Gets a URL representing the location of this container.
@@ -151,15 +155,15 @@ abstract class Container extends @container {
151155
*
152156
* This is the absolute path of the container.
153157
*/
154-
string toString() { result = getAbsolutePath() }
158+
string toString() { result = this.getAbsolutePath() }
155159
}
156160

157161
/** A folder. */
158162
class Folder extends Container, @folder {
159163
override string getAbsolutePath() { folders(this, result) }
160164

161165
/** Gets the URL of this folder. */
162-
override string getURL() { result = "folder://" + getAbsolutePath() }
166+
override string getURL() { result = "folder://" + this.getAbsolutePath() }
163167
}
164168

165169
/** A file. */

0 commit comments

Comments
 (0)