Skip to content

fix(kitfile): reject layer paths outside the context directory - #1289

Open
ManthanNimodiya wants to merge 1 commit into
kitops-ml:mainfrom
ManthanNimodiya:fix/pack-reject-paths-outside-context
Open

ManthanNimodiya wants to merge 1 commit into
kitops-ml:mainfrom
ManthanNimodiya:fix/pack-reject-paths-outside-context

Conversation

@ManthanNimodiya

Copy link
Copy Markdown

Description

Kitfile validation only rejected absolute paths and skipped prompt paths entirely, so ../ or absolute layer paths packed an empty layer.
Validation now rejects any local layer path that escapes the context directory and applies path checks to prompts too.

  • pkg/artifact/kitfile.go: add prompts to path checks; reject non-local paths (same rule as filesystem.VerifySubpath)
  • pkg/artifact/testdata/validation/: cases for ../ prompt, ../ dataset, absolute prompt, and a valid in-context path

Note: prompts now also get the existing duplicate-path check, same as all other layer types.

Linked issues

Fixes #1286

AI-Assisted Code

  • This PR contains AI-generated code that I have reviewed and tested
  • I take full responsibility for all code in this PR, regardless of how it was created

Validate now rejects non-local paths and checks prompt paths, so pack fails instead of writing an empty layer.

Signed-off-by: ManthanNimodiya <manthannimodiya989898@gmail.com>
@ManthanNimodiya
ManthanNimodiya force-pushed the fix/pack-reject-paths-outside-context branch from 00ea01f to 6e994d7 Compare October 31, 2026 17:57

This branch has not been deployed

No deployments
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.

pack silently produces an empty layer for a path outside the context directory

1 participant