From 498e760b2115a72b8cc988b8e448ace6b0cf4d55 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Tue, 27 Apr 2021 20:55:53 +0200 Subject: [PATCH 1/3] Add consistency queries to codeqlmanifest --- .codeqlmanifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.codeqlmanifest.json b/.codeqlmanifest.json index 6e6333c430c..63200dbfc95 100644 --- a/.codeqlmanifest.json +++ b/.codeqlmanifest.json @@ -1,9 +1,10 @@ { "provide": [ "ql/src/qlpack.yml", + "ql/consistency-queries/qlpack.yml", "ql/test/qlpack.yml", "ql/examples/qlpack.yml", "upgrades/qlpack.yml", "extractor-pack/codeql-extractor.yml" ] -} \ No newline at end of file +} From 3547980f5bca25ba5990d604ea062c83d4ca487f Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Thu, 13 May 2021 15:24:02 +0200 Subject: [PATCH 2/3] Update reference to tree-sitter-embedded-template --- Cargo.lock | 2 +- extractor/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20e44a76f26..3cf8082d015 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -590,7 +590,7 @@ dependencies = [ [[package]] name = "tree-sitter-embedded-template" version = "0.17.0" -source = "git+https://github.com/aibaars/tree-sitter-embedded-template?rev=d4aac29c08aa7c596633d00b5ec2dd2d247eafe4#d4aac29c08aa7c596633d00b5ec2dd2d247eafe4" +source = "git+https://github.com/tree-sitter/tree-sitter-embedded-template?rev=d4aac29c08aa7c596633d00b5ec2dd2d247eafe4#d4aac29c08aa7c596633d00b5ec2dd2d247eafe4" dependencies = [ "cc", "tree-sitter", diff --git a/extractor/Cargo.toml b/extractor/Cargo.toml index ebe82e28282..cc600391701 100644 --- a/extractor/Cargo.toml +++ b/extractor/Cargo.toml @@ -10,7 +10,7 @@ edition = "2018" flate2 = "1.0" node-types = { path = "../node-types" } tree-sitter = "0.17" -tree-sitter-embedded-template = { git = "https://github.com/aibaars/tree-sitter-embedded-template", rev = "d4aac29c08aa7c596633d00b5ec2dd2d247eafe4" } +tree-sitter-embedded-template = { git = "https://github.com/tree-sitter/tree-sitter-embedded-template", rev = "d4aac29c08aa7c596633d00b5ec2dd2d247eafe4" } tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby.git", rev = "32cd5a04adb4accb0c121f037ab59df3c3488228" } clap = "2.33" tracing = "0.1" From 66bf13e77a1b2951a4ccf3190527c04c44087229 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Tue, 27 Apr 2021 11:46:11 +0000 Subject: [PATCH 3/3] Setup a CodeSpace --- .devcontainer/Dockerfile | 15 +++++++++++++ .devcontainer/devcontainer.json | 39 +++++++++++++++++++++++++++++++++ .devcontainer/post_attach.sh | 37 +++++++++++++++++++++++++++++++ .devcontainer/post_create.sh | 4 ++++ 4 files changed, 95 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/post_attach.sh create mode 100755 .devcontainer/post_create.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..a5776e19806 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,15 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/rust/.devcontainer/base.Dockerfile + +FROM mcr.microsoft.com/vscode/devcontainers/rust:0-1 + +RUN apt-key --keyring /usr/share/keyrings/githubcli-archive-keyring.gpg adv \ + --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages $(lsb_release -cs) main" \ + | tee /etc/apt/sources.list.d/github-cli2.list > /dev/null + + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends gh + +COPY post_create.sh /bin/post_create.sh +COPY post_attach.sh /bin/post_attach.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..b7824f45cfe --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/rust +{ + "name": "Rust", + "build": { + "dockerfile": "Dockerfile" + }, + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "lldb.executable": "/usr/bin/lldb", + // VS Code don't watch files under ./target + "files.watcherExclude": { + "**/target/**": true + } + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "rust-lang.rust", + "bungcip.better-toml", + "vadimcn.vscode-lldb", + "mutantdino.resourcemonitor", + "ms-azuretools.vscode-docker", + "github.vscode-codeql" + ], + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "rustc --version", + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode", + "postCreateCommand": [ "/bin/post_create.sh" ], + "postAttachCommand": [ "flock", "-E", "0", "-n", "/var/lock/post_attach.lock", "/bin/post_attach.sh" ] +} \ No newline at end of file diff --git a/.devcontainer/post_attach.sh b/.devcontainer/post_attach.sh new file mode 100755 index 00000000000..989ed912be9 --- /dev/null +++ b/.devcontainer/post_attach.sh @@ -0,0 +1,37 @@ +#! /bin/bash +set -xe + +echo "Check installed CodeQL version" +CURRENT_CODEQL_BIN=$(readlink -e /usr/local/bin/codeql || echo "") +LATEST=$(gh release list --repo https://github.com/github/codeql-cli-binaries | cut -f 1 | sort --version-sort | tail -1) + +BASE_DIR=/home/vscode/codeql-binaries +mkdir -p "${BASE_DIR}" +LATEST_CODEQL_DIR="${BASE_DIR}/codeql-${LATEST}" +LATEST_CODEQL_BIN="${LATEST_CODEQL_DIR}/codeql/codeql" + +if [ "${CURRENT_CODEQL_BIN}" != "${LATEST_CODEQL_BIN}" ]; then + echo "Installing CodeQL ${LATEST}" + TMPDIR=$(mktemp -d -p "$(dirname ${LATEST_CODEQL_DIR})") + gh release download --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip -D "${TMPDIR}" "$LATEST" + unzip -oq "${TMPDIR}/codeql-linux64.zip" -d "${TMPDIR}" + rm -f "${TMPDIR}/codeql-linux64.zip" + mv "${TMPDIR}" "${LATEST_CODEQL_DIR}" + test -x "${LATEST_CODEQL_BIN}" && sudo ln -sf "${LATEST_CODEQL_BIN}" /usr/local/bin/codeql + if [[ "${CURRENT_CODEQL_BIN}" =~ .*/codeql/codeql ]]; then + rm -rf "$(dirname $(dirname ${CURRENT_CODEQL_BIN}))" + fi +fi + +echo "Build the Ruby extractor" + +# clone the git dependencies using "git clone" because cargo's builtin git support is rather slow +REPO_DIR="${CARGO_HOME:-/home/vscode/.cargo}/git/db" +REPO_DIR_ERB="${REPO_DIR}/tree-sitter-embedded-template-4c796e3340c233b6" +REPO_DIR_RUBY="${REPO_DIR}/tree-sitter-ruby-666a40ce046f8e7a" + +mkdir -p "${REPO_DIR}" +test -e "${REPO_DIR_ERB}" || git clone -q --bare https://github.com/tree-sitter/tree-sitter-embedded-template "${REPO_DIR_ERB}" +test -e "${REPO_DIR_RUBY}" || git clone -q --bare https://github.com/tree-sitter/tree-sitter-ruby.git "${REPO_DIR_RUBY}" + +./create-extractor-pack.sh diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh new file mode 100755 index 00000000000..a1af653024b --- /dev/null +++ b/.devcontainer/post_create.sh @@ -0,0 +1,4 @@ +#! /bin/bash + +mkdir -p /home/vscode/.config/codeql +echo '--search-path /workspaces/codeql-ruby' >> /home/vscode/.config/codeql/config