Skip to content

types: read a file mode as an unsigned 32 bit number - #965

Merged
ndeloof merged 2 commits into
compose-spec:mainfrom
ndeloof:file-mode-range
Oct 25, 2026
Merged

ndeloof merged 2 commits into
compose-spec:mainfrom
ndeloof:file-mode-range

Conversation

@ndeloof

@ndeloof ndeloof commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

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: -1 on a secret or a config was accepted, then marshaled as 0-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=) with strconv.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, where 440 is 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

Comment thread loader/tests/secrets_test.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues in the focused validation change, regression tests, or fuzz coverage update.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The bounded validation change, regression coverage, and fuzzing update are consistent, with no unresolved findings.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused validation changes match the intended behavior and include regression coverage, with no unresolved findings.

No open issues 🎉

Review effort: Balanced

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
ndeloof merged commit f05c125 into compose-spec:main Oct 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants