Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/codeql/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"codeql_version": {
"type": "string",
"proposals": [
"2.19.1"
"latest"
],
"default": "2.19.1",
"default": "latest",
"description": "Select the version of the CodeQL CLI to install"
}
},
Expand Down
61 changes: 27 additions & 34 deletions src/codeql/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

CODEQL_HOME=/usr/local/codeql-home

CODEQL_TAG=""
echo "Activating feature 'CodeQL'"
echo "The provided CodeQL version is: $CODEQL_VERSION"
echo "The CodeQL home directory is: $CODEQL_HOME"
Expand All @@ -19,59 +19,52 @@ echo "The effective dev container remoteUser's home directory is '$_REMOTE_USER_
echo "The effective dev container containerUser is '$_CONTAINER_USER'"
echo "The effective dev container containerUser's home directory is '$_CONTAINER_USER_HOME'"


check_version() {
if [ -z "$1" ]; then
echo "Version is not provided"
exit 1
fi
echo "Checking version"

if ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version is not valid. Please provide a valid version"
exit 1
# Set the codeql version to the latest if it is not provided
if [ "$CODEQL_VERSION" = "latest" ]; then
CODEQL_TAG=$(curl -s https://api.github.com/repos/github/codeql-action/releases/latest | jq -r '.tag_name')
echo "Setting the CodeQL version to the latest: $CODEQL_TAG"
else
CODEQL_TAG="codeql-bundle-v$CODEQL_VERSION"
echo "Using provided version: $CODEQL_TAG"
fi
}

install_packages(){
install_packages() {
echo "Installing required packages"

apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
software-properties-common \
curl \
git \
git-lfs \
build-essential \
unzip \
apt-transport-https \
python3.10 \
python3-venv \
python3-pip \
python3-setuptools \
python3-dev \
python-is-python3 \
gnupg \
g++ \
make \
gcc \
apt-utils

# Clean up
apt-get clean && apt-get autoremove
jq \
ca-certificates

update-ca-certificates

echo "Installed packages:"
curl --version
jq --version
}

install_codeql(){
install_codeql() {
echo "Installing CodeQL"
mkdir ${CODEQL_HOME}

# Install CodeQL
cd /tmp

echo "Downloading CodeQL bundle v${CODEQL_VERSION}"
curl -OL https://github.com/github/codeql-action/releases/download/codeql-bundle-v${CODEQL_VERSION}/codeql-bundle-linux64.tar.gz
echo "Downloading CodeQL bundle v${CODEQL_TAG}"
curl -OL https://github.com/github/codeql-action/releases/download/${CODEQL_TAG}/codeql-bundle-linux64.tar.gz
tar -xvf /tmp/codeql-bundle-linux64.tar.gz --directory ${CODEQL_HOME}
rm /tmp/codeql-bundle-linux64.tar.gz
}

check_version
install_packages

#install_packages
check_version

install_codeql
1 change: 0 additions & 1 deletion test/codeql/codeql_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "execute command" bash -c "color | grep 'CodeQL installed at /usr/local/codeql-home and version is 2.19.1"
check "Validate CodeQL Version installed" codeql --version | grep "$CODEQL_VERSION"

# Report result
Expand Down
2 changes: 1 addition & 1 deletion test/codeql/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"check_codeql_version": {
"codeql_version": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"codeql": {
Expand Down