fix(monitor): check seeds without scanning workers
This commit is contained in:
1 parent
1b660a0435
commit
98309a356a
5 files changed
+41
-26
No files matched your search
@@ -42,10 +42,10 @@ func runManagedBlockcheck(ctx context.Context, binary, domain string, stdout, st
|
||||
domain = strings.ToLower(domain)
|
||||
if args := managedSeedArgs(domain); args != "" {
|
||||
// A transient endpoint timeout can invalidate one protocol's strict 3/3
|
||||
// check even when the seeded scan found it; retry this tiny corpus before
|
||||
// check even when the seeded candidate works; retry this tiny check before
|
||||
// spending an hour on the full built-in corpus.
|
||||
for attempt := 0; attempt < 5; attempt++ {
|
||||
path, err := runBlockcheckWithConflictCleanupAndSeed(ctx, binary, domain, stdout, stderr, true, args)
|
||||
path, err := runManagedSeedCheck(ctx, binary, domain, args, stdout, stderr)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
@@ -67,10 +67,6 @@ func runManagedBlockcheck(ctx context.Context, binary, domain string, stdout, st
|
||||
}
|
||||
|
||||
func runBlockcheckWithConflictCleanup(ctx context.Context, binary, domain string, stdout, stderr io.Writer, allowConflictCleanup bool) (string, error) {
|
||||
return runBlockcheckWithConflictCleanupAndSeed(ctx, binary, domain, stdout, stderr, allowConflictCleanup, "")
|
||||
}
|
||||
|
||||
func runBlockcheckWithConflictCleanupAndSeed(ctx context.Context, binary, domain string, stdout, stderr io.Writer, allowConflictCleanup bool, seedArgs string) (string, error) {
|
||||
if !validDomain(domain) {
|
||||
return "", fmt.Errorf("invalid DNS hostname: %q", domain)
|
||||
}
|
||||
@@ -98,21 +94,7 @@ func runBlockcheckWithConflictCleanupAndSeed(ctx context.Context, binary, domain
|
||||
}
|
||||
}
|
||||
domain = strings.ToLower(domain)
|
||||
var seedPath string
|
||||
if seedArgs != "" {
|
||||
rows, err := combinedVanillaRowsForHost(seedArgs, domain)
|
||||
if err != nil {
|
||||
return path, err
|
||||
}
|
||||
seedPath = filepath.Join(workdir, "managed-seed.txt")
|
||||
if err := os.WriteFile(seedPath, []byte(rows), 0600); err != nil {
|
||||
return path, err
|
||||
}
|
||||
}
|
||||
scanArgs := []string{"--workers", "8", "scan", "--domain", domain, "--protocols", "tls12,tls13", "--auto"}
|
||||
if seedPath != "" {
|
||||
scanArgs = append(scanArgs, "--from-file", seedPath)
|
||||
}
|
||||
if !allowConflictCleanup {
|
||||
scanArgs = append(scanArgs, "--no-conflict-cleanup")
|
||||
}
|
||||
@@ -142,6 +124,30 @@ func runBlockcheckWithConflictCleanupAndSeed(ctx context.Context, binary, domain
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func runManagedSeedCheck(ctx context.Context, binary, host, args string, stdout, stderr io.Writer) (string, error) {
|
||||
rows, err := combinedVanillaRowsForHost(args, host)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
f, err := os.CreateTemp("", "blockcheckw-managed-seed-*.txt")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
path := f.Name()
|
||||
if err := f.Close(); err != nil {
|
||||
return path, err
|
||||
}
|
||||
input := path + ".input"
|
||||
if err := os.WriteFile(input, []byte(rows), 0600); err != nil {
|
||||
return path, err
|
||||
}
|
||||
checkArgs := []string{"--workers", "32", "check", "--from-file", input, "--domain", strings.ToLower(host), "--take", "1", "--passes", "3", "--auto", "--output", path + ".check.json"}
|
||||
if err := runBlockcheckCommand(ctx, binary, "", checkArgs, stdout, stderr); err != nil {
|
||||
return path, err
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func blockcheckVanillaReport(dir string) (string, error) {
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
|
||||
@@ -253,15 +253,12 @@ func TestRunManagedBlockcheckSeedsKnownProfileThroughBlockcheck(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
decoder := json.NewDecoder(bytes.NewReader(argv))
|
||||
var scanArgs, checkArgs []string
|
||||
if err := decoder.Decode(&scanArgs); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var checkArgs []string
|
||||
if err := decoder.Decode(&checkArgs); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !slices.Contains(scanArgs, "--from-file") || slices.Contains(scanArgs, "--no-conflict-cleanup") || slices.Contains(checkArgs, "--no-conflict-cleanup") {
|
||||
t.Fatalf("managed seeded commands=%q then %q", scanArgs, checkArgs)
|
||||
if !slices.Contains(checkArgs, "--from-file") || !slices.Contains(checkArgs, "--passes") || slices.Contains(checkArgs, "--no-conflict-cleanup") {
|
||||
t.Fatalf("managed seeded check=%q", checkArgs)
|
||||
}
|
||||
if seed := managedSeedArgs("rr3.googlevideo.com"); !strings.Contains(seed, "fakeddisorder") {
|
||||
t.Fatalf("missing exact-host GGC seed: %q", seed)
|
||||
|
||||
@@ -213,6 +213,9 @@ func selectBlockcheckEvidence(r io.Reader, expected, group, host string, recover
|
||||
if !ok {
|
||||
return "", fmt.Errorf("no fully passing check strategy for both tls12 and tls13")
|
||||
}
|
||||
if protocol == "tls13" && c.Args == best["tls12"].Args {
|
||||
continue
|
||||
}
|
||||
for _, token := range strings.Fields(c.Args) {
|
||||
if strings.HasPrefix(token, "--payload=") {
|
||||
if payloads[token] {
|
||||
|
||||
@@ -396,6 +396,14 @@ func TestCombinedVanillaRowsAndSelection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSelectBlockcheckDoesNotDuplicateIdenticalCrossProtocolArgs(t *testing.T) {
|
||||
args := "--payload=tls_client_hello --lua-desync=hostfakesplit:disorder_after:ip_autottl=-3,3-20:repeats=1 --lua-desync=multidisorder:pos=1,midsld"
|
||||
got, err := selectBlockcheckArgsForTarget(strings.NewReader(combinedReportFixture(args)), "", "frontend", "www.youtube.com")
|
||||
if err != nil || got != args {
|
||||
t.Fatalf("selected args=%q err=%v", got, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCombinedBlockcheckOutput(t *testing.T) {
|
||||
args := "--payload=tls_client_hello --lua-desync=hostfakesplit --lua-desync=multidisorder"
|
||||
valid := combinedReportFixture(args)
|
||||
|
||||
Reference in new issue
Block a user