Skip to content

Commit 7384122

Browse files
committed
Merge branch 'main' into redsun82/swift-open-redirection
2 parents 4f5f0aa + 2dbacbc commit 7384122

File tree

125 files changed

+12086
-3030
lines changed

Some content is hidden

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

125 files changed

+12086
-3030
lines changed

.github/actions/os-version/action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: OS Version
2+
description: Get OS version.
3+
4+
outputs:
5+
version:
6+
description: "OS version"
7+
value: ${{ steps.version.outputs.version }}
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- if: runner.os == 'Linux'
13+
shell: bash
14+
run: |
15+
. /etc/os-release
16+
echo "VERSION=${NAME} ${VERSION}" >> $GITHUB_ENV
17+
- if: runner.os == 'Windows'
18+
shell: powershell
19+
run: |
20+
$objects = systeminfo.exe /FO CSV | ConvertFrom-Csv
21+
"VERSION=$($objects.'OS Name') $($objects.'OS Version')" >> $env:GITHUB_ENV
22+
- if: runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
echo "VERSION=$(sw_vers -productName) $(sw_vers -productVersion)" >> $GITHUB_ENV
26+
- name: Emit OS version
27+
id: version
28+
shell: bash
29+
run: |
30+
echo "$VERSION"
31+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
32+

.github/workflows/mad_modelDiff.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ jobs:
4040
- name: Download database
4141
env:
4242
SLUG: ${{ matrix.slug }}
43+
GH_TOKEN: ${{ github.token }}
4344
run: |
4445
set -x
4546
mkdir lib-dbs
4647
SHORTNAME=${SLUG//[^a-zA-Z0-9_]/}
47-
projectId=`curl -s https://lgtm.com/api/v1.0/projects/g/${SLUG} | jq .id`
48-
curl -L "https://lgtm.com/api/v1.0/snapshots/$projectId/java" -o "$SHORTNAME.zip"
48+
gh api -H "Accept: application/zip" "/repos/${SLUG}/code-scanning/codeql/databases/java" > "$SHORTNAME.zip"
4949
unzip -q -d "${SHORTNAME}-db" "${SHORTNAME}.zip"
5050
mkdir "lib-dbs/$SHORTNAME/"
5151
mv "${SHORTNAME}-db/"$(ls -1 "${SHORTNAME}"-db)/* "lib-dbs/${SHORTNAME}/"
@@ -100,4 +100,6 @@ jobs:
100100
with:
101101
name: diffs
102102
path: tmp-models/*.html
103+
# An html file is only produced if the generated models differ.
104+
if-no-files-found: ignore
103105
retention-days: 20

.github/workflows/ql-for-ql-build.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ jobs:
3838
shell: bash
3939
env:
4040
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
41+
- uses: ./.github/actions/os-version
42+
id: os_version
4143
- name: Cache entire pack
4244
id: cache-pack
4345
uses: actions/cache@v3
4446
with:
4547
path: ${{ runner.temp }}/pack
46-
key: ${{ runner.os }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }}
48+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }}
4749
- name: Cache queries
4850
if: steps.cache-pack.outputs.cache-hit != 'true'
4951
id: cache-queries
@@ -77,7 +79,7 @@ jobs:
7779
ql/target/release/ql-autobuilder.exe
7880
ql/target/release/ql-extractor
7981
ql/target/release/ql-extractor.exe
80-
key: ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
82+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
8183
- name: Cache cargo
8284
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8385
uses: actions/cache@v3
@@ -86,7 +88,7 @@ jobs:
8688
~/.cargo/registry
8789
~/.cargo/git
8890
ql/target
89-
key: ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
91+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
9092
- name: Check formatting
9193
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
9294
run: cd ql; cargo fmt --all -- --check
@@ -172,4 +174,4 @@ jobs:
172174
with:
173175
name: ql-for-ql-langs
174176
path: split-sarif
175-
retention-days: 1
177+
retention-days: 1

.github/workflows/ql-for-ql-dataset_measure.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ jobs:
2828
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
2929
with:
3030
languages: javascript # does not matter
31+
- uses: ./.github/actions/os-version
32+
id: os_version
3133
- uses: actions/cache@v3
3234
with:
3335
path: |
3436
~/.cargo/registry
3537
~/.cargo/git
3638
ql/target
37-
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
39+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
3840
- name: Build Extractor
3941
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh
4042
env:

.github/workflows/ql-for-ql-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ jobs:
2525
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
2626
with:
2727
languages: javascript # does not matter
28+
- uses: ./.github/actions/os-version
29+
id: os_version
2830
- uses: actions/cache@v3
2931
with:
3032
path: |
3133
~/.cargo/registry
3234
~/.cargo/git
3335
ql/target
34-
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
36+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
3537
- name: Build extractor
3638
run: |
3739
cd ql;

.github/workflows/ruby-build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
run: |
4949
brew install gnu-tar
5050
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
51+
- uses: ./.github/actions/os-version
52+
id: os_version
5153
- name: Cache entire extractor
5254
uses: actions/cache@v3
5355
id: cache-extractor
@@ -58,15 +60,15 @@ jobs:
5860
ruby/target/release/ruby-extractor
5961
ruby/target/release/ruby-extractor.exe
6062
ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
61-
key: ${{ runner.os }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
63+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
6264
- uses: actions/cache@v3
6365
if: steps.cache-extractor.outputs.cache-hit != 'true'
6466
with:
6567
path: |
6668
~/.cargo/registry
6769
~/.cargo/git
6870
ruby/target
69-
key: ${{ runner.os }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
71+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
7072
- name: Check formatting
7173
if: steps.cache-extractor.outputs.cache-hit != 'true'
7274
run: cargo fmt --all -- --check

cpp/ql/lib/definitions.qll

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ private predicate constructorCallTypeMention(ConstructorCall cc, TypeMention tm)
123123
)
124124
}
125125

126+
/** Holds if `loc` has the container `container` and is on the line starting at `startLine`. */
127+
pragma[nomagic]
128+
private predicate hasContainerAndStartLine(Location loc, Container container, int startLine) {
129+
loc.getStartLine() = startLine and
130+
loc.getContainer() = container
131+
}
132+
126133
/**
127134
* Gets an element, of kind `kind`, that element `e` uses, if any.
128135
* Attention: This predicate yields multiple definitions for a single location.
@@ -184,11 +191,9 @@ Top definitionOf(Top e, string kind) {
184191
kind = "I" and
185192
result = e.(Include).getIncludedFile() and
186193
// exclude `#include` directives containing macros
187-
not exists(MacroInvocation mi, Location l1, Location l2 |
188-
l1 = e.(Include).getLocation() and
189-
l2 = mi.getLocation() and
190-
l1.getContainer() = l2.getContainer() and
191-
l1.getStartLine() = l2.getStartLine()
194+
not exists(MacroInvocation mi, Container container, int startLine |
195+
hasContainerAndStartLine(e.(Include).getLocation(), container, startLine) and
196+
hasContainerAndStartLine(mi.getLocation(), container, startLine)
192197
// (an #include directive must be always on it's own line)
193198
)
194199
) and

cpp/ql/lib/semmle/code/cpp/Location.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import semmle.code.cpp.File
1010
*/
1111
class Location extends @location {
1212
/** Gets the container corresponding to this location. */
13+
pragma[nomagic]
1314
Container getContainer() { this.fullLocationInfo(result, _, _, _, _) }
1415

1516
/** Gets the file corresponding to this location, if any. */
1617
File getFile() { result = this.getContainer() }
1718

1819
/** Gets the 1-based line number (inclusive) where this location starts. */
20+
pragma[nomagic]
1921
int getStartLine() { this.fullLocationInfo(_, result, _, _, _) }
2022

2123
/** Gets the 1-based column number (inclusive) where this location starts. */

cpp/ql/lib/semmle/code/cpp/ir/implementation/Opcode.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ private newtype TOpcode =
3030
TNegate() or
3131
TShiftLeft() or
3232
TShiftRight() or
33+
TUnsignedShiftRight() or
3334
TBitAnd() or
3435
TBitOr() or
3536
TBitXor() or
@@ -652,6 +653,15 @@ module Opcode {
652653
final override string toString() { result = "ShiftRight" }
653654
}
654655

656+
/**
657+
* The `Opcode` for a `UnsignedShiftRightInstruction`.
658+
*
659+
* See the `UnsignedShiftRightInstruction` documentation for more details.
660+
*/
661+
class UnsignedShiftRight extends BinaryBitwiseOpcode, TUnsignedShiftRight {
662+
final override string toString() { result = "UnsignedShiftRight" }
663+
}
664+
655665
/**
656666
* The `Opcode` for a `BitAndInstruction`.
657667
*

cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,17 @@ class ShiftRightInstruction extends BinaryBitwiseInstruction {
12041204
ShiftRightInstruction() { this.getOpcode() instanceof Opcode::ShiftRight }
12051205
}
12061206

1207+
/**
1208+
* An instruction that shifts its left operand to the right by the number of bits specified by its
1209+
* right operand.
1210+
*
1211+
* Both operands must have an integer type. The result has the same type as the left operand.
1212+
* The leftmost bits are zero-filled.
1213+
*/
1214+
class UnsignedShiftRightInstruction extends BinaryBitwiseInstruction {
1215+
UnsignedShiftRightInstruction() { this.getOpcode() instanceof Opcode::UnsignedShiftRight }
1216+
}
1217+
12071218
/**
12081219
* An instruction that performs a binary arithmetic operation involving at least one pointer
12091220
* operand.

0 commit comments

Comments
 (0)