Uh oh!
There was an error while loading. Please reload this page.
fix(attest): don't preserve file ownership when packaging attachments - #1076
Conversation
Claude finished @mbevc1's task in 1m 10s —— View job ReviewI re-reviewed after the latest push. The fix is correct, minimal, and well-tested. Both points from the earlier review are now resolved. Static analysis
Correctness of the fix
Tests — thorough and thoughtfully written:
Minor observations (non-blocking)
Nice work — the commit messages and the in-code comment ( LGTM. 👍 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Passing two or more evidence paths to `kosli attest` staged each path into a temp dir before tarring, and asked github.com/otiai10/copy to preserve uid and gid. That is implemented with Lchown, which a non-root process cannot use to chown a file to a foreign uid, so the command aborted with chown /tmp/1800768837/reports/rubocop/junit.xml: operation not permitted whenever any attachment had been written by a docker container rather than by the CLI user. Lint, test and coverage output produced in a container is the common case, so adding a second --attachments broke commands that were green the day before. The copy is only a staging area for the tarball that gets uploaded, and nothing downstream reads uid or gid. The single-path branch never copies and so never chowned, which is why it kept working. Dropping `PreserveOwner` makes the multi-path branch agree with it. Also wrap the copy error with the evidence path the user passed, so a genuine failure names their own input rather than only a temp directory they never created. Fixes#1075
The Lint job flagged four errcheck violations in the new tests: two deferred
Close calls in readTarHeaders and two deferred os.RemoveAll cleanups. All four
are deliberately ignorable, so ignore them explicitly with the
`defer func() { _ = ... }()` idiom already used elsewhere in these tests.
Also wrap the copy error with %w rather than %v, so a caller can still reach the
underlying error through errors.Is/errors.As, and assert that in the test.Uh oh!
There was an error while loading. Please reload this page.
Passing two or more evidence paths to
kosli atteststaged each path into a temp dir before tarring, and asked github.com/otiai10/copy to preserve uid and gid. That is implemented with Lchown, which a non-root process cannot use to chown a file to a foreign uid, so the command aborted withwhenever any attachment had been written by a docker container rather than by the CLI user. Lint, test and coverage output produced in a container is the common case, so adding a second --attachments broke commands that were green the day before.
The copy is only a staging area for the tarball that gets uploaded, and nothing downstream reads uid or gid. The single-path branch never copies and so never chowned, which is why it kept working. Dropping
PreserveOwnermakes the multi-path branch agree with it.Also wrap the copy error with the evidence path the user passed, so a genuine failure names their own input rather than only a temp directory they never created.
Fixes#1075
Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR