Repository navigation
types: read a file mode as an unsigned 32 bit number - #965
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused validation changes have no identified blocking issues; the remaining feedback is a non-blocking diagnostic-test improvement.
1 open issue
What changed in this PR
This PR aligns compose-go’s secret and config file-mode parsing with the Docker CLI’s unsigned 32-bit range, addressing the round-trip failure identified by fuzzing in #962.
Changes:
- Reject negative, oversized, and invalid octal modes with value-specific errors.
- Add regression cases for invalid secret modes.
- Remove the negative-mode exclusion from loader round-trip fuzzing.
| File | Description |
|---|---|
types/types.go |
Validate file modes as unsigned 32-bit values. |
loader/tests/secrets_test.go |
Cover rejection of invalid file modes. |
loader/loader_fuzz_test.go |
Remove the obsolete negative-mode workaround. |
Review effort: Balanced
ndeloof
force-pushed
the
file-mode-range
branch
from
October 23, 2026 14:27
1d287ce to
10b3b0a
Compare
ndeloof
force-pushed
the
file-mode-range
branch
from
October 25, 2026 07:59
10b3b0a to
efcab7a
Compare
ndeloof
force-pushed
the
file-mode-range
branch
from
October 25, 2026 08:14
efcab7a to
cc1eee2
Compare
The mode of a secret or a config accepted a negative number, which marshaled as `0-1` and did not load back, and a number of any size. The Docker CLI reads the mode of a secret as an unsigned 32 bit number (`strconv.ParseUint(..., 32)`): so does Compose now for the range, with an error naming the value for anything outside of it. The syntax stays Compose's own: text is an octal number, where the CLI reads it with base 0 (`440` is decimal there). Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
A negative file mode is rejected now, so it no longer needs to be left out of the round trip. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
ndeloof
force-pushed
the
file-mode-range
branch
from
October 25, 2026 08:22
cc1eee2 to
eda9f36
Compare
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this PR does, in one sentence
The mode of a secret or a config is now read as an unsigned 32 bit number, the range the Docker CLI accepts, instead of accepting values that cannot be used.
Context
mode: -1on a secret or a config was accepted, then marshaled as0-1, which does not load back, and a mode of any size was accepted. The Docker CLI reads the mode of a secret (--secret ...,mode=) withstrconv.ParseUint(..., 32), so neither a negative nor an oversized mode gets through. Found by the fuzzer added in #962.What the PR brings
A negative mode and a mode that does not fit in 32 bits are rejected when the file is loaded, with an error that names the value (
invalid file mode "-1": ...) and the attribute. The syntax is unchanged and stays Compose's own: text is an octal number (the CLI reads it with base 0, where440is decimal), and a number is taken as YAML reads it. Every mode that was usable before still loads, except text with a sign ("+440","-0"), which the CLI rejects as well. This tightens what loads: a file with a negative or oversized mode used to load and now fails. The fuzzer no longer leaves projects with a file mode out of its round trip.🤖 Generated with Claude Code