mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 15:32:06 +00:00
fix: restrict supervisor drain to loopback
This commit is contained in:
@@ -167,3 +167,16 @@ func TestAssignedEndpointRejectsMalformedAddressAndPort(t *testing.T) {
|
||||
server.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func TestSupervisorRejectsRemoteOrPartialDrainConfiguration(t *testing.T) {
|
||||
for _, config := range []Config{
|
||||
{Command: []string{"/bin/sh", "-c", "exit 0"}, DrainURL: "https://example.com/drain", DrainToken: "token-1234567890123456"},
|
||||
{Command: []string{"/bin/sh", "-c", "exit 0"}, DrainURL: "http://127.0.0.1/drain"},
|
||||
{Command: []string{"/bin/sh", "-c", "exit 0"}, DrainToken: "token-1234567890123456"},
|
||||
{Command: []string{"/bin/sh", "-c", "exit 0"}, DrainURL: "http://127.0.0.1/drain?token=leaked", DrainToken: "token-1234567890123456"},
|
||||
} {
|
||||
if _, err := New(config); err == nil {
|
||||
t.Fatalf("unsafe drain configuration accepted: %+v", config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user