Skip to content

Commit cde7f7c

Browse files
authored
Merge pull request #13 from CodeIntelligenceTesting/dev-container
Dev container
2 parents 3e1bca5 + 63e8533 commit cde7f7c

File tree

6 files changed

+142
-1
lines changed

6 files changed

+142
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04
2+
3+
#ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"
4+
5+
# Optionally install the cmake for vcpkg
6+
#COPY ./reinstall-cmake.sh /tmp/
7+
8+
#RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
9+
# chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
10+
# fi \
11+
# && rm -f /tmp/reinstall-cmake.sh
12+
13+
# [Optional] Uncomment this section to install additional vcpkg ports.
14+
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"
15+
16+
# [Optional] Uncomment this section to install additional packages.
17+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
18+
&& apt-get -y install --no-install-recommends cmake clang llvm lcov
19+
RUN --mount=type=secret,id=credentials \
20+
export CIFUZZ_CREDENTIALS=$(cat /run/secrets/credentials) &&\
21+
sh -c "$(curl -fsSL http://downloads.code-intelligence.com/assets/install-cifuzz.sh)" $CIFUZZ_CREDENTIALS latest &&\
22+
export CIFUZZ_CREDENTIALS=""
23+
24+
25+
RUN sysctl vm.mmap_rnd_bits=30
26+
RUN cifuzz completion bash > /etc/bash_completion.d/cifuzz

.devcontainer/devcontainer.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
3+
{
4+
"name": "Cifuzz",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"options": [
8+
"--secret=id=credentials,env=CIFUZZ_CREDENTIALS"
9+
]
10+
},
11+
"features": {
12+
"ghcr.io/devcontainers-community/features/llvm:3": {}
13+
},
14+
"customizations": {
15+
"vscode": {
16+
"extensions": [
17+
"ryanluker.vscode-coverage-gutters",
18+
"ms-vscode.cpptools",
19+
"ms-vscode.cpptools-extension-pack",
20+
"jeff-hykin.better-cpp-syntax"
21+
]
22+
}
23+
}
24+
25+
// Features to add to the dev container. More info: https://containers.dev/features.
26+
// "features": {},
27+
28+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
29+
// "forwardPorts": [],
30+
31+
// Use 'postCreateCommand' to run commands after the container is created.
32+
// "postCreateCommand": "gcc -v",
33+
34+
// Configure tool-specific properties.
35+
// "customizations": {},
36+
37+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
38+
// "remoteUser": "root"
39+
}

.devcontainer/reinstall-cmake.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
#-------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5+
#-------------------------------------------------------------------------------------------------------------
6+
#
7+
set -e
8+
9+
CMAKE_VERSION=${1:-"none"}
10+
11+
if [ "${CMAKE_VERSION}" = "none" ]; then
12+
echo "No CMake version specified, skipping CMake reinstallation"
13+
exit 0
14+
fi
15+
16+
# Cleanup temporary directory and associated files when exiting the script.
17+
cleanup() {
18+
EXIT_CODE=$?
19+
set +e
20+
if [[ -n "${TMP_DIR}" ]]; then
21+
echo "Executing cleanup of tmp files"
22+
rm -Rf "${TMP_DIR}"
23+
fi
24+
exit $EXIT_CODE
25+
}
26+
trap cleanup EXIT
27+
28+
29+
echo "Installing CMake..."
30+
apt-get -y purge --auto-remove cmake
31+
mkdir -p /opt/cmake
32+
33+
architecture=$(dpkg --print-architecture)
34+
case "${architecture}" in
35+
arm64)
36+
ARCH=aarch64 ;;
37+
amd64)
38+
ARCH=x86_64 ;;
39+
*)
40+
echo "Unsupported architecture ${architecture}."
41+
exit 1
42+
;;
43+
esac
44+
45+
CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
46+
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
47+
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)
48+
49+
echo "${TMP_DIR}"
50+
cd "${TMP_DIR}"
51+
52+
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
53+
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O
54+
55+
sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
56+
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license
57+
58+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
59+
ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for more information:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
# https://containers.dev/guide/dependabot
6+
7+
version: 2
8+
updates:
9+
- package-ecosystem: "devcontainers"
10+
directory: "/"
11+
schedule:
12+
interval: weekly

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ build
44
cmake-build-debug
55

66
/**/.cifuzz-*
7-
/**/*fuzzer_inputs
7+
/**/*fuzzer_inputs
8+
9+
/**/lcov.info

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ input parameters that trigger the bug.
2727
* [Automotive Example](src/automotive):
2828
An example that demonstrates the challenges of creating high-quality fuzz tests for complex
2929
projects with a large public API. We demonstrate how we can automate most of this task with CI Spark.
30+
31+
32+
If you want to use the devcontainer environment then export your cifuzz download token to a environment var called "CIFUZZ_CREDENTIALS" like `export CIFUZZ_CREDENTIALS=[my_token]`.

0 commit comments

Comments
 (0)