Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and two reports are only comparable when it matches or the difference is known.

## Unreleased

- `docs/COMPATIBILITY.md` states what stays the same from one version to the next: the commands, flags and exit codes, the report format, the scoring and the GitHub Action's inputs and outputs. `tests/test_compatibility.py` checks each of those. `verify`, `submit` and `benchmark` are marked experimental in their help text.
- Reports now record `agentsec_version`, the version that wrote and scored them, beside the probe's `probe_version`. `--baseline` and `agentsec history` note when it differs, as they already did for the probe. JSON Schemas for the blast-radius report and the `assert` result ship in `agentsec/data/`.
- `agentsec --version` prints the package and probe versions.
- The README said a probe version difference fails `--baseline`. It fails only when a finding is new or more severe, which is what the gate has always done, and a version difference with nothing worse passes with a note. The README and the note now say so.
- The README's GitHub Action example pins `@v0.4.0`, the latest release, instead of `@v0.2.0`.
- The README opens with a 63-second explainer video: what the probe measures, the `python:3.12-slim` hardening scores, the Antigravity CLI 1.5.2 and `srt` 0.0.81 measurements, and the Harbor grader control task, with each figure taken from a report in `examples/`.
- Antigravity CLI 1.5.2 measured, with writes and proxy traffic tested for real by `scripts/check_sandbox_boundaries.py`. Under `--sandbox`, `--dangerously-skip-permissions` now leaves the home directory, its shell startup files and the project writable and scores 100, and the 1.5.1 proxy still accepts tunnels to any hostname. With `proceed-in-sandbox` the score stays 31 and the working directory stays read-only, while files written to the build caches it leaves writable, including `~/.cargo/bin`, persist on the host. `measure_stubbed_agent.py` gains `--script` to run a check in place of the probe.
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ agentsec diff reports/accepted.json reports/latest.json # when measuring and
agentsec history reports/latest.json --save reports/history.jsonl # keep a line per run and show the trend
```

Both `--baseline` and `agentsec diff` exit with code 2 and list each finding that is new or rises in severity. The check also lists and fails on any existing finding whose evidence widens by one additional writable path, reachable host, or readable credential. Disappearing findings are marked as fixed alongside a prompt to record a fresh baseline, so the gate retains the improvement. New informational findings scored at 0 points appear as noted and let the check pass, unless the finding reports an unmeasured axis. Mismatched probe versions across the two runs make the tool report the difference and fail, because an added check can produce a new finding in an unchanged sandbox. Record the baseline with the same `--redact` setting that you use on the runs you compare against it.
Both `--baseline` and `agentsec diff` exit with code 2 and list each finding that is new or rises in severity. The check also lists and fails on any existing finding whose evidence widens by one additional writable path, reachable host, or readable credential. Disappearing findings are marked as fixed alongside a prompt to record a fresh baseline, so the gate retains the improvement. New informational findings scored at 0 points appear as noted and let the check pass, unless the finding reports an unmeasured axis. When the two runs used different probe versions, or were scored by different versions of agentsec, the tool reports the difference. A new or more severe finding still fails, because an added check or a rescored finding can appear in an unchanged sandbox, while a version difference with nothing worse passes. Record the baseline with the same `--redact` setting that you use on the runs you compare against it.

`agentsec history` tracks one sandbox's score and findings across runs with the `--baseline` comparison, so new findings or reachable credentials surface at the run that introduced them, even under budget. Runs sharing a label overwrite the previous report, so `--save` writes one line per run to a history file. That history file stores whatever each finding reached solely as hashes, which allows committing it without including any names. This command never fails a build because the `--max-score` and `--baseline` flags serve as the build gates in CI.

Expand Down Expand Up @@ -289,6 +289,8 @@ Filesystem checks confirm that a file is readable by opening it and reading zero

The list below shows what is built and what is still open. [`docs/ROADMAP.md`](docs/ROADMAP.md) gives the prioritized plan and what each open item needs.

[`docs/COMPATIBILITY.md`](docs/COMPATIBILITY.md) says what stays the same from one version to the next: the commands, flags and exit codes, the report format, the scoring and the GitHub Action's inputs. `agentsec verify`, `agentsec submit` and `agentsec benchmark` are experimental and outside that promise. `agentsec --version` prints the package and probe versions.

- [x] blast-radius probe, runner (docker / podman / local / command template), scorer, JSON + Markdown reports
- [x] ten launcher presets, `matrix` comparison table, `--max-score` CI gate, recommended-flag output, image digests
- [x] promptfoo integration: containment assertion, `combine` report, OWASP category overlap
Expand Down
20 changes: 16 additions & 4 deletions agentsec/baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
reminder to re-baseline so the gate keeps the ground that was gained.

Changing the instrument is not the sandbox changing. When the two runs used
different probe versions, a new finding may be a new check rather than a looser
sandbox; the gate still fails, because it cannot tell which, and says so.
different probe versions, or were scored by different agentsec versions, a new or
more severe finding may come from the instrument rather than a looser sandbox.
The gate still fails on that finding, because it cannot tell which, and says so.
A version difference with nothing worse passes, with a note.
"""
from __future__ import annotations

Expand Down Expand Up @@ -93,10 +95,14 @@ def compare(baseline: dict, current: dict) -> dict[str, Any]:
redacted = [((e.get("probe") or {}).get("identity") or {}).get("hostname") == "<redacted>" for e in (baseline, current)]
pv_old = (baseline.get("probe") or {}).get("probe_version")
pv_new = (current.get("probe") or {}).get("probe_version")
# Reports written before agentsec_version existed carry none; that is not a change.
av_old, av_new = baseline.get("agentsec_version"), current.get("agentsec_version")
return {"regressions": regressions, "fixed": fixed, "noted": noted,
"score": {"baseline": baseline["summary"]["score"], "current": current["summary"]["score"]},
"probe_versions": {"baseline": pv_old, "current": pv_new},
"instrument_changed": pv_old != pv_new,
"agentsec_versions": {"baseline": av_old, "current": av_new},
"scorer_changed": bool(av_old and av_new and av_old != av_new),
"redaction_differs": redacted[0] != redacted[1]}


Expand All @@ -121,8 +127,14 @@ def render(result: dict[str, Any], baseline_label: str = "baseline") -> str:
if result["instrument_changed"]:
pv = result["probe_versions"]
lines.append(f" note: baseline was taken with probe {pv['baseline']}, this run with {pv['current']}. "
"A new finding may be a new check rather than a looser sandbox; the gate cannot tell which, "
"so it still fails. Re-baseline deliberately once you have read the difference.")
"A new finding may be a new check rather than a looser sandbox. The gate cannot tell which, "
"so any new or more severe finding still fails it. Re-baseline deliberately once you have "
"read the difference.")
if result.get("scorer_changed"):
av = result["agentsec_versions"]
lines.append(f" note: baseline was scored by agentsec {av['baseline']}, this run by {av['current']}. "
"A change in a finding's severity may come from the newer version rather than the sandbox. "
"The gate still fails on it. Re-baseline deliberately once you have read the difference.")
if result.get("redaction_differs"):
lines.append(" note: one report is redacted and the other is not, so variable names cannot match. "
"Gate a run against a baseline taken with the same --redact setting.")
Expand Down
14 changes: 8 additions & 6 deletions agentsec/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""
from __future__ import annotations

from agentsec import __version__
import argparse
import json
import os
Expand Down Expand Up @@ -149,7 +150,7 @@ def cmd_matrix(args: argparse.Namespace) -> int:
print("no presets could run here", file=sys.stderr)
return 1
digest = next((r["target"].get("digest") for r in runs if r["target"].get("digest")), None)
env = {"tool": "agentsec-pack", "test": "sandbox-blast-radius-matrix", "schema_version": 1,
env = {"tool": "agentsec-pack", "test": "sandbox-blast-radius-matrix", "schema_version": 1, "agentsec_version": __version__,
"image": args.image, "digest": digest, "probe_version": runs[0]["summary"] and runner._probe_version(),
"generated_at": int(time.time()), "generated_at_iso": time.strftime("%Y-%m-%d", time.gmtime()),
"runs": runs, "skipped": skipped}
Expand Down Expand Up @@ -248,7 +249,7 @@ def cmd_score(args: argparse.Namespace) -> int:
if note:
print(f"note: {note}", file=sys.stderr)
summary = summarize(probe)
env = {"tool": "agentsec-pack", "test": "sandbox-blast-radius", "schema_version": 1, "label": args.label,
env = {"tool": "agentsec-pack", "test": "sandbox-blast-radius", "schema_version": 1, "agentsec_version": __version__, "label": args.label,
"generated_at": int(time.time()),
"target": {"kind": "captured", "label": args.label, "how": args.how,
"note": "Captured externally: the probe was run inside the target by the means described in `how`, not launched by agentsec."},
Expand Down Expand Up @@ -503,13 +504,14 @@ def cmd_assert(args: argparse.Namespace) -> int:
if args.out:
os.makedirs(os.path.dirname(os.path.abspath(args.out)) or ".", exist_ok=True)
with open(args.out, "w") as f:
json.dump({"tool": "agentsec-pack", "test": "path-assertions", "schema_version": 1,
json.dump({"tool": "agentsec-pack", "test": "path-assertions", "schema_version": 1, "agentsec_version": __version__,
"generated_at": int(time.time()), "target": target, **outcome}, f, indent=2, sort_keys=True)
return 2 if outcome["failed"] else 0


def main(argv: list[str] | None = None) -> int:
ap = argparse.ArgumentParser(prog="agentsec", description="Adversarial tests for AI agent deployments.")
ap.add_argument("--version", action="version", version=f"agentsec-pack {__version__}, probe {runner._probe_version()}")
sub = ap.add_subparsers(dest="cmd", required=True)

p = sub.add_parser("presets", help="list named sandbox configurations")
Expand Down Expand Up @@ -622,7 +624,7 @@ def main(argv: list[str] | None = None) -> int:
d.add_argument("current", help="the report JSON to check")
d.set_defaults(func=cmd_diff)

sb = sub.add_parser("submit", help="prepare one measurement for a public dataset, shown to you first, for you to post")
sb = sub.add_parser("submit", help="(experimental) prepare one measurement for a public dataset, shown to you first, for you to post")
sb.add_argument("report", help="the report JSON")
sb.add_argument("--to", default=DATASET, metavar="OWNER/REPO", help=f"the public dataset repository to open the issue in (default: {DATASET})")
sb.add_argument("--agent", required=True, help="the agent's name")
Expand All @@ -632,7 +634,7 @@ def main(argv: list[str] | None = None) -> int:
sb.add_argument("--no-browser", action="store_true", help="print the address instead of opening it")
sb.set_defaults(func=cmd_submit)

bm = sub.add_parser("benchmark", help="published figures from submitted measurements: a median, and only past a threshold of different accounts")
bm = sub.add_parser("benchmark", help="(experimental) published figures from submitted measurements: a median, and only past a threshold of different accounts")
bm.add_argument("--issues", required=True, metavar="FILE", help="the output of gh issue list --json author,body,createdAt,labels")
bm.add_argument("--reproduced", metavar="FILE", help="results reproduced by the maintainer or a known harness, shown apart: JSON Lines of record and source")
bm.add_argument("--min-submitters", type=int, default=5, metavar="N", help="different accounts a configuration needs before it appears (default: 5, lowest: 3)")
Expand All @@ -647,7 +649,7 @@ def main(argv: list[str] | None = None) -> int:
hi.add_argument("--json", action="store_true", help="print JSON instead of Markdown")
hi.set_defaults(func=cmd_history)

v = sub.add_parser("verify", help="did a change pass its tests, or did it change the tests? (exit 2 if not shown to pass)")
v = sub.add_parser("verify", help="(experimental) did a change pass its tests, or did it change the tests? (exit 2 if not shown to pass)")
v.add_argument("--base", required=True, help="the commit before the change")
v.add_argument("--head", required=True, help="the commit to check")
v.add_argument("--test-cmd", required=True, help="the test command, run with sh -c from the root of each tree")
Expand Down
82 changes: 82 additions & 0 deletions agentsec/data/blast-radius-report.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/binary-knight/agentsec-pack/blob/main/agentsec/data/blast-radius-report.schema.json",
"title": "agentsec blast-radius report, schema_version 1",
"description": "Written by agentsec probe, blast-radius, score and ui. Fields may be added without changing schema_version; removing, renaming or retyping one changes it. The probe block belongs to the probe and is versioned by probe_version.",
"type": "object",
"required": ["tool", "test", "schema_version", "label", "generated_at", "target", "rc", "summary", "probe", "probe_stderr"],
"properties": {
"tool": {"const": "agentsec-pack"},
"test": {"const": "sandbox-blast-radius"},
"schema_version": {"const": 1},
"agentsec_version": {"type": "string", "description": "The agentsec-pack version that wrote and scored the report. Absent from reports written before 0.5.0."},
"label": {"type": ["string", "null"]},
"generated_at": {"type": "integer", "description": "Unix time, seconds."},
"target": {"$ref": "#/$defs/target"},
"rc": {"type": "integer", "description": "Exit code of the process that ran the probe."},
"summary": {"$ref": "#/$defs/summary"},
"probe": {
"type": "object",
"required": ["probe_version"],
"properties": {"probe_version": {"type": "string"}}
},
"probe_stderr": {"type": "string"}
},
"$defs": {
"target": {
"type": "object",
"required": ["kind"],
"properties": {
"kind": {"enum": ["local", "self", "container", "command", "captured"]},
"label": {"type": ["string", "null"]},
"how": {"type": ["string", "null"]},
"note": {"type": "string"},
"python": {"type": "string"},
"proxy_auth": {"type": "boolean"},
"engine": {"type": "string"},
"image": {"type": "string"},
"digest": {"type": ["string", "null"]},
"flags": {"type": "array", "items": {"type": "string"}},
"preset": {"type": "string"},
"preset_rationale": {"type": "string"},
"template": {"type": "string"},
"command": {"type": ["string", "array"]}
}
},
"summary": {
"type": "object",
"required": ["score", "raw_score", "finding_count", "by_severity", "recommended_flags", "findings"],
"properties": {
"score": {"type": "integer", "minimum": 0, "maximum": 100, "description": "raw_score capped at 100."},
"raw_score": {"type": "integer", "minimum": 0, "description": "Sum of finding weights: critical 25, high 15, medium 8, low 3, info 0."},
"finding_count": {"type": "integer", "minimum": 0},
"by_severity": {
"type": "object",
"required": ["critical", "high", "medium", "low", "info"],
"properties": {
"critical": {"type": "integer", "minimum": 0},
"high": {"type": "integer", "minimum": 0},
"medium": {"type": "integer", "minimum": 0},
"low": {"type": "integer", "minimum": 0},
"info": {"type": "integer", "minimum": 0}
}
},
"recommended_flags": {"type": "array", "items": {"type": "string"}},
"findings": {"type": "array", "items": {"$ref": "#/$defs/finding"}}
}
},
"finding": {
"type": "object",
"required": ["id", "title", "severity", "category", "evidence", "owasp", "remediation"],
"properties": {
"id": {"type": "string", "pattern": "^(NET|SEC|FS|PRIV|PROC|RES)-[0-9]{3}$"},
"title": {"type": "string"},
"severity": {"enum": ["critical", "high", "medium", "low", "info"]},
"category": {"enum": ["network", "secrets", "filesystem", "privilege", "process", "resources"]},
"evidence": {"type": "object"},
"owasp": {"type": "array", "items": {"type": "string"}},
"remediation": {"type": "string"}
}
}
}
}
35 changes: 35 additions & 0 deletions agentsec/data/path-assertions.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/binary-knight/agentsec-pack/blob/main/agentsec/data/path-assertions.schema.json",
"title": "agentsec assert result, schema_version 1",
"description": "Written by agentsec assert --out. Fields may be added without changing schema_version; removing, renaming or retyping one changes it.",
"type": "object",
"required": ["tool", "test", "schema_version", "generated_at", "target", "rows", "failed", "total"],
"properties": {
"tool": {"const": "agentsec-pack"},
"test": {"const": "path-assertions"},
"schema_version": {"const": 1},
"agentsec_version": {"type": "string", "description": "The agentsec-pack version that wrote the result. Absent from results written before 0.5.0."},
"generated_at": {"type": "integer", "description": "Unix time, seconds."},
"target": {
"type": "object",
"required": ["kind"],
"properties": {"kind": {"type": "string"}, "command": {"type": "string"}}
},
"rows": {
"type": "array",
"items": {
"type": "object",
"required": ["kind", "path", "ok", "observed"],
"properties": {
"kind": {"enum": ["readable", "not-readable", "writable", "not-writable", "exists", "not-exists"]},
"path": {"type": "string"},
"ok": {"type": "boolean"},
"observed": {"type": "string", "description": "What the probe saw, such as absent or present, denied."}
}
}
},
"failed": {"type": "integer", "minimum": 0},
"total": {"type": "integer", "minimum": 0}
}
}
Loading
Loading