fix(sandbox): add JSON bodies to proxy 403/502 responses and include port in HTTP log URLs#809
Open
johntmyers wants to merge 1 commit intomainfrom
Open
fix(sandbox): add JSON bodies to proxy 403/502 responses and include port in HTTP log URLs#809johntmyers wants to merge 1 commit intomainfrom
johntmyers wants to merge 1 commit intomainfrom
Conversation
…port in HTTP log URLs L4 CONNECT and forward-proxy denial responses (403) and upstream failure responses (502) were returned with empty bodies, making them indistinguishable from each other when using curl -s. Add a build_json_error_response() helper that produces consistent JSON bodies with error and detail fields, matching the format already used by the L7 deny path. Also fix Url::to_display_string() in openshell-ocsf to include non-default ports in the shorthand log output. Requests to e.g. http://host:9876/path were logged as http://host/path, dropping the port number. Closes #807, closes #808
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.
Summary
Proxy 403/502 error responses were returned with empty bodies, making them invisible to
curl -sand indistinguishable from each other. Also, non-default ports were dropped from HTTP activity shorthand log lines.Related Issue
Closes #807
Closes #808
Changes
build_json_error_response()helper inproxy.rsthat produces JSON bodies witherroranddetailfields, consistent with the existing L7 deny path (send_deny_responseinl7/rest.rs)Url::to_display_string()inopenshell-ocsfto include the port when it differs from the scheme default (443/https, 80/http)Error codes returned:
policy_deniedssrf_deniedupstream_unreachablecredential_injection_failedBefore:
After:
{"detail":"GET api.example.com:9876/test not permitted by policy","error":"policy_denied"}Testing
mise run pre-commitpasses (excluding pre-existing z3 build env issue)build_json_error_response(403, 502, Content-Length correctness), 3 new tests forUrl::to_display_string(non-default port, default port, no port), 1 new shorthand formatter testChecklist