| Source | Type | Labels |
|---|---|---|
| SARD (NIST) | C/C++ vulnerable functions | buffer_overflow, etc. |
| CVE Details | Multi-language real CVEs | All categories |
| OWASP WebGoat | JS/Java web vulns | sql_injection, xss |
| GitHub advisories | Python, JS | All categories |
| Synthetic (built-in) | All languages | All categories |
Each sample in data/raw/*.json must follow this schema:
{
"code": "cursor.execute('SELECT * FROM users WHERE id = ' + uid)",
"language": "python",
"labels": ["sql_injection"],
"source": "synthetic"
}code: raw source code string (any length; will be truncated tomax_seq_lengthtokens)language: one ofpython,javascript,cpp,c,typescriptlabels: list of label names from the taxonomy; empty list[]means safe/cleansource: origin of the sample (for provenance tracking)
# 1. Place raw JSON files in data/raw/
# 2. Run preprocessing to create train/val/test splits
python -m src.data_pipeline.dataset_builder
# Or via script:
bash scripts/preprocess.shOutputs:
data/processed/train.json— 80% of samplesdata/processed/val.json— 10% of samplesdata/processed/test.json— 10% of samples
If data/raw/ is empty, the dataset builder automatically generates 160 synthetic samples covering all 6 vulnerability types plus clean samples. This is enough to smoke-test the pipeline end-to-end, but not sufficient for a production-quality model — real labeled data is required for that.
Vulnerability datasets are typically imbalanced (far more clean samples than vulnerable ones). Strategies implemented or planned:
- Oversampling: repeat minority-class samples in training
- Loss weighting:
BCEWithLogitsLoss(pos_weight=...)in the trainer - Threshold tuning: choose per-label thresholds on the validation set to maximize F1