Add --test flag to evaluate rules against a URL (dry-run)#32
Merged
Conversation
…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>
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>
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.
Implements
--testto evaluate a rule against a URL without starting the proxy/jail.\n\nUpdate:--testnow supportsMETHOD URLin addition to justURL(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] URLCLI 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- PrintsALLOW <METHOD> <url>orDENY <METHOD> <url>and includes context if provided\n- Adjusts CLI so--testcan 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