You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dd91585
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(assail): make assail reports deterministic (#245)
Follow-up to #237 (JCS reports), as noted in that PR.
## Problem
Running `assail` twice on the same input gave **different reports**. On
`main`, six runs of `examples/vulnerable_program.rs` produced six
distinct reports. The cause is that these fields were built from
`HashSet`/`HashMap` iteration order, which Rust randomises per run:
- `frameworks`
- `recommended_attacks`
- the taint-matrix rows
- the dependency-graph edges, despite a code comment claiming
"deterministic output"
- the test-only-function scan
JCS sorts object keys but, by design, leaves array order alone. So since
#237, the canonical JSON, and any hash over it such as the `--attest`
seal, differed for identical input.
## Fix
- Those five sites now use `BTreeSet`/`BTreeMap`.
- `AttackAxis`, `Framework` and `WeakPointCategory` now derive
`PartialOrd` and `Ord` (declaration order). The derives are additive.
## Evidence
- After the fix, runs are byte-identical:
- six runs on the example file;
- three runs on `examples/`;
- three runs on the whole `src/` tree.
- **New test `test_assail_report_is_deterministic`.** It builds a
multi-directory fixture whose `Cargo.toml` triggers several frameworks
and asserts that nine analyses give identical canonical JSON. Every
`HashMap` in a process gets its own random seed, so this catches
regressions within a single test run.
- **The test is not vacuous.** With the old `HashMap` code restored, it
fails with "assail report differs between runs".
## Verification
- `cargo fmt --check`: clean.
- `cargo build --locked`: no warnings.
- `cargo clippy --locked --all-features --all-targets -- -D warnings`:
clean.
- `cargo test --locked --all-features --no-fail-fast`: 693 passed, 0
failed.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01PFaqv6iBXrt3W5Akd1Fq5k)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
0 commit comments