Repository navigation
policy, mcp-query: add change_impact pre-change evaluator + MCP tool - #66
Closed
fastrevmd-lab wants to merge 2 commits into
Closed
fastrevmd-lab wants to merge 2 commits into
fastrevmd-lab wants to merge 2 commits into
Conversation
Implements task C of MEC-570 (pre-change impact analysis): a read-only differential first-match replay that evaluates historical flows against the current rulebase (P) and a proposed delta (P'), and reports which flows' verdict would change. - Three-valued (match/no_match/unknown) evaluator, respecting Junos zone-pair -> global -> default-deny context order and PAN-OS ordered-list + implicit defaults. - Delta parsing: vendor-neutral JSON op list, and (Junos only) set/delete/insert/activate/deactivate lines applied to `| display set` text and re-parsed with the existing parse_security_policies(). The delta never reaches a device -- this tool issues no device writes. - Candidate pruning restricted to the zone-pairs of the rules that actually differ between P and P', with truncation detected and reported rather than silently assumed complete. - Config-only pre-check: a config-only "no impact" verdict requires every changed rule in the delta to be individually accounted for -- disabled in both P and P', or part of a content-unchanged reorder pair proven equivalence-preserving -- and refuses rule names that are ambiguous across zone-pair contexts, so a mixed or ambiguous delta cannot be waved through on the strength of one benign change. - Per-zone-pair calibration gate: compares the evaluator's verdict against the device's own logged rule_name; below the agreement threshold (default 99%, 100-session minimum sample), that zone-pair's verdicts downgrade to "unknown: model does not reproduce device behaviour" with mismatch examples, instead of reporting a guess. - Output honesty contract: the words "safe" and "no impact" never appear in report output. A zero-result reads "no historical sessions observed in the analysable scope", or "provably no impact (config-only)" when the config-only proof applies. A deny-widening count with no logged denies in-window reports as unknown, never 0. - Hardens the audit path around this tool: device-output arguments that may carry secrets are hashed rather than stored verbatim in the audit trail, including on refusal/error paths, and the tool rejects caller-supplied device text that falls outside the documented scope rather than silently processing it. - New sovereign-only MCP tool change_impact, following the same registration/classification pattern as rule_tools/unused_rules/explain_rule, registered in the eval corpus's tool allowlist. - Default analysis window is 14 days against raw ssdf.events, stated in every report, until the flow_tuples_daily rollup (MEC-1639) lands. Out of scope for v1 (always evaluate to unknown, never a guess): App-ID filters, application-default, DAG/EDL/region (PAN-OS); identity, dynamic-application, URL-category, and scheduler-name (Junos). Verified: - services/policy: uv run pytest -q -m "not integration" -- 184 passed - services/mcp-query: uv run pytest -q -m "not integration" -- 610 passed, 44 skipped - ruff check services / ruff format --check services -- clean - gitleaks protect --staged -- clean Supersedes #51. Refs #29 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
7 tasks done
Addresses the change_impact security review on PR #66: - apply_delta renumbers position from the resulting list order (and canonicalizes the caller's input list order first), so a JSON-delta move/add is reflected in position-based diffing and first-match evaluation instead of silently reading as no change. - Junos insert accepts the fully zone-qualified form and refuses an ambiguous bare policy name instead of resolving to the first match. - Junos sub-statement activate/deactivate and prefix-style sub-statement delete with no value are refused instead of mis-applying to the whole policy or silently no-op'ing. - change_impact no longer accepts a caller-supplied deny_logging_observed argument; it's computed from the same candidate rows the evaluator scores. - delta-line rejection errors identify the line by index only, and the Junos text-delta form's delta.lines is hashed before reaching ssdf.audit, matching junos_current_text's existing treatment. - is_global is persisted on the policy entity and read back, instead of re-derived from from_zone. - coverage.window_default_days now reflects whether the 14-day default was actually used. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
5 tasks done
Member
Author
|
Superseded by #67. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements task C of MEC-570 (pre-change impact analysis): a read-only differential first-match replay that evaluates historical flows against the current rulebase (P) and a proposed delta (P′), and reports which flows' verdict would change.
match/no_match/unknown) evaluator, respecting Junos zone-pair → global → default-deny context order and PAN-OS ordered-list + implicit defaults.set/delete/insert/activate/deactivatelines applied to| display settext and re-parsed with the existingparse_security_policies(). The delta never reaches a device -- this tool issues no device writes.rule_name; below the agreement threshold (default 99%, 100-session minimum sample), that zone-pair's verdicts downgrade tounknown: model does not reproduce device behaviourwith mismatch examples, instead of reporting a guess.unknown, never0.change_impact, following the same registration/classification pattern asrule_tools/unused_rules/explain_rule, registered in the eval corpus's tool allowlist.ssdf.events, stated in every report, until theflow_tuples_dailyrollup (MEC-1639) lands.Out of scope for v1 (always evaluate to
unknown, never a guess)App-ID filters,
application-default, DAG/EDL/region (PAN-OS); identity, dynamic-application, URL-category, and scheduler-name (Junos).Test plan
cd services/policy && uv run pytest -q -m "not integration"— 184 passedcd services/mcp-query && uv run pytest -q -m "not integration"— 610 passed, 44 skippeduvx ruff@0.12.4 check services— cleanuvx ruff@0.12.4 format --check services— cleangitleaks protect --staged— cleanSupersedes #51.
Refs #29 (task C of this issue only; tasks A/B and the rust*mcp approval UX remain)
🤖 Generated with Claude Code