Resuming a --since or --changed scan silently widens it to the whole tree

Ouverte
#119 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
go
Domaine
cli

Piste de recherche

Start with the resume hint in internal/cli/scan.go around lines 80-82, then check RunStart in internal/ledger/payload.go, which has no diff-base field, and the --resume checks in internal/engine/run.go around 105-120. Reproduce by running a --since scan that exhausts its budget, then resuming it without the flag and seeing old.go leads reported. Done means a resumed diff scan reports only changed-file leads, a mismatched diff base is refused or applied with a note, the hint includes the flag, and a test in internal/engine asserts no out-of-diff lead appears.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug severity: medium

Summary

A --since or --changed scan that runs out of budget prints a resume command that drops the diff flag. The run does not record its diff base, so running that command continues as a whole-tree scan, and findings from files the change never touched appear in what reads as a diff scan.

Where

  • internal/cli/scan.go:80-82 (resume hint)
  • internal/ledger/payload.go:8-35 (RunStart has no diff-base field)
  • internal/engine/run.go:105-120 (--resume checks; nothing compares the diff base)
  • internal/engine/run.go:184-188 (keepChanged runs only when changed != nil)
  • internal/engine/agentic.go:475-517 (leftoverFindings reports uninvestigated leads)

Details

// internal/cli/scan.go:80-82
if engine.Resumable(res.Run) {
    fmt.Fprintf(env.Stderr, "... To continue with the rest under a new budget:\n  spackle scan %s --resume %s\n", tgt, res.RunID)
}

RunStart stores no since or changed value, and internal/engine/resume.go never refers to either. A resumed run without the flag has changed == nil, so the diff filter is skipped. Every lead in the tree then reaches leftoverFindings, which reports each lead the resumed run did not investigate as an unconfirmed finding. The findings carried over from the first run were diff-filtered; the new ones are not.

Impact

A PR or pre-commit scan, resumed as the tool instructs, turns into a whole-repository report. fail_on can fail a CI job on code outside the diff, and nothing in the report says the file set changed between the two runs.

Steps to reproduce

  1. In a git repository, put a flaw a built-in rule catches in an unchanged file (old.go) and make a small change in new.go.
  2. spackle scan . --since HEAD~1 --max-usd <small> with a model, so the run ends budget-exhausted.
  3. Run the printed spackle scan . --resume <id>.
  4. The resumed report lists the old.go lead, although the first run's note said only changed files were reported. --changed behaves the same.

Suggested fix

Record the diff base in RunStart (for example DiffBase string, holding since:<rev> or changed). Restore it in loadResume, and either apply the stored base or refuse a --resume whose --since/--changed differs from it. Include the flag in the hint at scan.go:81.

Acceptance criteria

  • A resumed diff scan reports only leads in the changed files.
  • --resume with a different diff base from the stored run is refused, or the stored base is applied with a note.
  • The resume hint printed after a budget-exhausted diff scan includes --since <rev> or --changed.
  • A test resumes a budget-exhausted --since run and asserts that no lead outside the diff is reported.

Getting started

  • Relevant files: internal/engine/run.go, internal/engine/resume.go, internal/ledger/payload.go, internal/cli/scan.go
  • How to run tests: go test ./internal/engine ./internal/cli (or make test-short)
  • Related docs: docs/ci.md (diff scans), docs/superpowers/specs/

Filed by repo-audit/full-audit at fffef43. Severity: medium. Effort: M. audit-key: bug|internal/engine/run.go|Run resume diff base

Langage dominant
Go
Étoiles
0
Forks
1
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TMHSDigital/Spackle

Toutes les issues de TMHSDigital/Spackle

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.