Skip to content

feat: IP ranges codegen script and trie-backed service range lookups - #11

Merged
mostafa merged 3 commits into
mainfrom
feat/ip-ranges-codegen
May 9, 2026
Merged

mostafa merged 3 commits into
mainfrom
feat/ip-ranges-codegen

Conversation

@mostafa

@mostafa mostafa commented May 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract hardcoded cloud deny ranges and domain suffixes into config/domains_{aws,azure,gcp}.json, generate Rust constants via build.rs, and replace static slices in cloud modules with include! of generated code.
  • Add scripts/generate_ip_ranges.py (stdlib-only) that fetches IANA special-purpose registries and AWS/Azure/GCP service IP ranges with SHA-256 audit logging, CIDR validation, duplicate detection, and csp_metadata cross-checks. Supports --iana-only, --validate-only, and --dry-run modes.
  • Add ServiceRangeTable backed by prefix-trie for O(log n) longest-prefix-match lookups on ~9,000+ cloud service prefixes, gated behind the std feature. Includes load_from_file(), load_all(), lookup(), is_service_ip(), and merge(). Integrated with PolicyBuilder via optional with_service_ranges().
  • Fix ip_ranges.json: remove ::ffff:0:0/96 (would block all IPv4 via mapped addresses), add missing IANA ranges (127.0.0.0/8, 224.0.0.0/4, fc00::/7, ff00::/8), clean up malformed RFC references.
  • Add monthly CI workflow (.github/workflows/update-ip-ranges.yml) with cargo test validation gate, concurrency limits, and automatic PR creation.

Test plan

  • python scripts/generate_ip_ranges.py --validate-only passes
  • cargo test --workspace --all-features passes (88 tests)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings clean
  • cargo fmt --all -- --check clean
  • zizmor -p . zero findings
  • Go tests pass with -race flag
  • Node.js tests pass (91 tests)
  • WASM rebuild succeeds for wasm32-wasip1

mostafa and others added 3 commits May 10, 2026 00:38
Extract hardcoded cloud deny ranges and domain suffixes into JSON config
files (domains_{aws,azure,gcp}.json), generate Rust constants via build.rs,
and replace static slices in cloud modules with include! of generated code.

Add scripts/generate_ip_ranges.py that fetches IANA special-purpose
registries and cloud provider service IP ranges (AWS, Azure, GCP) with
SHA-256 audit logging, CIDR validation, and csp_metadata cross-checks.

Add ServiceRangeTable backed by prefix-trie for O(log n) longest-prefix-match
lookups on cloud service IP ranges, gated behind the std feature. Integrate
with PolicyBuilder via optional with_service_ranges() for allow-listing.

Fix ip_ranges.json: remove ::ffff:0:0/96 (would block all IPv4 via mapped
addresses), add missing IANA ranges (127.0.0.0/8 loopback, 224.0.0.0/4
multicast, fc00::/7 unique-local, ff00::/8 IPv6 multicast), clean up
malformed RFC references.

Add monthly CI workflow (.github/workflows/update-ip-ranges.yml) that
fetches upstream sources and opens a PR on changes.
@mostafa
mostafa merged commit df1952d into main May 9, 2026
22 checks passed
@mostafa
mostafa deleted the feat/ip-ranges-codegen branch May 9, 2026 22:57
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