Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/anthropics/defending-code-reference-harness
/ functions
Functions
364 in github.com/anthropics/defending-code-reference-harness
⨍
Functions
364
◇
Types & classes
9
↓ 35 callers
Function
parse_xml_tag
Extract content of <tag>...</tag>. DOTALL so multiline ASAN traces work. Not a real XML parser — tags are markers in prose, not well-formed XML.
harness/agent.py:139
↓ 21 callers
Function
color
Wrap ``text`` in ANSI color ``name`` if ``stream`` is a TTY. dim — low-signal progress lines (tool calls) red — a crash landed bold — v
harness/agent.py:53
↓ 18 callers
Function
build_find_prompt
( github_url: str, commit: str, source_root: str, binary_path: str, focus_area: str | None
harness/prompts/find_prompt.py:307
↓ 17 callers
Function
sanitize_untrusted
Neutralize anything that could close an <untrusted_data> block early.
harness/prompts/untrusted.py:25
↓ 16 callers
Function
dedup
Group crashes under results_root by signature. Returns {(crash_type, top_frame): [(result_json_path, status, reason), ...]} where reason is t
harness/dedup.py:36
↓ 14 callers
Method
find_tagged_message
Return the most-recent assistant message text containing <tag>. Agents emit structured tags, then often a short final "Done!" message.
harness/agent.py:160
↓ 14 callers
Function
grade_patch
Grade a candidate patch against a verified crash. Spins a fresh container, applies the diff, walks the ladder. Short-circuits on the first fa
harness/patch_grade.py:37
↓ 12 callers
Function
crash_reason
crash_type + READ/WRITE operation parsed from sanitizer output. Display-only: feeds found_bugs.jsonl excerpts and dedup summary. Not a decisi
harness/asan.py:69
↓ 11 callers
Function
_asst
(text: str)
tests/test_xml_parse.py:72
↓ 11 callers
Function
project_frames
Top-N frames from the crash stack that have project source info. Walks frames in order; collects those with a file:line source location (skip
harness/asan.py:23
↓ 11 callers
Function
top_frame
First project-source frame from the crash stack (convenience wrapper).
harness/asan.py:56
↓ 10 callers
Function
_exec_sequence
Mock for docker_ops.exec_sh that returns a fixed sequence of (rc,out,err).
tests/test_patch_grade.py:152
↓ 10 callers
Function
_nonces
(prompt: str)
tests/test_untrusted.py:31
↓ 9 callers
Function
_bare_close_tags
Closing tags that do not carry the nonce id attribute.
tests/test_untrusted.py:26
↓ 9 callers
Function
_f
(tmp_path, content)
tests/test_skill_checkpoint.py:27
↓ 9 callers
Function
_write_result
(path, status, crash_type=None, crash_output=None)
tests/test_dedup.py:62
↓ 9 callers
Function
make_nonce
Per-prompt random delimiter id for <untrusted_data> blocks.
harness/prompts/untrusted.py:20
↓ 9 callers
Function
run_agent
Run a Claude Code agent session via headless CLI inside ``container``. Invokes ``docker exec <container> claude -p --output-format stream-json``
harness/agent.py:198
↓ 8 callers
Function
_build_tree
3 crashes on signature A, 1 on B, plus a no-crash and a rejected-on-A.
tests/test_dedup.py:81
↓ 8 callers
Function
_resolve_auth_env
Resolve auth for the in-container `claude -p` process. Returns the env dict set on the agent container at ``docker run`` time, or None if no auth
harness/cli.py:66
↓ 8 callers
Method
from_dict
(cls, d: dict[str, Any])
harness/artifacts.py:175
↓ 7 callers
Function
_done
(result: RunResult)
harness/cli.py:241
↓ 7 callers
Function
_parse_judge
(text: str)
harness/judge.py:73
↓ 7 callers
Function
_parse_score_tag
(text: str, tag: str, allowed: tuple[int, ...])
harness/report.py:167
↓ 7 callers
Function
_signature
(crash: dict)
harness/dedup.py:29
↓ 7 callers
Function
_user
(text: str)
tests/test_xml_parse.py:77
↓ 7 callers
Function
build_system_prompt
Full system prompt: fixed pipeline preamble + engagement block. --engagement-context overrides only the engagement block; the preamble's sand
harness/prompts/system_prompt.py:53
↓ 7 callers
Function
format_report
(groups: dict[tuple[str, str], list[tuple[Path, str, dict]]], root: Path | None = None)
harness/dedup.py:60
↓ 7 callers
Method
to_dict
(self)
harness/artifacts.py:162
↓ 6 callers
Function
_assigned_focus
(i: int, focus_areas: list[str])
harness/cli.py:560
↓ 6 callers
Function
_blocks_to_text
Extract plain text from a content-block list. stream-json content is list[{"type":"text","text":...} | {"type":"tool_use",...} | ...]. We onl
harness/agent.py:71
↓ 6 callers
Function
_clip
(s: str)
harness/patch_grade.py:309
↓ 6 callers
Function
_load_run_checkpoint
Return a prior run's result if it reached a terminal status. agent_failed / build_failed / error are NOT terminal — resume retries them. Tran
harness/cli.py:159
↓ 6 callers
Function
_mk_result
(tmp_path, name, status, score, poc_len)
tests/test_report.py:132
↓ 6 callers
Function
_parse_token
(text: str, tag: str, tokens: tuple[str, ...], default: str)
harness/report.py:176
↓ 6 callers
Function
_read_found_summaries
(path: Path)
harness/cli.py:590
↓ 6 callers
Function
_sh
(cmd: str, **kw)
tests/test_agent_sandbox.py:33
↓ 6 callers
Function
_verdict
(t0, t1, t2, ra, t3, evidence, timings)
harness/patch_grade.py:297
↓ 6 callers
Function
_write
(path, d)
tests/test_checkpoint.py:14
↓ 6 callers
Function
asan_excerpt
SUMMARY line + first N stack frames, for dedup context. ~500 bytes per excerpt — enough for a find- or judge-agent to compare signatures sema
harness/asan.py:86
↓ 6 callers
Function
build_report_prompt
( github_url: str, commit: str, source_root: str, binary_path: str, reproduction_command:
harness/prompts/report_prompt.py:183
↓ 6 callers
Function
crash_file_from_frame
Extract the file path from a top_frame string like `func /path/file.h:1234`.
harness/novelty.py:91
↓ 5 callers
Function
_agent_emitting
(text: str)
tests/test_patch.py:18
↓ 5 callers
Function
_append_found
(path: Path, crash: CrashArtifact, run_idx: int)
harness/cli.py:577
↓ 5 callers
Function
_load_report_checkpoint
Return prior report.json if it landed with status report_submitted AND its signature matches. agent_failed / no_report are retried. A signature
harness/cli.py:1181
↓ 5 callers
Function
_pick_representative
Pick the best result.json from a dedup group for the report agent. Prefer passed-grade > rejected, then highest grade score, then smallest PoC
harness/cli.py:1080
↓ 5 callers
Function
_t1_passes
(rc: int, stdout: str, stderr: str)
harness/patch_grade.py:244
↓ 5 callers
Function
_write_result
(out_dir: Path, result: RunResult)
harness/cli.py:193
↓ 5 callers
Function
build_judge_prompt
manifest_entries: [{"bug_id", "run_idx", "asan_excerpt", "report_text" or None}, ...]
harness/prompts/judge_prompt.py:113
↓ 5 callers
Method
load
(cls, target_dir: str | Path)
harness/config.py:40
↓ 5 callers
Function
run_patch
Generate and verify a patch for a crash. Returns (diff_bytes, verdict, agent_result). diff_bytes is None if the agent never emitted a readabl
harness/patch.py:30
↓ 4 callers
Function
_append_manifest
(reports_root: Path, bug_id: int, run_idx: int, excerpt: str)
harness/cli.py:641
↓ 4 callers
Function
_judged_runs
run_idx values that already passed through _stream_dispatch — the idempotence key for --resume --stream replay (one judge_log line per run, in
harness/cli.py:447
↓ 4 callers
Function
_kwargs
(**over)
tests/test_report.py:87
↓ 4 callers
Function
_mk_crash
(crash_type="heap-buffer-overflow", crash_output=ASAN_TRACE)
tests/test_found_bugs.py:158
↓ 4 callers
Function
_parse_grader
(text: str, novelty_checked: bool)
harness/report.py:144
↓ 4 callers
Function
_read_manifest
Manifest entries with existing report text attached if it's landed.
harness/cli.py:609
↓ 4 callers
Function
_write_report_json
(out_dir: Path, d: dict)
harness/cli.py:1176
↓ 4 callers
Function
agent_tag
Distinct agent-image tag per *full* target tag, so a committed ``<name>:patched-<uuid>`` snapshot doesn't collide with ``<name>:v1``.
harness/agent_image.py:27
↓ 4 callers
Function
runtime
()
harness/sandbox.py:27
↓ 3 callers
Function
_capture_run
(monkeypatch)
tests/test_sandbox.py:67
↓ 3 callers
Function
_failed_tier
(v: PatchVerdict)
harness/patch.py:174
↓ 3 callers
Function
_grade
(diff_path: str)
tests/test_patch_grade_e2e.py:56
↓ 3 callers
Function
_has_passed
(entries)
harness/cli.py:1222
↓ 3 callers
Function
_next_bug_id
(entries: list[dict])
harness/cli.py:635
↓ 3 callers
Function
build_compare_prompt
(report_a: str, report_b: str)
harness/prompts/judge_prompt.py:206
↓ 3 callers
Function
load_engagement_context
Return the engagement-context block. Falls back to DEFAULT if path is None or the file is missing/empty.
harness/prompts/system_prompt.py:41
↓ 3 callers
Function
untrusted_block
Wrap attacker-influenced text in nonce-delimited isolation tags.
harness/prompts/untrusted.py:30
↓ 2 callers
Function
_build
(dockerfile: str, tag: str)
harness/agent_image.py:33
↓ 2 callers
Function
_checkpointed
(i: int)
harness/cli.py:744
↓ 2 callers
Function
_dispatch
()
harness/cli.py:1265
↓ 2 callers
Function
_log_judge
(reports_root: Path, run_idx: int, jv, bug_id: int | None)
harness/cli.py:438
↓ 2 callers
Function
_patch_prompt
(report_text=None, retry_evidence=None)
tests/test_untrusted.py:53
↓ 2 callers
Function
_resolve_target_dir
Accept either a name (looked up under ./targets/) or a direct path.
harness/cli.py:84
↓ 2 callers
Function
_resume_layout_error
Return an error string if --runs is incompatible with the on-disk layout of a --resume dir. out_dirs is [root] when runs==1 vs [root/run_NNN] when
harness/cli.py:179
↓ 2 callers
Function
_seed_found_bugs
Seed the jsonl with config known_bugs so a mid-run `cat` is a complete view, not just peer discoveries. System-prompt attention fades at high
harness/cli.py:568
↓ 2 callers
Function
_stream_dispatch
Judge → maybe-report. Serialized on ctx["lock"] so two simultaneous arrivals don't both claim NEW for the same root cause. Report dispatch hap
harness/cli.py:381
↓ 2 callers
Function
_tail
(s: str, n: int = 40)
harness/patch_grade.py:313
↓ 2 callers
Function
_task
(i: int)
harness/cli.py:759
↓ 2 callers
Function
_truncate_tool_results
Clip large tool_result content (ASAN traces) for transcript persistence. Mutates a copy. Only touches user messages with tool_result blocks.
harness/agent.py:87
↓ 2 callers
Function
build
()
tests/test_untrusted.py:195
↓ 2 callers
Function
build_grade_prompt
( image_tag: str, reproduction_command: str, reproduction_command_adapted: str, crash_type: st
harness/prompts/grade_prompt.py:76
↓ 2 callers
Function
build_patch_prompt
( source_root: str, binary_path: str, build_command: str, test_command: str | None, reprod
harness/prompts/patch_prompt.py:139
↓ 2 callers
Function
build_report_grader_prompt
(report_text: str)
harness/prompts/report_grader_prompt.py:89
↓ 2 callers
Function
build_style_judge_prompt
(diff: str)
harness/prompts/patch_prompt.py:41
↓ 2 callers
Method
from_json
(cls, s: str)
harness/artifacts.py:191
↓ 2 callers
Function
run_find
Run one find attempt against a target. Returns (crash_or_none, agent_result, timings). crash is None if no PoC was emitted or the claimed pat
harness/find.py:21
↓ 2 callers
Function
run_recon
Explore the target's source and propose a focus-area partition. Returns (focus_areas, agent_result). focus_areas is empty if the agent failed
harness/recon.py:22
↓ 2 callers
Function
run_report
Produce an exploitability report for a verified crash. Returns (verdict, report_text, agent_result, elapsed). verdict is None if the agent em
harness/report.py:37
↓ 2 callers
Method
to_json
(self)
harness/artifacts.py:187
↓ 2 callers
Method
transcript
JSON-serializable transcript for persistence.
harness/agent.py:186
↓ 2 callers
Function
upstream_log
Return `git log <commit>..HEAD -- <crash_file>` from a cached shallow clone. Returns a status-prefixed string: either the truncated git log outpu
harness/novelty.py:22
↓ 1 callers
Function
_ckpt
(i: int)
harness/cli.py:1261
↓ 1 callers
Function
_cmd_dedup
(args)
harness/cli.py:1064
↓ 1 callers
Function
_cmd_patch
(args)
harness/cli.py:1297
↓ 1 callers
Function
_cmd_recon
(args)
harness/cli.py:1017
↓ 1 callers
Function
_cmd_report
(args)
harness/cli.py:1201
↓ 1 callers
Function
_cmd_run
(args)
harness/cli.py:948
↓ 1 callers
Function
_docker_available
()
tests/test_patch_grade_e2e.py:38
↓ 1 callers
Function
_ensure_base
()
harness/agent_image.py:45
next →
1–100 of 364, ranked by callers