Fix on a CRLF file holding a multi-line secret is always rejected
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 78/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Go
- Estrelas
- 0
- Forks
- 1
- Merge médio
- 8h 14min
- PRs com merge (30d)
- 3
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Inclui um Dockerfile ou arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de TMHSDigital/Spackle
-
ci good first issue severity: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
TMHSDigital/Spackle#206 ·
Mantenedores costumam responder em até 1 dia
-
ci severity: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
TMHSDigital/Spackle#205 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue severity: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
TMHSDigital/Spackle#199 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue severity: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 87/100
TMHSDigital/Spackle#195 ·
Mantenedores costumam responder em até 1 dia
-
documentation good first issue severity: medium
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
TMHSDigital/Spackle#188 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de TMHSDigital/Spackle
Issues semelhantes
-
bug effort:s impact:med raised-by:worker risk:low to:worker
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
medici-finance/assay#8120 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
factory:subtask
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
agent-substrate/substrate#4308 ·
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
celestiaorg/celestia-app#8877 ·
Mantenedores costumam responder em até 1 dia
-
sweep
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 84/100
bketelsen/truenas-mcp#112 ·
Mantenedores costumam responder em até 1 dia