A diff scan (--since) still seeds the whole tree, and the lead cap applies before the diff filter

オープン
#88 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
go
領域
cli, performance

調査の方向性

Start in internal/engine/run.go around lines 175-180, where seed.RunAll runs over the whole tree before keepChanged in internal/engine/diffscan.go filters by diff. Then read capLeads in internal/seed/seed.go, since the per-seeder cap of 5000 runs before the diff filter. Done means a test with more than 5000 leads in unchanged files still reports a changed-file lead under --since, and built-in seeders read only changed files in a diff scan. Scanner-specific changes (semgrep, gitleaks, hadolint) need maintainer input first.

索引モデルが issue の本文から書いたものです。

説明

performance severity: medium

Summary

--since computes the changed files before mapping, but every seeder still runs over the whole tree, and leads outside the diff are thrown away afterwards. The per-seeder cap of 5000 leads is applied before that filter, so a new lead in a changed file can be dropped on large repositories.

Where

  • internal/engine/run.go:175-180
  • internal/engine/diffscan.go:38 (keepChanged)
  • internal/seed/seed.go:124 (capLeads inside RunAll)
  • docs/ci.md:133

Details

leads, statuses := seed.RunAll(ctx, seeders, root, m.Files, texts)  // whole tree, capped per seeder
leads, scanNotes := applyScanConfig(leads, opts.Config.Scan)
if changed != nil {
    leads, note = keepChanged(leads, changed, opts.Since)           // filtered afterwards

The built-in seeders are per-file, so running them on unchanged files is pure waste.

Impact

  • A PR scan of a 3-file change in a 100k-file repository reads and rule-matches every file; without a model it costs the same as a full scan on every push.
  • If one seeder has more than 5000 leads across the tree, the cap keeps the first 5000 in file order, and a lead in a changed file later in sort order is dropped before the diff filter. Only the seeder's status note mentions the drop.

Suggested fix

When changed != nil, pass only the changed files to the shared built-in pass, so the cap applies to changed-file leads only. Pass changed paths to scanners that accept file targets (semgrep, gitleaks, hadolint); keep whole-tree runs only where needed (osv-scanner, trivy). Update docs/ci.md:133.

Acceptance criteria

  • A test with more than 5000 leads in unchanged files still reports a lead in a changed file under --since.
  • Built-in seeders read only changed files in a diff scan.

Getting started

  • Relevant files: internal/engine/run.go, internal/engine/diffscan.go, internal/seed/seed.go
  • How to run tests: make test (Unix) or .\make.ps1 test (Windows PowerShell); one package: go test ./internal/<pkg>

Filed by repo-audit/full-audit at a7f6edc. Severity: medium. Effort: M. audit-key: performance|internal/engine/run.go|keepChanged

主要言語
Go
スター
0
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TMHSDigital/Spackle のほかの issue

TMHSDigital/Spackle の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。