Skip to content

policy: normalize local policy paths#3944

Open
crazy-max wants to merge 2 commits into
docker:masterfrom
crazy-max:policy-windows-policy-paths
Open

policy: normalize local policy paths#3944
crazy-max wants to merge 2 commits into
docker:masterfrom
crazy-max:policy-windows-policy-paths

Conversation

@crazy-max

Copy link
Copy Markdown
Member

needs #3943

Was testing some policies on multiple machines and it fails in a case on Windows because fs.FS paths must use forward slashes, but local policy paths were cleaned with filepath.Clean, which produces backslashes on Windows. That made valid policy files fail to load with invalid argument:

mkdir bx-policy-repro\policy
Set-Content bx-policy-repro\Dockerfile "FROM scratch"
Set-Content bx-policy-repro\policy\allow.rego @'
package docker

default allow := true

decision := {"allow": allow}
'@

cd bx-policy-repro
docker buildx build --check --policy "filename=cwd://policy/allow.rego" .
failed to stat policy file cwd://policy/allow.rego: stat policy\allow.rego: invalid argument

The policy loader now converts local and cwd:// policy filenames with filepath.ToSlash and path.Clean before resolving them through the policy filesystem.

crazy-max added 2 commits July 7, 2026 10:34
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max marked this pull request as ready for review July 7, 2026 15:55
@crazy-max crazy-max requested a review from tonistiigi July 7, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant