Skip to content

Commit 4f8373f

Browse files
committed
Merge branch 'main' into rdmarsh2/dataflow-global-vars
2 parents 4a52283 + dfe276a commit 4f8373f

File tree

1,402 files changed

+85084
-53848
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,402 files changed

+85084
-53848
lines changed

.devcontainer/swift/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.236.0/containers/cpp/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/22.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
4+
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-ubuntu-22.04
5+
6+
USER root
7+
ADD root.sh /tmp/root.sh
8+
ADD update-codeql.sh /usr/local/bin/update-codeql
9+
RUN bash /tmp/root.sh && rm /tmp/root.sh

.devcontainer/swift/devcontainer.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extensions": [
3+
"github.vscode-codeql",
4+
"hbenl.vscode-test-explorer",
5+
"ms-vscode.test-adapter-converter",
6+
"slevesque.vscode-zipexplorer",
7+
"ms-vscode.cpptools"
8+
],
9+
"settings": {
10+
"files.watcherExclude": {
11+
"**/target/**": true
12+
},
13+
"codeQL.runningQueries.memory": 2048
14+
},
15+
"build": {
16+
"dockerfile": "Dockerfile",
17+
},
18+
"runArgs": [
19+
"--cap-add=SYS_PTRACE",
20+
"--security-opt",
21+
"seccomp=unconfined"
22+
],
23+
"remoteUser": "vscode",
24+
"onCreateCommand": ".devcontainer/swift/user.sh"
25+
}

.devcontainer/swift/root.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set -xe
2+
3+
BAZELISK_VERSION=v1.12.0
4+
BAZELISK_DOWNLOAD_SHA=6b0bcb2ea15bca16fffabe6fda75803440375354c085480fe361d2cbf32501db
5+
6+
apt-get update
7+
export DEBIAN_FRONTEND=noninteractive
8+
apt-get -y install --no-install-recommends \
9+
zlib1g-dev \
10+
uuid-dev \
11+
python3-distutils \
12+
python3-pip \
13+
bash-completion
14+
15+
# Install Bazel
16+
curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-amd64
17+
echo "${BAZELISK_DOWNLOAD_SHA} */usr/local/bin/bazelisk" | sha256sum --check -
18+
chmod 0755 /usr/local/bin/bazelisk
19+
ln -s bazelisk /usr/local/bin/bazel
20+
21+
# install latest codeql
22+
update-codeql

.devcontainer/swift/update-codeql.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash -e
2+
3+
URL=https://github.com/github/codeql-cli-binaries/releases
4+
LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' $URL/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
5+
CURRENT_VERSION=v$(codeql version 2>/dev/null | sed -ne 's/.*release \([0-9.]*\)\./\1/p')
6+
if [[ $CURRENT_VERSION != $LATEST_VERSION ]]; then
7+
if [[ $UID != 0 ]]; then
8+
echo "update required, please run this script with sudo:"
9+
echo " sudo $0"
10+
exit 1
11+
fi
12+
ZIP=$(mktemp codeql.XXXX.zip)
13+
curl -fSqL -o $ZIP $URL/download/$LATEST_VERSION/codeql-linux64.zip
14+
unzip -q $ZIP -d /opt
15+
rm $ZIP
16+
ln -sf /opt/codeql/codeql /usr/local/bin/codeql
17+
echo installed version $LATEST_VERSION
18+
else
19+
echo current version $CURRENT_VERSION is up-to-date
20+
fi

.devcontainer/swift/user.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set -xe
2+
3+
# add the workspace to the codeql search path
4+
mkdir -p /home/vscode/.config/codeql
5+
echo "--search-path /workspaces/codeql" > /home/vscode/.config/codeql/config
6+
7+
# create a swift extractor pack with the current state
8+
cd /workspaces/codeql
9+
bazel run swift/create-extractor-pack
10+
11+
#install and set up pre-commit
12+
python3 -m pip install pre-commit --no-warn-script-location
13+
$HOME/.local/bin/pre-commit install

.github/workflows/swift-codegen.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@ jobs:
1515
- uses: actions/checkout@v3
1616
- uses: ./.github/actions/fetch-codeql
1717
- uses: bazelbuild/setup-bazelisk@v2
18+
- uses: actions/setup-python@v3
19+
- uses: pre-commit/action@v3.0.0
20+
name: Check that python code is properly formatted
21+
with:
22+
extra_args: autopep8 --all-files
1823
- name: Run unit tests
1924
run: |
2025
bazel test //swift/codegen/test --test_output=errors
21-
- name: Check that QL generated code was checked in
22-
run: |
23-
bazel run //swift/codegen
24-
git add swift
25-
git diff --exit-code --stat HEAD
26+
- uses: pre-commit/action@v3.0.0
27+
name: Check that QL generated code was checked in
28+
with:
29+
extra_args: swift-codegen --all-files
2630
- name: Generate C++ files
2731
run: |
28-
bazel run //swift/codegen:codegen -- --generate=trap,cpp --cpp-output=$PWD/swift-generated-headers
32+
bazel run //swift/codegen:codegen -- --generate=trap,cpp --cpp-output=$PWD/swift-generated-cpp-files
2933
- uses: actions/upload-artifact@v3
3034
with:
31-
name: swift-generated-headers
32-
path: swift-generated-headers/*.h
35+
name: swift-generated-cpp-files
36+
path: swift-generated-cpp-files/**

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ go/main
5858
# node_modules folders except in the JS test suite
5959
node_modules/
6060
!/javascript/ql/test/**/node_modules/
61+
62+
# Temporary folders for working with generated models
63+
.model-temp

.pre-commit-config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ repos:
1515
- id: clang-format
1616
files: ^swift/.*\.(h|c|cpp)$
1717

18+
- repo: https://github.com/pre-commit/mirrors-autopep8
19+
rev: v1.6.0
20+
hooks:
21+
- id: autopep8
22+
files: ^swift/codegen/.*\.py
23+
1824
- repo: local
1925
hooks:
2026
- id: codeql-format
@@ -40,7 +46,7 @@ repos:
4046
name: Run Swift checked in code generation
4147
files: ^swift/(codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements))
4248
language: system
43-
entry: bazel run //swift/codegen
49+
entry: bazel run //swift/codegen -- --quiet
4450
pass_filenames: false
4551

4652
- id: swift-codegen-unit-tests

config/identical-files.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"DataFlow Java/C# Flow Summaries": [
7676
"java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll",
7777
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll",
78-
"ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll"
78+
"ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll",
79+
"swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll"
7980
],
8081
"SsaReadPosition Java/C#": [
8182
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll",
@@ -527,7 +528,8 @@
527528
"java/ql/lib/semmle/code/java/dataflow/internal/AccessPathSyntax.qll",
528529
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll",
529530
"ruby/ql/lib/codeql/ruby/dataflow/internal/AccessPathSyntax.qll",
530-
"python/ql/lib/semmle/python/frameworks/data/internal/AccessPathSyntax.qll"
531+
"python/ql/lib/semmle/python/frameworks/data/internal/AccessPathSyntax.qll",
532+
"swift/ql/lib/codeql/swift/dataflow/internal/AccessPathSyntax.qll"
531533
],
532534
"IncompleteUrlSubstringSanitization": [
533535
"javascript/ql/src/Security/CWE-020/IncompleteUrlSubstringSanitization.qll",

cpp/ql/lib/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.2.3
2+
3+
### New Features
4+
5+
* An `isBraced` predicate was added to the `Initializer` class which holds when a C++ braced initializer was used in the initialization.
6+
17
## 0.2.2
28

39
### Deprecated APIs

0 commit comments

Comments
 (0)