fix(recovery): validate diagnostic DNS addresses
Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
73028f534d
commit
dd98398e77
2 files changed
+19
-1
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@@ -95,7 +96,7 @@ var earlySuccessResult = regexp.MustCompile(`^ OK median [0-9]+ms, [0-9]+\.[0
|
||||
var earlyCheckPreamble = regexp.MustCompile("^(! --workers has no effect on `check` \\(it verifies strategies sequentially by design\\)\n)?" +
|
||||
`=== Checking prerequisites ===\n OK nfqws2: /[^\s]+\n OK nft\n OK nft queue support\n` +
|
||||
`check loaded 2 strategies from /[^\s]+, --take [0-9]+, --passes 3\n( ISP: AS[0-9]+ [^\n]+\n)?` +
|
||||
`=== DNS resolve ===\n dns mode: auto\n ([a-z0-9.-]+) -> [0-9a-fA-F:.]+(?:, [0-9a-fA-F:.]+)* \(via (?:system|doh \(auto-fallback\))\)$`)
|
||||
`=== DNS resolve ===\n dns mode: auto\n ([a-z0-9.-]+) -> ([0-9a-fA-F:.]+(?:, [0-9a-fA-F:.]+)*) \(via (?:system|doh \(auto-fallback\))\)$`)
|
||||
var earlyCheckSummary = regexp.MustCompile(`^ total: 2 \| working: ([01]) \| elapsed: [0-9]+\.[0-9]s\n OK JSON report → (?:/[^\s]+|[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}-[0-9]{2}_check\.json)$`)
|
||||
|
||||
// This is rejection evidence only, never qualification evidence. Unknown CLI
|
||||
@@ -154,6 +155,11 @@ func candidateEarlyTimeout(raw, diagnostics []byte, args, group, host string) bo
|
||||
if preamble == nil || preamble[3] != host {
|
||||
return false
|
||||
}
|
||||
for _, ip := range strings.Split(preamble[4], ", ") {
|
||||
if net.ParseIP(ip) == nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
parts = strings.Split(parts[1], "\n=== Check summary ===\n")
|
||||
if len(parts) != 2 {
|
||||
return false
|
||||
|
||||
@@ -272,6 +272,13 @@ func TestCandidateEarlyTimeoutRemoteCaptures(t *testing.T) {
|
||||
}
|
||||
for _, pair := range [][2]string{
|
||||
{c.ips, "142.251.156.4, garbage"},
|
||||
{c.ips, "dead"},
|
||||
{c.ips, "999.999.999.999"},
|
||||
{c.ips, "142.251.156.4, dead"},
|
||||
{c.ips, "999.999.999.999, 142.251.156.4"},
|
||||
{c.ips, "2001:db8:::1"},
|
||||
{c.ips, "142.251.156.4,2001:db8::1"},
|
||||
{c.ips, "142.251.156.4, 2001:db8::1"},
|
||||
{"via doh (auto-fallback)", "via unknown"},
|
||||
{c.path, "unknown-output"},
|
||||
{c.path, c.path + "\nnfqws2 exited with status 1"},
|
||||
@@ -283,6 +290,11 @@ func TestCandidateEarlyTimeoutRemoteCaptures(t *testing.T) {
|
||||
if !candidateEarlyTimeout(report, []byte(strings.Replace(diagnostic, "via doh (auto-fallback)", "via system", 1)), c.args, "frontend", "www.youtube.com") {
|
||||
t.Fatal("system-resolved addresses rejected")
|
||||
}
|
||||
for _, ips := range []string{"2001:db8::1", "142.251.156.4, 2001:db8::1", "::ffff:192.0.2.1"} {
|
||||
if !candidateEarlyTimeout(report, []byte(strings.Replace(diagnostic, c.ips, ips, 1)), c.args, "frontend", "www.youtube.com") {
|
||||
t.Fatalf("valid IP literals rejected: %q", ips)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user