mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-23 15:37:01 +00:00
sts: Limit the size of the HTTPS reads
To avoid accidents/DoS when we are fetching a very very large policy, this patch limits the size of the reads to 10k, which should be more than enough for any reasonable policy as per the current draft.
This commit is contained in:
@@ -157,6 +157,22 @@ func TestFetch(t *testing.T) {
|
||||
t.Logf("version99: got expected error: %v", err)
|
||||
}
|
||||
|
||||
func TestPolicyTooBig(t *testing.T) {
|
||||
// Construct a valid but very large JSON as a policy.
|
||||
raw := `{"version": "STSv1", "mode": "enforce", "mx": [`
|
||||
for i := 0; i < 2000; i++ {
|
||||
raw += fmt.Sprintf("\"mx%d\", ", i)
|
||||
}
|
||||
raw += `"mxlast"], "max_age": 100}`
|
||||
policyForDomain["toobig"] = raw
|
||||
|
||||
_, err := Fetch(context.Background(), "toobig")
|
||||
if err == nil {
|
||||
t.Errorf("fetch worked, but should have failed")
|
||||
}
|
||||
t.Logf("got error as expected: %v", err)
|
||||
}
|
||||
|
||||
// Tests for the policy cache.
|
||||
|
||||
func mustTempDir(t *testing.T) string {
|
||||
|
||||
Reference in New Issue
Block a user