Zreby's picture
Update labeled README for public dataset
0f6d522 verified
|
Raw History Blame Contribute Delete
5.18 kB

NIST SARD Juliet C/C++ 1.3 — local labeled subset

This directory contains a Colab-ready annotation of the existing 960-file pilot subset. The original source export remains unchanged. No Juliet source was compiled or executed. The files in this directory are published under labeled/ in the public Hugging Face dataset repository; the original source subset remains at the repository root.

Use the function-level data in Colab

juliet_functions_labeled.jsonl is the recommended supervised-learning table: each row is one extracted Juliet function, with label (good or bad) and code. Files with several functions contribute several rows; the function records are not statistically independent.

from datasets import load_dataset

ds = load_dataset("json", data_files="https://huggingface.co/datasets/Zreby/nist-c-cpp-security-samples/resolve/main/labeled/juliet_functions_labeled.jsonl", split="train")
print(ds[0]["label"], ds[0]["cwe_id"], ds[0]["split"]) 
train = ds.filter(lambda row: row["split"] == "train")
valid = ds.filter(lambda row: row["split"] == "validation")
test = ds.filter(lambda row: row["split"] == "test")

What was labeled—and what was not

Labels come from explicit Juliet function/class role names, not from the parent folder’s CWE. Terminal bad / _bad roles map to bad; terminal good, goodG2B, and goodB2G roles map to good. For C++ cases, a class name ending in one of those roles can label its action method. These are Juliet’s intended path labels, not a claim that a production program is exploitable or secure.

Partial helpers such as badSink, goodG2BSink, badSource, and goodB2GSource are not forced into a binary label: their function body alone may not determine the end-to-end path. In this pilot, 758 partial helper functions are left unlabeled, and 233 files have no confidently labeled function; see juliet_functions_review.jsonl and juliet_label_review.csv. The file-level export has file_label: null by design. file_label_summary (mixed, good_only_observed, bad_only_observed, or no_confident_function_label) is a descriptive summary only, not a training target.

The extractor is a lightweight source-text scanner, not a C/C++ AST or compiler. It handles ordinary Juliet function definitions and brace matching while ignoring comments and strings; unusual declarations may be missed. A reviewer should inspect unresolved cases before expanding the labeled set.

Leakage-safe split

The grouping unit is a Juliet case family: the archive path with /sNN/ removed, and the basename’s terminal flow-variant token (for example _11, _63b, _82_bad, or _82_goodG2B) removed. Extensions are ignored, so language variants stay together. Every file and extracted function in a family has one shared group_id and split. Groups are assigned separately within each CWE to approximate 70/15/15 file-level train/validation/test targets; a family is never split across partitions. Exact file counts can differ from targets because groups are indivisible. group_assignments.csv makes the assignment auditable.

Distribution by split

Split Files Good functions Bad functions Mixed files Files without confident labels
train 672 1562 341 317 171
validation 144 332 75 71 32
test 144 370 79 75 30

split_summary.csv also reports the same counts for each CWE and split. Function counts are counts of labeled function definitions, not unique files or real-world prevalence.

Files

  • juliet_functions_labeled.jsonl — function-level good/bad dataset recommended for Colab.
  • juliet_files_labeled.jsonl — original full source files plus group, split, observed function labels, and a non-target file summary.
  • juliet_functions_review.jsonl — function code for partial Juliet helpers intentionally left unlabeled.
  • juliet_label_review.csv — files with partial helper roles or no confidently labeled function.
  • group_assignments.csv — normalized case-family keys and their one-split assignments.
  • split_summary.csv — per-CWE and total file/function label counts by split.
  • manifest.json — source checksum, policies, counts, verification results, and output checksums.

Important limits

The pilot is a deterministic selection of the first 80 eligible source files per CWE in upstream ZIP order, not a random or representative sample. Juliet code is synthetic. Function identifiers and inline FLAW/FIX comments can reveal the label; remove or normalize those cues in a separate derived copy if evaluating a model, while retaining this provenance-preserving source. Do not compile, execute, or deploy the samples outside a properly isolated test environment.

Source: NIST SARD Juliet C/C++ 1.3. License/provenance notes: NIST acknowledgements and test suite descriptions.