diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..47ea27e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,22 @@ +# Use Ubuntu 24.04 as base image to match the current environment +FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04 + +# Install system dependencies +# Note: Python and Git are installed via devcontainer features +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + build-essential \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Install CodeQL CLI +RUN curl -Ls -o /tmp/codeql.zip https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql-linux64.zip \ + && unzip /tmp/codeql.zip -d /opt \ + && mv /opt/codeql /opt/codeql-cli \ + && ln -s /opt/codeql-cli/codeql /usr/local/bin/codeql \ + && rm /tmp/codeql.zip + +# Set working directory +WORKDIR /workspaces/seclab-taskflows + +# The rest of the setup will be done in post-create script diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..a55f621 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,56 @@ +{ + "name": "Seclab Taskflows", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + // Features to add to the dev container + "features": { + "ghcr.io/devcontainers/features/python:1": { + "version": "3.11", + "installTools": true + }, + "ghcr.io/devcontainers/features/git:1": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/github-cli:1": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "version": "latest" + } + }, + // Configure tool-specific properties + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.vscode-python-envs", + "redhat.vscode-yaml", + "GitHub.copilot", + "GitHub.copilot-chat", + "ms-azuretools.vscode-docker" + ], + "settings": { + "python.useEnvironmentsExtension": true + } + } + }, + // 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": "bash .devcontainer/post-create.sh", + // Use 'postStartCommand' to run commands when the container starts + "postAttachCommand": "bash .devcontainer/post-attach.sh", + // Environment variables + "containerEnv": { + "PYTHONUNBUFFERED": "1" + }, + // Set the user to use in the container (non-root) + "remoteUser": "vscode", + // Grant the container access to the host's Docker daemon + "runArgs": [ + "--init" + ] +} diff --git a/.devcontainer/post-attach.sh b/.devcontainer/post-attach.sh new file mode 100644 index 0000000..0fd307a --- /dev/null +++ b/.devcontainer/post-attach.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +# If running in Codespaces, check for necessary secrets and print error if missing +if [ -v CODESPACES ]; then + echo "🔐 Running in Codespaces - injecting secrets from Codespaces settings..." + if [ ! -v COPILOT_TOKEN ]; then + echo "⚠️ Running in Codespaces - please add COPILOT_TOKEN to your Codespaces secrets" + fi + if [ ! -v GITHUB_PERSONAL_ACCESS_TOKEN ]; then + echo "⚠️ Running in Codespaces - please add GITHUB_PERSONAL_ACCESS_TOKEN to your Codespaces secrets" + fi +fi + +echo "💡 Remember to activate the virtual environment: source .venv/bin/activate" diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100644 index 0000000..57d145f --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +echo "🚀 Setting up Seclab Taskflows development environment..." + +# Create Python virtual environment +echo "📦 Creating Python virtual environment..." +python3 -m venv .venv + +# Activate virtual environment and install dependencies +echo "📥 Installing Python dependencies..." +source .venv/bin/activate +python -m pip install --upgrade pip +python -m pip install hatch +hatch build + +# Install this package from local directory. +pip install -e . + +# Create logs directory if it doesn't exist +mkdir -p logs + +# Create optional data directories +mkdir -p data + +# Create .env file if it doesn't exist +if [ ! -f .env ]; then + echo "📝 Creating .env template..." + echo "# Optional: CodeQL database base path" >> .env + echo "CODEQL_DBS_BASE_PATH=$(realpath data)" >> .env + echo "⚠️ Please configure the environment or your .env file with required tokens!" +fi + +echo "✅ Development environment setup complete!"