Skip to content

fix(pkg-docker): reject unsafe build paths#810

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
aiirvizionz:clientkit/docker-path-guards
Jul 22, 2026
Merged

fix(pkg-docker): reject unsafe build paths#810
ralyodio merged 1 commit into
profullstack:masterfrom
aiirvizionz:clientkit/docker-path-guards

Conversation

@aiirvizionz

Copy link
Copy Markdown
Contributor

Summary

  • validate pkg-docker Dockerfile and context paths before writing build plans
  • reject absolute paths, parent traversal, backslashes, empty segments, and null bytes
  • keep existing relative Dockerfile/context planning behavior intact

Verification

  • vitest run packages/targets/pkg-docker/src/index.test.ts (7 passed)
  • tsc -p packages/targets/pkg-docker/tsconfig.json --noEmit
  • git diff --check

Note: running through pnpm in this workspace currently triggers an unrelated lockfile policy failure for @profullstack/autoblog@0.4.0 missing tarball integrity, so I ran the local Vitest and TypeScript binaries directly.

Copilot AI review requested due to automatic review settings July 21, 2026 22:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the pkg-docker target by validating Docker build context and Dockerfile paths before generating and writing the build plan, preventing unsafe path inputs from being embedded into the planned docker buildx commands.

Changes:

  • Added safeRelativePath() to validate context and dockerfile inputs (rejecting absolute paths, traversal, backslashes, empty segments, and null bytes).
  • Routed build argument planning and the emitted plan JSON through the new path validation.
  • Added a Vitest case covering several unsafe path examples.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/targets/pkg-docker/src/index.ts Introduces path validation and applies it to build arg generation and plan output.
packages/targets/pkg-docker/src/index.test.ts Adds tests asserting unsafe dockerfile/context values are rejected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +67 to +69
if (label !== 'context' && segments.some((segment) => segment === '.')) {
throw new Error(`pkg-docker ${label} must not contain current-directory segments`);
}
@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

2 similar comments
@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@ralyodio
ralyodio merged commit e9fac38 into profullstack:master Jul 22, 2026
4 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.

3 participants