Repository navigation
Conversation
Signed-off-by: Sai Sree Laya Chukkappalli <saisreelaya.chukkapalli@gmail.com>
Signed-off-by: Sai Sree Laya Chukkappalli <saisreelaya.chukkapalli@gmail.com>
araujof
left a comment
There was a problem hiding this comment.
I added a duplicate ASI01 with different scenario text before the original entry, and Phase C still passed. The snapshot is also read again for hashing, so replacing it after validation can leave the state recording bytes that were never checked. Could we validate the whole snapshot and hash the same bytes?
The new changelog entry says the catalog ships in built packages, but the wheel I checked omits the JSON. Could we include the file and test the installed wheel, or remove that claim? Please also share an end-to-end example run for the changed phase guides, as CONTRIBUTING.md requires.
These snapshots are useful groundwork for reducing context use. I've asked for smaller handoffs, bounded batches and context budgets in the proposal review. That work can follow separately, keeping this PR focused on snapshots and provenance.
| recorded = { | ||
| entry.get("id"): entry for entry in actual["threats"] if isinstance(entry, dict) | ||
| } |
There was a problem hiding this comment.
Could we validate the whole snapshot before building this dict? Non-object rows are dropped and duplicate IDs collapse to the last entry. I inserted an extra ASI01 with different scenario text before the genuine entry; Phase C still passed with 11 rows and recorded the edited file's hash. It also passed after I added a top-level mitigations field to the Phase C snapshot. Please reject malformed or duplicate rows and unexpected fields so the check covers all the content the model reads.
| AttributeError, | ||
| ) as exc: | ||
| raise ReconciliationError(f"OWASP catalog is malformed: {path}: {exc}") from exc | ||
| if sorted(ids) != list(CATALOG_IDS): |
There was a problem hiding this comment.
Could we check that IDs are strings before sorting them? Replacing ASI01's ID with 1 raises TypeError, bypassing the ReconciliationError path the CLI handles and showing a traceback instead of the malformed-catalog message.
| ) | ||
| continue | ||
| try: | ||
| recorded = json.loads(path.read_text(encoding="utf-8")) |
There was a problem hiding this comment.
Could we keep the snapshot bytes from this read and use their hash in the state record? The file is validated here, then read again for hashing later in checkpoint(). In a simulation that replaces the snapshot between those steps, the checkpoint passes and records the replacement's hash even though its scenario text would fail validation. Hashing the checked bytes would keep the record accurate.
…wheel Signed-off-by: Sai Sree Laya Chukkappalli <saisreelaya.chukkapalli@gmail.com>
Signed-off-by: Sai Sree Laya Chukkappalli <saisreelaya.chukkapalli@gmail.com>
Signed-off-by: Sai Sree Laya Chukkappalli <saisreelaya.chukkapalli@gmail.com>
… in addenda Signed-off-by: Sai Sree Laya Chukkappalli <saisreelaya.chukkapalli@gmail.com>
|
Thanks for the careful review. All three points and the packaging issue are fixed in bb91561:
Each case has regression tests in One addition since your review: b210158 makes Phase D work with numbered-section guidance and keeps that numbering in the addenda. Please take a look at it as well. @araujof, could you take another look when you have a chance? |
Summary
Phases C and D now read the OWASP catalog through per-phase snapshot files written by
--prepare, and the checkpoint verifies each snapshot against the current catalog.analysis_state.jsonrecords the hash of everysnapshot and of the catalog, so a run shows exactly which catalog content it used, and a catalog edited after a phase was prepared fails that phase's checkpoint.
This is PR 1 (provenance) of the design in #114. Context-budget work and ranking follow in separate PRs.
Changes
--prepare --phase Cwritesowasp_catalog_C.json(descriptions, aliases and scenarios, with no mitigation or impact fields).--prepare --phase Dwritesowasp_catalog_D.json, holding exactly the categories Phase C markedYesorPartial. The step guides point the model at these files instead of the raw catalog.ASI03#4) and the phase to re-run.guidance_mergerefusesguidance derived from an older catalog.
ReconciliationError, not aTypeError.security_catalog.py). It rejects duplicate, missing or malformedASI01–ASI10IDs and entries with no attack scenarios. An entry with no scenarios used to drop that categoryfrom mandatory coverage silently.
data/*.json). A non-editable install used to fail Phase C with "OWASP catalog is missing".## 1. Title, as inemployee) now works through Phase D. The existing-rule check recognizes the headings, and an addendum must addrules as the next numbered sections at the same heading level, so merged guidance keeps the target's format. Previously every reference to an existing rule failed the Phase D checkpoint, and an addendum could only
be bare bullets appended under the last section. The same bug is on
main. This is outside snapshots/provenance; it's included because it blocked the end-to-end run.site-packages..gitignore: per-run snapshots are ignored, likeanalysis_state.json.End-to-end runs
Two fresh step-9 runs on this branch (
tests/run_smith_pipeline.py -s 9 -m aws/claude-sonnet-5). Both passedPhases A–D. In both:
analysis_state.jsonrecords hashes for the catalog and both snapshots, and each matches its file.RagChatbot_MCPServer (plain-numbered guidance; D snapshot
ASI01,ASI02,ASI03,ASI08,ASI09). Phase D found no new rules.employee (heading-numbered guidance; D snapshot
ASI01,ASI02,ASI03,ASI09). Phase D proposed one rule, written in the guidance's own format as the next section:The per-phase sums equal each run's reported totals. Uncached input was under 210 tokens per run, so it's omitted. Cache reads are about 95% of every phase, so later phases cost more because the session keeps growing. That is the accumulation #114 §5A addresses. The artifacts, step logs and token tables for both runs are in the attached zip.
Checks
make cipasses (lint, license headers, 567 unit tests)make test— not applicable; no policy behavior changedCHANGELOG.mdupdated under## [Unreleased]Notes
make ciwas run with ruff 0.15.20, the version CI uses. The dev extrapins
ruff==0.17.0, which enables 407 rules by default instead of 59 andreports 253 existing findings across
src/. That mismatch is onmainand worth its own issue.