Fix on a CRLF file holding a multi-line secret is always rejected
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Read internal/agent/fixer.go around loadOriginals, restoreSecrets, and hideKnownSecrets, then compare its input handling with the model view in internal/agent/tools/tools.go and internal/walk/walk.go. Update internal/agent/fixer_test.go to build that view in production order and cover CRLF multi-line secrets and a UTF-8 BOM. Done means the marker is accepted, secret bytes and CRLF endings are preserved, and the BOM remains.
由索引模型根據 Issue 內容生成。
描述
Summary
Every fix that touches a CRLF file containing a multi-line secret (for example a PEM block) is rejected, because the redaction marker the model saw was hashed over the LF form and the fixer looks it up over the CRLF form.
Where
internal/agent/fixer.go:108(loadOriginalsreads the raw bytes)internal/agent/fixer.go:142-158(restoreSecrets)internal/agent/tools/tools.go:365-378(model view:walk.ReadTextthenredact.KeepLinesIn)internal/walk/walk.go:387(ReadTextstrips the BOM and turns CRLF into LF)internal/agent/fixer_test.go:486(test builds the view in the opposite order)
Details
The model reads a file through Registry.text: walk.ReadText (strips a UTF-8 BOM, turns every CRLF into LF) and only then redact.KeepLinesIn. The marker for a secret that spans lines therefore carries the hash of the LF form of the value. loadOriginals reads the same file raw and restoreSecrets computes redact.MatchesIn(file, orig) on the CRLF bytes. The value there holds \r\n, so its hash is different, the marker in the model's content never matches, and the check fires: "it holds a redaction marker that stands for no secret in the file". The code clearly means to support this case (the eol handling), and TestRestoreSecretsKeepsAMultiLineKeyInACRLFFile passes only because it redacts the CRLF text first and converts line endings second, the reverse of production.
Same root cause, smaller symptom: ReadText strips the BOM and loadOriginals puts back line endings only, so a fix to a file that starts with a BOM silently removes the BOM and the patch shows line 1 as changed.
Impact
On a checkout with CRLF line endings (the default on Windows with core.autocrlf=true), every fix and every debug fix that touches a file holding a multi-line secret is rejected on every attempt when the model keeps the marker, as the fixer prompt tells it to. The run spends all max_attempts model conversations and reports that no patch passed verification.
Steps to reproduce
- Create
app.pywith CRLF endings holding a triple-quoted PEM private key block and one more line of code. - Take the model view as production does:
redact.KeepLinesIn("app.py", walk.ReadText(abs)), and change the other line. - Pass the result to
loadOriginals(root, {"app.py": content}): it returns the "redaction marker that stands for no secret" error. - Repeat with LF endings: it succeeds.
Suggested fix
In restoreSecrets (and hideKnownSecrets), compute the matches on the view the model had: normalize orig the way walk.ReadText does, take markers and values from that text, and map each value back to its raw form (LF to the file's line ending) before substituting. Put the BOM back when the original had one. Change the test to build the view as production does (KeepLinesIn over the ReadText-normalized text).
Acceptance criteria
- A fix to a CRLF file with a multi-line secret is accepted when the model keeps the marker
- The written file keeps its CRLF endings and the secret bytes unchanged
- A fix to a file with a UTF-8 BOM keeps the BOM
- The test builds the model view in production order
Getting started
- Relevant files: internal/agent/fixer.go, internal/agent/fixer_test.go, internal/agent/tools/tools.go, internal/walk/walk.go
- How to run tests:
make test-short(Unix) or.\make.ps1 test-short(Windows PowerShell);make lintbefore you call it done - Related docs: CONTRIBUTING.md, docs/ARCHITECTURE.md
Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: S. audit-key: bug|internal/agent/fixer.go|restoreSecrets
- 主要語言
- Go
- 星號
- 0
- 分支
- 1
- 平均合併
- 8 小時 14 分鐘
- 30 天內合併 PR
- 3
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TMHSDigital/Spackle 的其他 Issue
-
ci good first issue severity: low
難度 2/5 1-3 小時 新手友好度 77/100
TMHSDigital/Spackle#206 ·
維護者通常 1 天內回覆
-
ci severity: low
難度 2/5 1-3 小時 新手友好度 78/100
TMHSDigital/Spackle#205 ·
維護者通常 1 天內回覆
-
bug good first issue severity: low
難度 2/5 1-3 小時 新手友好度 82/100
TMHSDigital/Spackle#199 ·
維護者通常 1 天內回覆
-
bug good first issue severity: low
難度 2/5 1-3 小時 新手友好度 87/100
TMHSDigital/Spackle#195 ·
維護者通常 1 天內回覆
-
documentation good first issue severity: medium
難度 1/5 1 小時以內 新手友好度 90/100
TMHSDigital/Spackle#188 ·
維護者通常 1 天內回覆
查看 TMHSDigital/Spackle 的全部 Issue
相似的 Issue
-
bug effort:s impact:med raised-by:worker risk:low to:worker
難度 2/5 1-3 小時 新手友好度 78/100
medici-finance/assay#8120 · 1 則留言 ·
維護者通常 1 天內回覆
-
factory:subtask
難度 1/5 1 小時以內 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
agent-substrate/substrate#4308 ·
維護者通常 2 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
celestiaorg/celestia-app#8877 ·
維護者通常 1 天內回覆
-
sweep
難度 1/5 1 小時以內 新手友好度 84/100
bketelsen/truenas-mcp#112 ·
維護者通常 1 天內回覆