Skip to content

test: cross-language conformance parity for shared test vectors - #18

Merged
mostafa merged 7 commits into
mainfrom
feat/cross-language-conformance
May 11, 2026
Merged

mostafa merged 7 commits into
mainfrom
feat/cross-language-conformance

Conversation

@mostafa

@mostafa mostafa commented May 11, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Wire audit_events.json and redirect_chains.json into all four languages (Rust, Go, Python, Node.js), covering PolicyCreated audit events and per-hop redirect chain validation with scheme enforcement and max_redirects limits.
  • Add ipv4_ipv6_mapping.json coverage to Python conformance tests and wire cloud_providers into Rust and Python policy_decisions.json tests.
  • Add Node.js SSH policy guard tests (safeSshConnect blocks private IP, loopback, and IMDS).
  • Fix clippy pedantic lints (redundant closures, as usize casts, map_unwrap_or).

Test plan

  • cargo test passes (Rust)
  • go test ./... passes (Go)
  • pytest passes (Python)
  • node --import tsx --test passes (Node.js)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings passes

mostafa added 7 commits May 11, 2026 21:07
…roviders into conformance tests

- Add audit_event_vectors() test: validates PolicyCreated event fields
  (preset, deny_count_min, allow_count) via CollectingSink, handles
  no_event_when_no_sink case. Skips validate_url/validate_host/
  connection_attempt/redirect_intercepted (not yet emitted by core).
- Add redirect_chain_vectors() test: per-hop URL validation through
  UriValidator + Policy.validate_scheme for protocol rules. Handles
  max_redirects counting, allow_cidrs overrides, scheme downgrade
  detection, and FTP protocol switch.
- Wire cloud_providers field in policy_decision_vectors() via
  CloudProvider enum, matching Go/Node behavior.
…mance tests

- Add TestAuditEventVectors: loads audit_events.json, tests
  create_policy (verifies audit callback invoked with cloud modules)
  and no_event_when_no_sink. Skips validate_url/validate_host/
  connection_attempt/redirect_intercepted (WASM-layer limitation).
- Add TestRedirectChainVectors: per-hop IsAllowed validation with
  manual require_https enforcement (WASM ABI does not expose protocol
  rules), max_redirects counting, and allow_cidrs overrides.
- Extract presetBuilder helper to reduce duplication.
…iders

- Add TestAuditEvents: validates PolicyCreated event fields (preset,
  deny_count_min, allow_count) via AuditFunc callback, handles
  no_event_when_no_sink. Skips validate_url/validate_host/
  connection_attempt/redirect_intercepted (not yet emitted).
- Add TestRedirectChains: per-hop validate_url with manual
  require_https enforcement, max_redirects counting, allow_cidrs.
- Add TestIpv4Ipv6Mapping: cidr_contains for both IPv4 and
  IPv6-mapped forms across all 7 vectors.
- Wire cloud_providers in TestPolicyDecisions via builder.with_cloud().
- Add conftest fixtures: audit_event_vectors, redirect_chain_vectors,
  ipv4_ipv6_mapping_vectors (all using correct test_cases/cases keys).
- Add Conformance: Audit Events suite: validates PolicyCreated event
  fields (preset, deny_count_min, allow_count) via AuditFunc callback,
  handles no_event_when_no_sink. Skips validate_url/validate_host/
  connection_attempt/redirect_intercepted (WASM-layer limitation).
- Add Conformance: Redirect Chains suite: per-hop isAllowed validation
  with manual require_https enforcement, max_redirects counting, and
  allow_cidrs overrides across all 12 redirect chain vectors.
- Create ssh.test.ts with 3 policy guard tests matching Go's
  protocol_ssh_test.go: blocks private IP, blocks loopback, blocks
  IMDS. Tests fail at the policy/TCP validation step before any SSH
  handshake.
- Add loadTestCases helper for test_cases key alignment.
Replace redundant closures with method references, use
usize::try_from instead of `as usize` casts, and prefer
map_or over map().unwrap_or().
@mostafa
mostafa merged commit 71a1b57 into main May 11, 2026
20 checks passed
@mostafa
mostafa deleted the feat/cross-language-conformance branch May 11, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant