Skip to content

cds get Dockerfile COPY glob with .. escapes build context, then crashes with unhandled traceback #475

Description

@SemTiOne

Summary

_extract_dockerfile_instruction_sources (getter.py:355) runs context_path.glob(source) on COPY/ADD source patterns from a module's Dockerfile. Path.glob follows .. segments, so a source like ../outside matches files outside the build context. Verified: Path('ctx').glob('../outside.txt') returns the file outside ctx/.

Problem

The match is resolved and added to the asset set without a _require_within_repo check. Later, _add_copy_action calls relative_to(source_repo) on it (getter.py:510), which raises an unhandled ValueError for out-of-repo paths. cds get dies with a raw traceback instead of a GetError; violating the documented "completes safely" contract; when pointed at a source repo whose Dockerfile contains COPY ../....

Suggested fix

  • Reject source patterns containing .. segments (or validate each glob match with _require_within_repo).
  • Wrap the relative_to in _add_copy_action so a stray path surfaces as GetError, not a traceback.

Files involved

  • cli/getter.py (lines 343-360, 503-524)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI commands and behaviorbugSomething isn't workinggood first issueGood for newcomerspriority:lowNice to have, low urgency

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions