mirror of
https://github.com/trailofbits/buttercup
synced 2026-06-21 14:11:39 +00:00
Build cscope image locally instead of pulling (#148)
* Add cscope as submodule * Use cscope submodule instead of docker image * Pass token to checkout private submodule in CI
This commit is contained in:
@@ -28,6 +28,9 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
persist-credentials: false
|
||||
token: ${{ secrets.GH_CLONE_REPO_PAT }}
|
||||
submodules: true
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
|
||||
@@ -45,6 +45,10 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
token: ${{ secrets.GH_CLONE_REPO_PAT }}
|
||||
submodules: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
@@ -67,6 +67,8 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
token: ${{ secrets.GH_CLONE_REPO_PAT }}
|
||||
submodules: true
|
||||
|
||||
- name: Set BUTTERCUP_NAMESPACE for PRs
|
||||
if: github.event_name == 'pull_request'
|
||||
|
||||
@@ -36,6 +36,8 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
token: ${{ secrets.GH_CLONE_REPO_PAT }}
|
||||
submodules: true
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v6
|
||||
@@ -49,8 +51,6 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y codequery just ripgrep git-lfs
|
||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
just download-cscope
|
||||
just install-cscope
|
||||
|
||||
- name: Prepare environment
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "external/aixcc-cscope"]
|
||||
path = external/aixcc-cscope
|
||||
url = https://github.com/trailofbits/aixcc-cscope.git
|
||||
|
||||
@@ -17,9 +17,6 @@ just lint-python-all # Format, lint, and type-check all components
|
||||
|
||||
# Example: lint the patcher component
|
||||
just lint-python patcher
|
||||
|
||||
# Download dependencies
|
||||
just download-cscope # Download cscope static analysis tools
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
## Dependencies
|
||||
|
||||
Clone the repo with `--recurse-submodules` as some dependencies are submodules.
|
||||
|
||||
Follow the install instructions for the required dependencies:
|
||||
|
||||
* [Docker install guide](https://docs.docker.com/engine/install/ubuntu/)
|
||||
|
||||
@@ -115,16 +115,6 @@ up() {
|
||||
FUZZER_BUILD_ARGS=""
|
||||
fi
|
||||
|
||||
if [ -n "$CSCOPE_IMAGE" ]; then
|
||||
PATCHER_BUILD_ARGS="--build-arg CSCOPE_IMAGE=$CSCOPE_IMAGE"
|
||||
SEED_GEN_BUILD_ARGS="--build-arg CSCOPE_IMAGE=$CSCOPE_IMAGE"
|
||||
PROGRAM_MODEL_BUILD_ARGS="--build-arg CSCOPE_IMAGE=$CSCOPE_IMAGE"
|
||||
else
|
||||
PATCHER_BUILD_ARGS=""
|
||||
SEED_GEN_BUILD_ARGS=""
|
||||
PROGRAM_MODEL_BUILD_ARGS=""
|
||||
fi
|
||||
|
||||
docker build $ORCHESTRATOR_BUILD_ARGS -f "$SCRIPT_DIR"/../orchestrator/Dockerfile -t localhost/orchestrator:latest "$SCRIPT_DIR"/..
|
||||
docker build $FUZZER_BUILD_ARGS -f "$SCRIPT_DIR"/../fuzzer/dockerfiles/runner_image.Dockerfile -t localhost/fuzzer:latest "$SCRIPT_DIR"/..
|
||||
docker build $SEED_GEN_BUILD_ARGS -f "$SCRIPT_DIR"/../seed-gen/Dockerfile -t localhost/seed-gen:latest "$SCRIPT_DIR"/..
|
||||
|
||||
@@ -86,4 +86,3 @@ export DOCKER_PAT="<your-docker-pat>"
|
||||
# Docker build arguments, useful for local deployment
|
||||
# By default these points to the aixcc-finals images
|
||||
# export FUZZER_BASE_IMAGE="gcr.io/oss-fuzz-base/base-runner"
|
||||
# export CSCOPE_IMAGE="ghcr.io/trailofbits/buttercup-cscope:main"
|
||||
|
||||
+1
Submodule external/aixcc-cscope added at d814aabe85
@@ -1,12 +1,5 @@
|
||||
download-cscope:
|
||||
mkdir -p cscope/
|
||||
docker pull ghcr.io/trailofbits/buttercup-cscope:main
|
||||
docker create --name temp-cscope ghcr.io/trailofbits/buttercup-cscope:main
|
||||
docker cp temp-cscope:/cscope cscope/
|
||||
docker rm temp-cscope
|
||||
|
||||
install-cscope:
|
||||
cd cscope/cscope/ && autoreconf -i -s && ./configure && make && sudo make install
|
||||
cd external/aixcc-cscope/ && autoreconf -i -s && ./configure && make && sudo make install
|
||||
|
||||
lint-python COMPONENT:
|
||||
cd {{ COMPONENT }} && uv sync --all-extras && uv run ruff format && uv run ruff check --fix && uv run mypy
|
||||
|
||||
+1
-4
@@ -1,7 +1,4 @@
|
||||
ARG BASE_IMAGE=ubuntu:24.04
|
||||
ARG CSCOPE_IMAGE=ghcr.io/aixcc-finals/buttercup-cscope:main
|
||||
|
||||
FROM $CSCOPE_IMAGE AS cscope-image
|
||||
|
||||
FROM $BASE_IMAGE AS python_base
|
||||
ARG PYTHON_VERSION=3.12
|
||||
@@ -51,8 +48,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
|
||||
|
||||
FROM runtime-base AS cscope-builder
|
||||
COPY --from=cscope-image /cscope /cscope
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y autoconf gcc make bison flex libncurses-dev
|
||||
COPY external/aixcc-cscope /cscope
|
||||
RUN cd /cscope && autoreconf -i -s && ./configure && make && make install
|
||||
|
||||
FROM runtime-base AS runtime
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
ARG BASE_IMAGE=ubuntu:24.04@sha256:f8b860e4f9036f2694571770da292642eebcc4c2ea0c70a1a9244c2a1d436cd9
|
||||
ARG CSCOPE_IMAGE=ghcr.io/aixcc-finals/buttercup-cscope:main
|
||||
|
||||
FROM $CSCOPE_IMAGE AS cscope-image
|
||||
|
||||
FROM $BASE_IMAGE AS base
|
||||
RUN apt-get update && apt-get install -y software-properties-common
|
||||
@@ -35,8 +32,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
uv sync --frozen --no-editable
|
||||
|
||||
FROM base AS cscope-builder
|
||||
COPY --from=cscope-image /cscope /cscope
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y autoconf gcc make bison flex libncurses-dev
|
||||
COPY external/aixcc-cscope /cscope
|
||||
RUN cd /cscope && autoreconf -i -s && ./configure && make && make install
|
||||
|
||||
FROM base AS runtime
|
||||
|
||||
@@ -4,19 +4,6 @@ Indexes a program's source code to be queried by `seed-gen` and `patcher`.
|
||||
|
||||
## Setup
|
||||
|
||||
Build the `cscope` docker image and push to `trailofbits`.
|
||||
|
||||
```shell
|
||||
git clone git@github.com:trailofbits/aixcc-cscope.git
|
||||
cd aixcc-cscope/
|
||||
git checkout buttercup
|
||||
|
||||
docker build -t aixcc-cscope -f aixcc.Dockerfile .
|
||||
docker tag aixcc-cscope ghcr.io/trailofbits/buttercup-cscope:main
|
||||
docker push ghcr.io/trailofbits/buttercup-cscope:main
|
||||
```
|
||||
|
||||
You should see the `buttercup-cscope` [package](https://github.com/orgs/trailofbits/packages)
|
||||
|
||||
## Development
|
||||
|
||||
|
||||
+1
-4
@@ -1,7 +1,4 @@
|
||||
ARG BASE_IMAGE=ubuntu:24.04
|
||||
ARG CSCOPE_IMAGE=ghcr.io/aixcc-finals/buttercup-cscope:main
|
||||
|
||||
FROM $CSCOPE_IMAGE AS cscope-image
|
||||
|
||||
FROM $BASE_IMAGE AS python_base
|
||||
ARG PYTHON_VERSION=3.12
|
||||
@@ -45,8 +42,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
||||
cd seed-gen && uv sync --frozen --no-editable
|
||||
|
||||
FROM runtime-base AS cscope-builder
|
||||
COPY --from=cscope-image /cscope /cscope
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y autoconf gcc make bison flex libncurses-dev
|
||||
COPY external/aixcc-cscope /cscope
|
||||
RUN cd /cscope && autoreconf -i -s && ./configure && make && make install
|
||||
|
||||
FROM runtime-base AS runtime
|
||||
|
||||
Reference in New Issue
Block a user