Files
trailofbits-buttercup/program-model
Riccardo Schirone e0b898a6b4 program-model: introduce codequery (#178)
* program-model/tree-sitter: refactor classes

* program-model/tree-sitter: change how paths are considered

This allows to parse also code in oss-fuzz (e.g. injected fuzz targets
not in upstream project)

* common: change name format for challenge commit

* program-model/codequery: make it persistent and nice

* program-model: disable janus & co for now

* patcher: make use of codequery instead of just tree-sitter

* program-model: add integration tests for codequery

* program-model/codequery: add support for different languages

* patcher: install codequery in patcher's container

* ci: fix codequery install

* program-model: ensure cqdb storage in /crs_scratch

* program-model: ensure the cqdb storage is available only at the end
2025-03-10 14:11:07 +01:00
..
2025-01-26 13:09:37 -05:00
2025-03-04 10:51:53 -05:00
2025-02-25 10:21:08 -05:00
2025-02-18 11:59:16 -05:00
2025-01-26 13:09:37 -05:00
2025-02-25 10:21:08 -05:00
2025-01-26 13:09:37 -05:00
2025-02-18 17:06:15 -05:00
2025-02-25 10:21:08 -05:00
2025-03-04 10:51:53 -05:00

Program Model

Indexes a program into a graph database.

Requirements

n2-highmem-8 instance.

sudo apt-get install -y codequery

Setup

Set up working directory and tasks directory.

cd afc-crs-trail-of-bits/

cp env.template .env

sudo mkdir /crs_scratch/ && sudo chown `whoami`:`whoami` /crs_scratch && sudo mount --bind ./crs_scratch /crs_scratch

sudo mkdir /tasks_storage && sudo chown `whoami`:`whoami` /tasks_storage && sudo mount --bind ./tasks_storage /tasks_storage

Set up Github token.

gh auth login
GitHub.com
SSH
No
Paste the authentication token

gh auth token | docker login ghcr.io -u USERNAME --password-stdin

Build the Kythe docker image and push to aixcc-finals. Create your own personal PAT, and give it write:packages permissions -- do not configure SSO for any organization. Log into ghcr.io like above.

git clone git@github.com:trailofbits/aixcc-kythe.git
cd aixcc-kythe/

# Takes roughly 70 minutes to build and 15 minutes to copy the .tar.gz file.
docker build -t aixcc-kythe -f aixcc.Dockerfile .
docker tag aixcc-kythe ghcr.io/aixcc-finals/buttercup-kythe:main
docker push ghcr.io/aixcc-finals/buttercup-kythe:main

You should see the buttercup-kythe package here.

Usage

Prepare example challenge project.

cd afc-crs-trail-of-bits/

./orchestrator/scripts/task_crs.sh

Start up CRS.

cd afc-crs-trail-of-bits/

docker compose up -d --build --remove-orphans

Send task to Program Model via Redis queue.

docker compose logs -f program-model
cd afc-crs-trail-of-bits/program-model/

uv run mock/trigger_pm.py \
  --build_type full \
  --package_name libpng \
  --sanitizer AddressSanitizer \
  --task_dir ../tasks_storage/5cea8f59-a7ab-4c77-97a9-f92fcfeb33d8 \
  --task_id libpng

API

See api.md.

Testing on Challenges

See challenges.md.

Development

Sync, reformat, lint, and test before committing changes to this directory:

just all

JanusGraph Indexing References

FAQs

  • Why does this use a ubuntu base image?
    • Since Kythe uses OSS Fuzz to build and index the challenge source code, we have to use the same base image as ClusterFuzz.
  • Why does this use Python 3.10?
    • ClusterFuzz uses Python 3.10.