fix(monitor): keep supervision after empty scans
This commit is contained in:
1 parent
c19c4ffbd9
commit
b2a41270a9
8 files changed
+90
-22
No files matched your search
@@ -268,13 +268,22 @@ func strategyFingerprint(args string) (string, error) {
|
||||
|
||||
// Validation is shared with tune's output path; only combined 3/3 evidence is stored.
|
||||
func saveRun(db *sql.DB, started time.Time, args, output string, report []byte, runErr error) error {
|
||||
return saveFrontendRunForHost(db, started, args, output, report, runErr, "youtube.com")
|
||||
}
|
||||
|
||||
// saveFrontendRunForHost keeps the service-level run target stable while
|
||||
// recording the actual tested frontend endpoint and candidate scope.
|
||||
func saveFrontendRunForHost(db *sql.DB, started time.Time, args, output string, report []byte, runErr error, host string) error {
|
||||
if !validDomain(host) || host != strings.ToLower(host) {
|
||||
return fmt.Errorf("invalid frontend evidence endpoint")
|
||||
}
|
||||
var evidence struct {
|
||||
Strategies []json.RawMessage `json:"strategies"`
|
||||
}
|
||||
state := "FAILED"
|
||||
var savedArgs, savedOutput, savedError, fingerprint interface{}
|
||||
if runErr == nil {
|
||||
verifiedOutput, err := combinedBlockcheckOutput(bytes.NewReader(report), args)
|
||||
verifiedOutput, err := combinedBlockcheckOutputForHost(bytes.NewReader(report), args, host)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -309,7 +318,7 @@ func saveRun(db *sql.DB, started time.Time, args, output string, report []byte,
|
||||
var candidateID int64
|
||||
checked := time.Now().UTC()
|
||||
if runErr == nil {
|
||||
candidateID, err = insertStrategyCandidate(tx, "frontend", []string{"youtube.com"}, args, id)
|
||||
candidateID, err = insertStrategyCandidate(tx, "frontend", []string{host}, args, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -325,7 +334,7 @@ func saveRun(db *sql.DB, started time.Time, args, output string, report []byte,
|
||||
if _, err := tx.Exec(`INSERT INTO protocol_results (run_id, protocol, passes_ok, passes_total) VALUES (?, ?, ?, ?)`, id, normalizeProtocol(row.Protocol), row.PassesOK, row.PassesTotal); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := saveCandidateEvidence(tx, candidateID, "youtube.com", normalizeProtocol(row.Protocol), raw, checked); err != nil {
|
||||
if err := saveCandidateEvidence(tx, candidateID, host, normalizeProtocol(row.Protocol), raw, checked); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user