Merge pull request #169 from github/aibaars/codespace

Add CodeSpace container
This commit is contained in:
Arthur Baars
2021-05-14 18:00:51 +02:00
committed by GitHub
7 changed files with 99 additions and 3 deletions

View File

@@ -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"
]
}
}

15
.devcontainer/Dockerfile Normal file
View File

@@ -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

View File

@@ -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" ]
}

37
.devcontainer/post_attach.sh Executable file
View File

@@ -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

4
.devcontainer/post_create.sh Executable file
View File

@@ -0,0 +1,4 @@
#! /bin/bash
mkdir -p /home/vscode/.config/codeql
echo '--search-path /workspaces/codeql-ruby' >> /home/vscode/.config/codeql/config

2
Cargo.lock generated
View File

@@ -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",

View File

@@ -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"