Skip to content

Add --test flag to evaluate rules against a URL (dry-run)#32

Merged
ammario merged 5 commits intomainfrom
blink/test-flag
Sep 12, 2025
Merged

Add --test flag to evaluate rules against a URL (dry-run)#32
ammario merged 5 commits intomainfrom
blink/test-flag

Conversation

@blink-so
Copy link
Copy Markdown
Contributor

@blink-so blink-so Bot commented Sep 11, 2025

Implements --test to evaluate a rule against a URL without starting the proxy/jail.\n\nUpdate: --test now supports METHOD URL in addition to just URL (defaults to GET). You can pass it as two args or a single quoted string, and method parsing is case-insensitive. Output reflects the method, e.g., ALLOW POST https://example.com.\n\nSummary:\n- Adds --test [METHOD] URL CLI support\n- Builds the selected rule engine (--js, --js-file, or --script) and evaluates the request\n- Exits 0 when the rule allows, 1 when it denies\n- Prints ALLOW <METHOD> <url> or DENY <METHOD> <url> and includes context if provided\n- Adjusts CLI so --test can be used without a command\n- Adds tests for allow/deny and method parsing behavior\n\nExamples:\n\nhttpjail --js \"r.host === 'google.com'\" --test https://google.com\nhttpjail --js \"r.method === 'POST' && r.host === 'example.com'\" --test POST https://example.com\nhttpjail --js \"r.method === 'PUT' && r.host === 'example.com'\" --test \"PUT https://example.com\"\n\n\nFixes #30

blink-so Bot added 2 commits September 11, 2025 20:21
…dd --test flag to CLI with URL argument\n- Build rule engine from --js/--js-file/--script and evaluate GET URL\n- Exit 0 on ALLOW, 1 on DENY; print result and optional context\n- Update clap to allow --test without a command\n- Add tests for allow/deny behavior\n\nFixes #30\n\nCo-authored-by: ammario <7416144+ammario@users.noreply.github.com>
…nused imports ArgAction and spawn_blocking\n- Apply rustfmt formatting changes\n\nCo-authored-by: ammario <7416144+ammario@users.noreply.github.com>
@ammario ammario marked this pull request as ready for review September 12, 2025 01:27
@ammario ammario enabled auto-merge (squash) September 12, 2025 01:27
ammario and others added 2 commits September 11, 2025 20:28
Allow --test to accept "[METHOD] URL" format where METHOD is optional.
When two words are provided, the first is interpreted as the HTTP method.
Defaults to GET when only URL is provided for backward compatibility.

Supported methods: GET, POST, PUT, DELETE, HEAD, OPTIONS, CONNECT, PATCH, TRACE

Examples:
  --test "https://example.com"              # defaults to GET
  --test "POST https://api.example.com"     # uses POST method
  --test "DELETE https://example.com/user"  # uses DELETE method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ammario ammario disabled auto-merge September 12, 2025 01:28
@ammario ammario merged commit 9ff860f into main Sep 12, 2025
7 checks passed
@ammario ammario deleted the blink/test-flag branch September 12, 2025 01:33
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.

Add --test flag

1 participant