Repository navigation
Feat: Deny-by-default egress allow list for the forward proxy #1548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
60019b8
feat: deny-by-default egress allow list for the forward proxy
mrsabath b5d4c95
fix: sanitize client-controlled values in the egress allow list's log…
mrsabath 6bd3bc6
fix: HTML-escape the name in MocaRefusal's body (#1483)
mrsabath c4c96ae
fix: Deny a stray-bracket destination instead of panicking (#1483)
mrsabath f342972
Merge main into fix/sbx-egress-allowlist (#1483)
mrsabath 3f47224
docs: Name the listener scope of the egress allow list (#1483)
mrsabath ec8afb8
Merge main into fix/sbx-egress-allowlist (#1483)
mrsabath 8091931
docs: Name enforce-redirect in the egress allow list's scope note (#1…
mrsabath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package main | ||
|
|
||
| import "testing" | ||
|
|
||
| // resolveEgressAllow picks the allow list's source: config wins over the | ||
| // MOCA_EGRESS_ALLOW env var, the env var is split on commas with blanks | ||
| // dropped, and nothing configured anywhere means the feature is off (nil). | ||
| // The env var is the MOCA conformance harness's only channel into the target, | ||
| // so the fallback is the contract, not a convenience. | ||
| func TestResolveEgressAllow(t *testing.T) { | ||
| configured := []string{"a.test:443", "b.test:80"} | ||
| if got := resolveEgressAllow(configured, func(string) string { | ||
| t.Fatal("config entries must win without consulting the environment") | ||
| return "" | ||
| }); len(got) != 2 || got[0] != "a.test:443" || got[1] != "b.test:80" { | ||
| t.Errorf("config wins: got %v, want the configured entries", got) | ||
| } | ||
|
|
||
| env := func(name, value string) func(string) string { | ||
| return func(k string) string { | ||
| if k == envEgressAllow { | ||
| return value | ||
| } | ||
| return "" | ||
| } | ||
| } | ||
|
|
||
| if got := resolveEgressAllow(nil, env(envEgressAllow, " a.test:443 , ,b.test:80 ")); len(got) != 2 || | ||
| got[0] != "a.test:443" || got[1] != "b.test:80" { | ||
| t.Errorf("env fallback: got %v, want the two comma-separated entries, trimmed", got) | ||
| } | ||
| if got := resolveEgressAllow(nil, env(envEgressAllow, " ")); got != nil { | ||
| t.Errorf("blank env: got %v, want nil — off, not an empty-but-armed list", got) | ||
| } | ||
| if got := resolveEgressAllow(nil, env(envEgressAllow, "")); got != nil { | ||
| t.Errorf("unset env: got %v, want nil", got) | ||
| } | ||
| if got := resolveEgressAllow(nil, func(string) string { return "" }); got != nil { | ||
| t.Errorf("nothing configured: got %v, want nil", got) | ||
| } | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.