This document is the handoff guide for completing the Gemini fine-tuning pipeline on a Mac (or any Linux-based machine). Windows was blocked by Defender flagging exploit-demo repos in the CredData dataset.
| File | Status | Notes |
|---|---|---|
agents/secret-detector-agent.md |
✅ Created | Output schema, types, severities, ignore rules |
.gitignore |
✅ Updated | /data/ is now gitignored — protects training data |
data/creddata/ |
✅ Cloned | Samsung/CredData repo is cloned (metadata only, no source files yet) |
data/creddata/download_win.py |
✅ Created | Windows-compatible downloader (not needed on Mac) |
- [Mac] Download the CredData source files via the original script
- [Mac] Inspect a few real examples to sanity-check (spot check only — no printing full secret values)
- Write
data/build_dataset.py - Write
data/validate_dataset.py - Write
scripts/upload_to_gcs.py - Write
scripts/launch_tuning.py - Write
scripts/test_tuned_model.py - Write
data/README.md+requirements.txt
# Python 3.10+ required (3.10 is recommended by CredData)
python3 --version
# Install CredData deps
cd data/creddata
pip install GitPython tabulate pybase62 colorama
# Run the download — clones 333 repos, takes 20-60 min depending on connection
# tmp/ can be deleted after it finishes
python3 download_data.py
# When it completes, data/creddata/data/ will exist with source files
# tmp/ can then be deleted to reclaim disk space
rm -rf tmp/The
data/directory is gitignored. Never commit anything inside it.
The Windows machine partially downloaded some repos into data/creddata/tmp/.
Before running the Mac download, delete that directory:
cd data/creddata
rm -rf tmp/If tmp/ does not exist after pulling from git (it is gitignored), skip this step.
This script converts CredData into Gemini supervised-tuning JSONL.
One training example = one FILE (not one line).
Target file extensions only: .js, .ts, .py, .json, .yml, .yaml
(these cover ~4,575 TRUE credential lines in the dataset)
Ground truth mapping:
T= True credential → becomes a finding in the model turnFandX= False/unknown → excluded from findings (file becomes a clean negative example)
match_redacted format: first 4 characters of the secret value + ****
Extract using ValueStart and ValueEnd columns from the meta CSV.
Never log or print the full secret value.
Category → agent type + severity mapping (confirmed):
| CredData Category (partial match) | type | severity |
|---|---|---|
PEM Private Key, BASE64 Private Key, BASE64 encoded PEM Private Key, NKEY Seed, JWK |
PRIVATE_KEY |
CRITICAL |
AWS Client ID, AWS Multi, AWS S3 Bucket |
CLOUD_ACCESS_KEY |
CRITICAL |
Google API Key, Google Multi, Azure Access Token, Tencent WeChat API App ID, Akamai Credentials, Dropbox App secret, Salesforce Credentials |
CLOUD_CREDENTIAL |
HIGH |
Key, API, MailGun API Key, Grafana Provisioned API Key, Twilio Credentials |
API_KEY |
HIGH |
Token, Slack Token, Bearer Authorization, JSON Web Token, CMD Token, Basic Authorization |
TOKEN |
HIGH |
Password, SQL Password, CMD Password, CURL User Password, CMD ConvertTo-SecureString |
PASSWORD |
HIGH |
URL Credentials |
CONNECTION_STRING |
HIGH |
Auth, Secret, Credential |
API_KEY |
HIGH |
OTP / 2FA Secret, Firebase Domain |
OTHER_CREDENTIAL |
MEDIUM |
Nonce, Salt, UUID |
OTHER_CREDENTIAL |
LOW |
For compound categories (e.g. Auth:Secret, Key:Secret):
take the highest-severity constituent. So Key:Secret → API_KEY / HIGH.
Split: 90% train / 10% validation.
Dedup so files from the same source repo (RepoName column) don't straddle
train and validation (prevents data leakage).
Balance: keep all clean-negative examples — don't drop them. They are the important hard negatives that teach the model NOT to hallucinate.
Each JSONL line is one training example. Vertex AI supervised-tuning format:
{
"contents": [
{
"role": "user",
"parts": [{ "text": "File: path/to/file.py\n\n<file contents here>" }]
},
{
"role": "model",
"parts": [{ "text": "{\"findings\": [...], \"summary\": {...}}" }]
}
]
}The model turn is a JSON string (the detector output), serialized as a single string
inside parts[0].text. It must be valid JSON matching the schema in
agents/secret-detector-agent.md.
Asserts every JSONL line:
- Is valid JSON
- Has
contentswith two turns (user + model) - The model turn text is itself valid JSON
- The JSON matches the detector schema (findings array + summary object)
Reports:
- Total examples
- With-findings vs empty-findings count
- Per-type breakdown
- Any lines that fail validation
Uploads data/train.jsonl and data/validation.jsonl to a private GCS bucket.
GCP project: bugtrap-prod
Region: us-central1
Bucket name: set via env var GCS_TRAINING_BUCKET (e.g. bugtrap-sft-data)
The bucket must be private. The script should create it if it doesn't exist, with uniform bucket-level access and no public ACLs.
Auth: Application Default Credentials (gcloud auth application-default login).
Launches a Vertex AI Gemini supervised-tuning job.
Before writing this script, look up the current Vertex AI tuning API:
- Base model to tune:
gemini-2.0-flash-lite(or the current smallest tuneable Gemini) - Check the current tuneable model names at: https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini-supervised-tuning
- The JSONL schema for Vertex tuning may have changed — verify it matches what
build_dataset.pyproduces before launching
The script should print the tuning job name/ID and a gcloud command to monitor it.
After the tuning job completes, point the script at the tuned endpoint and run a few held-out files (not in training) through it. Print the JSON output for manual quality review.
Tuned endpoint will be set via env var TUNED_MODEL_SECURITY in .env.local.
Pinned deps needed:
google-cloud-aiplatform>=1.60.0
google-cloud-storage>=2.14.0
data/is gitignored. Never commit anything inside it.- Never print a full secret value to the console or logs.
Use
match_redacted= first 4 chars +****. - The GCS bucket holding training data must be private.
- Do not store real credential values in training JSONL — CredData's
obfuscate_credsstep replaces them with random strings before the files land indata/creddata/data/. Build on those obfuscated files.
bugtrap/
├── agents/
│ └── secret-detector-agent.md ← output schema spec (READ THIS FIRST)
├── data/ ← gitignored; create this on the Mac
│ ├── creddata/ ← cloned from Samsung/CredData
│ │ ├── meta/ ← 333 CSV files, already present
│ │ ├── download_data.py ← original Linux/Mac download script
│ │ ├── download_win.py ← Windows-only workaround, ignore on Mac
│ │ └── data/ ← created by download_data.py (not present yet)
│ ├── train.jsonl ← created by build_dataset.py
│ └── validation.jsonl ← created by build_dataset.py
├── scripts/
│ ├── upload_to_gcs.py ← to be written
│ ├── launch_tuning.py ← to be written
│ └── test_tuned_model.py ← to be written
└── TRAINING_HANDOFF.md ← this file
- Project ID:
bugtrap-prod - Region:
us-central1 - Auth: ADC — run
gcloud auth application-default loginbefore any script - GCS bucket env var:
GCS_TRAINING_BUCKET
Paste this at the start of the session:
I'm picking up a BugTrap training pipeline from a Windows machine. Read TRAINING_HANDOFF.md first, then read agents/secret-detector-agent.md. The CredData download (Step 1) needs to run first — run it, then write all the scripts listed in the handoff doc (Steps 3–8) in order. Follow the security rules: never print full secret values, keep data/ gitignored, bucket must be private.