--changed refusals name --since, and the diff mode is chosen by comparing a display string

未关闭
#127 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
cli

调研方向

Start in internal/engine/diffscan.go, where changedSince compares rev against the uncommitted label, then check the refusal text at internal/engine/run.go lines 70 and 115-120 to see which flag name is hard-coded. Next, read the MCP scan handler in internal/mcp/tools.go around lines 369-379 to see how since and changed are passed through. Done means every refusal names the flag or argument the caller used, no code compares against the display label, and TestSinceRefusals plus new cases for --changed on a git URL and a blank MCP since pass under go test ./internal/engine ./internal/mcp.

由索引模型根据 Issue 内容生成。

描述

bug severity: low

Summary

The diff-scan mode is carried as the human-readable label "the last commit (uncommitted changes)", and the code decides which git command to run by comparing the revision with that text. One refusal still names --since when --changed caused it, and the MCP scan tool reports CLI flag names and treats a blank since as a full scan.

Where

  • internal/engine/diffscan.go:13-27 (const uncommitted = ..., diffBase)
  • internal/engine/diffscan.go:28-51 (changedSince compares rev == uncommitted three times)
  • internal/engine/run.go:115-120 (refusals)
  • internal/mcp/tools.go:369-379 (MCP scan passes since/changed through)

Details

const uncommitted = "the last commit (uncommitted changes)"
...
flag := "--since"
if rev == uncommitted {
	flag = "--changed"
}
// run.go:118-119
if diffBase(opts) != "" && tgt.Kind != target.KindPath {
    return Result{}, fmt.Errorf("%w: --since compares a checkout with a base revision, and %s is not a directory. ...", ErrRefused, tgt.Display)
}

Checklist:

  • spackle scan --changed https://github.com/example/none.git prints "run refused: --since compares a checkout with a base revision ...", naming a flag the user did not pass. run.go:70-72 was updated to name both flags; this check was not.
  • --since "the last commit (uncommitted changes)" silently runs a --changed scan.
  • An MCP client gets "--since and --changed choose different file sets" (run.go:116), with CLI flag names instead of the tool's argument names.
  • MCP since: " " is trimmed to "" and silently runs a full scan instead of reporting an empty revision.

Impact

Users get error text that misnames their input. Rewording the report note would change behavior, and a third diff mode (for example --staged) would need another sentinel string.

Suggested fix

  1. Build a diffSpec{flag, rev, label string; list func(ctx, root) ([]string, error)} once in Run from opts (nil for a full scan). Pass it to changedSince and keepChanged, and delete the rev == uncommitted comparisons.
  2. Use spec.flag in the refusals at run.go:70 and run.go:118. For --changed, say it lists uncommitted work in a local checkout.
  3. In the MCP scan tool, reject a blank since and since together with changed before calling the engine, with messages that use the argument names.

Acceptance criteria

  • Every refusal names the flag (CLI) or argument (MCP) the caller actually used.
  • No code path compares a revision with the display label.
  • Tests cover --changed on a git URL and MCP since: " ".

Getting started

  • Relevant files: internal/engine/diffscan.go, internal/engine/run.go, internal/mcp/tools.go
  • How to run tests: go test ./internal/engine ./internal/mcp (existing: TestSinceRefusals, TestChangedLimitsTheScanToUncommittedFiles)

Filed by repo-audit/full-audit at fffef43. Severity: low. Effort: S. audit-key: bug|internal/engine/diffscan.go|diffBase

主要语言
Go
星标
0
派生
1
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/Spackle 的其他 Issue

查看 TMHSDigital/Spackle 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。