Skip to content

Commit ea85ff5

Browse files
committed
(devcontainer): added a Codespaces edition for Auditor flavor
1 parent 205684f commit ea85ff5

2 files changed

Lines changed: 213 additions & 0 deletions

File tree

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# syntax=docker/dockerfile:1.10.0
2+
# check=error=true
3+
#
4+
# AUDITOR TRG DevContainer Dockerfile
5+
# This Dockerfile creates a specialized development environment for smart contract auditing
6+
# with focused tooling, Docker-in-Docker support, and comprehensive security analysis tools.
7+
#
8+
# Key features:
9+
# - Multi-stage build for Echidna binary
10+
# - Specialized audit tools (slither, mythril, crytic-compile)
11+
# - Foundry framework for testing and interaction
12+
# - Hardhat for development workflows
13+
# - Docker-in-Docker support for containerized tools
14+
15+
# Pull latest Echidna prebuilt image from Crytic
16+
# Echidna is a fuzzing tool for Ethereum smart contracts
17+
FROM --platform=linux/amd64 ghcr.io/crytic/echidna/echidna AS echidna
18+
19+
# Base image: Debian 12 (Bookworm) with VS Code DevContainer support
20+
# This provides a stable, development-focused base for auditing work
21+
FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm
22+
23+
# Switch to root user temporarily for system package installation
24+
USER root
25+
26+
# Install essential system packages for development
27+
# These are the minimal packages needed for Web3 development tools
28+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
29+
bash-completion # Shell completion support \
30+
build-essential # Compilation tools (gcc, make, etc.) \
31+
curl # HTTP client for downloading tools \
32+
git # Version control system \
33+
jq # JSON processor for tool outputs \
34+
pkg-config # Package configuration helper \
35+
sudo # Privilege escalation (needed for some tools) \
36+
unzip # Archive extraction \
37+
vim # Text editor \
38+
wget # Alternative HTTP client \
39+
zsh # Advanced shell \
40+
&& rm -rf /var/lib/apt/lists/*
41+
42+
43+
44+
# Install Python development dependencies
45+
# Required for Python-based security tools and package management
46+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
47+
python3-pip # Python package installer \
48+
libpython3-dev # Python development headers \
49+
python3-dev # Python development tools \
50+
python3-venv # Python virtual environment support \
51+
&& rm -rf /var/lib/apt/lists/*
52+
53+
# Switch to vscode user for security (drop privileges)
54+
# This ensures all subsequent operations run as non-root user
55+
USER vscode
56+
WORKDIR /home/vscode
57+
ENV HOME=/home/vscode
58+
59+
# Install uv
60+
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
61+
62+
# Update PATH environment for tool access
63+
# Configure paths for Python, Node.js, and other tools
64+
ENV UV_LOCAL_BIN=$HOME/.cargo/bin
65+
ENV USR_LOCAL_BIN=/usr/local/bin
66+
ENV LOCAL_BIN=${HOME}/.local/bin
67+
ENV PNPM_HOME=${HOME}/.local/share/pnpm
68+
ENV PATH=${PATH}:${USR_LOCAL_BIN}:${LOCAL_BIN}:${PNPM_HOME}:${UV_LOCAL_BIN}
69+
70+
# Install Python 3.12 with uv
71+
RUN uv python install 3.12
72+
73+
# Set the default shell to zsh for better development experience
74+
ENV SHELL=/usr/bin/zsh
75+
76+
# Running everything under zsh for consistency and features
77+
SHELL ["/usr/bin/zsh", "-ic"]
78+
79+
# Install Go programming language through asdf version manager
80+
# asdf provides consistent version management across different tools
81+
# Go is required for various Web3 tools and Foundry framework
82+
RUN git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.15.0 && \
83+
echo '. $HOME/.asdf/asdf.sh' >> $HOME/.zshrc && \
84+
echo 'fpath=(${ASDF_DIR}/completions $fpath)' >> $HOME/.zshrc && \
85+
echo 'autoload -Uz compinit && compinit' >> $HOME/.zshrc && \
86+
. $HOME/.asdf/asdf.sh && \
87+
asdf plugin add golang && \
88+
asdf install golang latest && \
89+
asdf global golang latest
90+
91+
# Install Rust programming language
92+
# Required for various Web3 security tools and Foundry framework
93+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && source $HOME/.cargo/env
94+
95+
# Switch to root user temporarily for Node.js installation
96+
USER root
97+
98+
# Install Node.js, npm, yarn, and pnpm through devcontainer features
99+
# These are essential for JavaScript/TypeScript Web3 development and Hardhat
100+
RUN curl -o- https://raw.githubusercontent.com/devcontainers/features/main/src/node/install.sh | bash
101+
RUN chown -R vscode:vscode ${HOME}/.npm
102+
103+
# Switch back to vscode user for security
104+
USER vscode
105+
106+
# Install Foundry framework for Ethereum development and testing
107+
# Foundry provides Forge (testing), Cast (interaction), and Anvil (local blockchain)
108+
# Essential for smart contract development and testing during audits
109+
RUN curl -L https://foundry.paradigm.xyz | zsh
110+
RUN foundryup
111+
112+
# Install Python-based security analysis tools for auditing
113+
# These tools provide comprehensive smart contract security analysis
114+
# Focused on core auditing tools: slither, mythril, crytic-compile
115+
RUN uv tool install slither-analyzer && \
116+
uv tool install mythril && \
117+
uv tool install crytic-compile
118+
119+
# Install Hardhat and Solhint for Ethereum development
120+
# Hardhat is a popular development environment, Solhint provides linting
121+
RUN pnpm install -g hardhat solhint
122+
123+
# Copy prebuilt Echidna binary from echidna stage to final image
124+
# This provides the prebuilt Echidna tool without rebuilding
125+
COPY --chown=vscode:vscode --from=echidna /usr/local/bin/echidna ${HOME}/.local/bin/echidna
126+
RUN chmod 755 ${HOME}/.local/bin/echidna
127+
128+
# Switch to non-root user for final setup
129+
USER vscode
130+
131+
# Set up user environment with Foundry path
132+
# Ensure Foundry tools are available in the user's shell
133+
RUN echo 'export PATH="/usr/local/foundry/bin:$PATH"' >> /home/vscode/.zshrc
134+
135+
# Switch to root for system cleanup
136+
USER root
137+
138+
# Clean up package cache and temporary files
139+
# This reduces image size and improves security
140+
RUN apt-get autoremove -y && apt-get clean -y
141+
142+
# Final switch to vscode user for development
143+
USER vscode
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
// For format details, see https://aka.ms/devcontainer.json.
3+
// This is the AUDITOR version of TRG's DevContainer - specialized for smart contract auditing
4+
// with Docker-in-Docker support, specialized audit extensions, and focused tooling for
5+
// comprehensive security analysis and code review.
6+
"name": "Auditor for Codespaces TRG's DevContainer",
7+
8+
// Build configuration - uses the local Dockerfile in this directory
9+
"build": {
10+
"dockerfile": "./Dockerfile"
11+
},
12+
13+
// Features to add to the dev container. More info: https://containers.dev/features.
14+
// Specialized features for auditing and development workflows
15+
"features": {
16+
"ghcr.io/devcontainers/features/git:1": {}, // Git version control support
17+
"ghcr.io/devcontainers/features/github-cli:1": {}, // GitHub CLI for repository management
18+
"ghcr.io/devcontainers/features/docker-in-docker:2.12.2": { // Docker-in-Docker for containerized tools
19+
"version": "latest", // Use latest stable version
20+
"enableNonRootDocker": "true" // Enable non-root Docker for security
21+
}
22+
},
23+
24+
// Configure tool-specific properties for VS Code
25+
"customizations": {
26+
"vscode": {
27+
// Specialized extensions for smart contract auditing and development
28+
"extensions": [
29+
// check out https://marketplace.visualstudio.com/items?itemName=tintinweb.ethereum-security-bundle for more information
30+
"tintinweb.ethereum-security-bundle", // includes what is listed above ^
31+
"tintinweb.vscode-ethover",
32+
"trailofbits.weaudit",
33+
"tintinweb.vscode-inline-bookmarks",
34+
"tintinweb.vscode-solidity-language",
35+
"tintinweb.graphviz-interactive-preview",
36+
"NomicFoundation.hardhat-solidity",
37+
"Olympixai.olympix",
38+
"trailofbits.contract-explorer",
39+
"tintinweb.chonky" // Chonky Agent
40+
],
41+
// VS Code settings optimized for auditing workflows
42+
"settings": {
43+
// Security settings - killswitch for automated tasks
44+
"task.autoDetect": "off", // Disable automatic task detection
45+
"task.problemMatchers.autoDetect": "off", // Disable automatic problem matchers
46+
47+
// Trust and security configuration
48+
"security.workspace.trust.enabled": false, // Trust no one by default
49+
50+
// Privacy settings - killswitch for telemetry
51+
"telemetry.telemetryLevel": "off", // Disable all telemetry collection
52+
53+
// Terminal configuration
54+
"terminal.integrated.defaultProfile.linux": "zsh", // Use zsh by default
55+
"terminal.integrated.profiles.linux": { "zsh": { "path": "/usr/bin/zsh" } }
56+
// Using bash might be more safe and stable, but zsh provides better features
57+
},
58+
}
59+
},
60+
61+
// Mount copying host folder into container, no hardening.
62+
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
63+
// Sets a hardened workspace path
64+
"workspaceFolder": "/workspace",
65+
66+
// Writable mounts in case you want to set --read-only above.
67+
// Currently no additional mounts are configured
68+
"mounts": [
69+
]
70+
}

0 commit comments

Comments
 (0)