Skip to content

feat: URL rule allow/deny system with cross-language support - #12

Merged
mostafa merged 8 commits into
mainfrom
feat/url-rules
May 10, 2026
Merged

mostafa merged 8 commits into
mainfrom
feat/url-rules

Conversation

@mostafa

@mostafa mostafa commented May 10, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add a URL-level allow/deny rule system to ressrf-core supporting scheme exact match, host globs (* = single DNS label), path globs (*/** segments), and optional full-URL regex (1MB automaton limit, ReDoS-safe). Deny rules evaluate first; per-rule bypass_ip_check flag allows trusted endpoints to skip IP validation.
  • Wire URL rules through the WASM ABI and expose WithURLAllow/WithURLDeny (Go), url_allow/url_deny (Python), and urlAllow/urlDeny (Node.js) on each language's PolicyBuilder.
  • Add 14 shared test vectors (tests/vectors/url_rules.json) and cross-language conformance tests in Rust, Go, Python, and Node.js.
  • Create per-package READMEs for all 9 sub-projects and refactor root README to high-level overview with links. Document URL rules with code examples across all languages.

Test plan

  • cargo test --workspace passes (including url_rules vector tests)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings clean
  • cargo fmt --all -- --check clean
  • Go tests pass (go test ./...)
  • Python conformance tests pass (uv run pytest)
  • Node.js conformance tests pass (node --import tsx --test)
  • CI green on all platforms

mostafa and others added 8 commits May 10, 2026 14:43
Implement UrlRule and UrlRuleset in ressrf-core for URL-level allow/deny
filtering beyond CIDR-based policies. Rules support scheme exact match,
host glob (* = single DNS label), path glob (*/** segments), and optional
full-URL regex (1MB automaton limit, ReDoS-safe via the regex crate).

Deny rules are evaluated first, then allow rules. When allow rules are
configured, unmatched URLs are blocked. Per-rule bypass_ip_check flag
allows trusted endpoints to skip IP-level validation entirely.

Wire into PolicyBuilder/Policy with validate_url_rules() and
is_request_allowed() methods. Extend WASM ABI PolicyConfig with optional
url_rules field. Add shared test vectors (14 cases) and Rust integration
tests.
Add URLRule struct and WithURLAllow/WithURLDeny methods to PolicyBuilder.
URL rules are serialized into the WASM PolicyConfig and evaluated at
policy check time. Add conformance tests consuming shared url_rules.json
vectors.
Expose URL rule support via PyO3 bindings. PolicyBuilder gains
url_allow() and url_deny() keyword-argument methods mapping to
ressrf-core UrlRule. CorePolicy.validate_url checks URL rules first,
respecting bypass_ip_check. Add conformance tests consuming shared
url_rules.json vectors.
Add UrlRule and UrlRulesConfig interfaces. PolicyBuilder gains urlAllow()
and urlDeny() methods. Policy.create maps UrlRule to WASM snake_case
config via ruleToWasm helper. Export new types from index. Add
conformance tests consuming shared url_rules.json vectors.
Create individual READMEs for all sub-projects (ressrf-core, ressrf-http,
ressrf-ssh, ressrf-tcp, ressrf-tracing, ressrf-wasm, Go, Python, Node.js)
with full API tables, code examples, and feature descriptions. Refactor
root README to high-level overview with links to per-package docs. Add
URL rules section with cross-language examples to root and all relevant
package READMEs.
@mostafa
mostafa merged commit d735428 into main May 10, 2026
21 checks passed
@mostafa
mostafa deleted the feat/url-rules branch May 10, 2026 13:01
gonzaloserrano added a commit that referenced this pull request May 27, 2026
The -out default `internal/engine` is relative to the current
working directory, not "relative to repo root" as the help string
claimed. A contributor running gen-data from the actual repo root
following the help text would write to <repo-root>/internal/engine/
which doesn't exist; if their shell auto-creates the dir, generated
files land in the wrong place while the engine package keeps stale
tables.

The doc comment at the top of main.go already says to run from
go-native/ressrf/, so the default does land in the right place when
the documented workflow is followed. The flag help just disagreed.

Addresses td-code-review finding #12.
gonzaloserrano added a commit that referenced this pull request May 27, 2026
The -out default `internal/engine` is relative to the current
working directory, not "relative to repo root" as the help string
claimed. A contributor running gen-data from the actual repo root
following the help text would write to <repo-root>/internal/engine/
which doesn't exist; if their shell auto-creates the dir, generated
files land in the wrong place while the engine package keeps stale
tables.

The doc comment at the top of main.go already says to run from
go-native/ressrf/, so the default does land in the right place when
the documented workflow is followed. The flag help just disagreed.

Addresses td-code-review finding #12.
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