diff --git a/go/cmd/vanir_sandbox/main.go b/go/cmd/vanir_sandbox/main.go index fe59f3c7424..b3e68b6d724 100644 --- a/go/cmd/vanir_sandbox/main.go +++ b/go/cmd/vanir_sandbox/main.go @@ -176,11 +176,17 @@ func (s *sandboxServer) handleGenerate(w http.ResponseWriter, r *http.Request) { //nolint:gosec // G115: uidBase + (n % uidSpan) is always in [10000, 59999]. uid := uint32(uidBase + (n % uidSpan)) + start := time.Now() + logger.InfoContext(ctx, "Generating Vanir signatures", + slog.String("vuln_id", meta.ID), + slog.Int64("seq", n)) + sigs, err := s.executeRequest(ctx, n, uid, meta.ID, &req) if err != nil { logger.ErrorContext(ctx, "Sandbox execution failed", slog.String("vuln_id", meta.ID), slog.Int64("seq", n), + slog.Duration("duration", time.Since(start)), slog.Any("error", err)) status := http.StatusInternalServerError if errors.Is(err, errChildTimeout) { @@ -191,6 +197,12 @@ func (s *sandboxServer) handleGenerate(w http.ResponseWriter, r *http.Request) { return } + logger.InfoContext(ctx, "Generated Vanir signatures", + slog.String("vuln_id", meta.ID), + slog.Int64("seq", n), + slog.Bool("has_signatures", len(sigs) > 2), + slog.Duration("duration", time.Since(start))) + respBytes, err := json.Marshal(GenerateResponse{Signatures: sigs}) if err != nil { http.Error(w, fmt.Sprintf("failed to marshal response: %v", err), http.StatusInternalServerError) diff --git a/go/internal/vanir/runner.go b/go/internal/vanir/runner.go index 1879a436f6f..484f1b799cf 100644 --- a/go/internal/vanir/runner.go +++ b/go/internal/vanir/runner.go @@ -193,22 +193,30 @@ func (r *Runner) Run(ctx context.Context) error { var allFailedIDs []string for outcome := range outcomeCh { + prevMilestone := totalProcessed / 100 totalProcessed += outcome.processed totalGenerated += outcome.generated allFailedIDs = append(allFailedIDs, outcome.failedIDs...) + if totalProcessed/100 > prevMilestone { + logger.InfoContext(ctx, "Vanir signature generation progress", + slog.Int("processed", totalProcessed), + slog.Int("generated", totalGenerated), + slog.Int("failed", len(allFailedIDs))) + } } if fatalErr != nil { return fatalErr } - logger.InfoContext(ctx, "Finished Vanir signature generation", - slog.Int("processed", totalProcessed), - slog.Int("generated", totalGenerated)) - slices.Sort(allFailedIDs) uniqueFailedIDs := slices.Compact(allFailedIDs) + logger.InfoContext(ctx, "Finished Vanir signature generation", + slog.Int("processed", totalProcessed), + slog.Int("generated", totalGenerated), + slog.Int("failed", len(uniqueFailedIDs))) + if r.Config.DryRun { logger.InfoContext(ctx, "Dry run: would have updated last_run", slog.Time("last_run", currentRun)) if len(uniqueFailedIDs) > 0 { @@ -236,11 +244,23 @@ func (r *Runner) processBatch(ctx context.Context, batch []*osvschema.Vulnerabil return 0, nil } - logger.InfoContext(ctx, "Processing batch of vulnerabilities", slog.Int("count", len(batch))) + if len(batch) == 1 { + logger.InfoContext(ctx, "Processing vulnerability", slog.String("id", batch[0].GetId())) + } else { + logger.InfoContext(ctx, "Processing batch of vulnerabilities", slog.Int("count", len(batch))) + } sigMap, err := r.Generator.GenerateBatch(ctx, batch) if err != nil { - logger.ErrorContext(ctx, "Failed to generate Vanir signatures for batch", slog.Int("count", len(batch)), slog.Any("error", err)) + if len(batch) == 1 { + logger.ErrorContext(ctx, "Failed to generate Vanir signatures", + slog.String("id", batch[0].GetId()), + slog.Any("error", err)) + } else { + logger.ErrorContext(ctx, "Failed to generate Vanir signatures for batch", + slog.Int("count", len(batch)), + slog.Any("error", err)) + } ids := make([]string, 0, len(batch)) for _, v := range batch { ids = append(ids, v.GetId()) @@ -276,6 +296,7 @@ func (r *Runner) processBatch(ctx context.Context, batch []*osvschema.Vulnerabil continue } if updated { + logger.InfoContext(ctx, "Updated vulnerability with Vanir signatures", slog.String("id", id)) updatedCount++ } }