Conversation
…irmed allow path (#1874) GAP-03: add four tests for load_policy_file() — happy-path (file-loaded deny rule evaluates correctly), FileTooLarge (>256 KiB rejected), FileLoad (nonexistent path), and FileParse (malformed TOML). GAP-04: add test verifying exactly MAX_RULES (256) rules compile without error, closing the off-by-one gap where only 257 was tested. GAP-05: add test confirming execute_tool_call_confirmed() delegates to the inner executor and returns its output when policy allows the call.
After merging main (which added load_policy_file security hardening), the boundary check rejects files outside the process cwd. Switch from NamedTempFile (creates in /tmp) to tempdir_in(cwd) so the canonical path stays within the cwd and all three error-case tests pass correctly.
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.
Closes #1874
Summary
Adds tests for three coverage gaps identified in the post-review of PR #1870:
policy.rs): four tests forload_policy_file():policy_file_happy_path— file-loaded deny rule evaluates correctlypolicy_file_too_large— file > 256 KiB returnsFileTooLargepolicy_file_load_error— nonexistent path returnsFileLoadpolicy_file_parse_error— malformed TOML returnsFileParsepolicy.rs):max_rules_exactly_256_compiles— exactly 256 rules compile without error, closing the off-by-one gap where only 257 was testedpolicy_gate.rs):confirmed_allow_delegates_to_inner—execute_tool_call_confirmed()returns the inner executor's output when policy allowsNotes
Tests in
policy.rsandpolicy_gate.rsare behind#[cfg(feature = "policy-enforcer")]. File-based tests usetempdir_in(cwd)to satisfy the symlink boundary check added in load_policy_file (merged from main during development).Test plan
cargo nextest run -p zeph-tools --features policy-enforcer --lib— 753 passedcargo nextest run --workspace --features full --lib --bins— 6000 passedcargo +nightly fmt --check— cleancargo clippy --workspace --features full -- -D warnings— clean