Skip to content

docker_lint.py --root mounts the live checkout, bypassing a repo's secrets-on-disk exclusion #1090

Description

@ptr727

Symptom

A CodeRabbit review on ptr727/ESPHome-Config#115
(a hub resync carrying GOVERNANCE.md's "Running the Linters Locally" section, hub commit
3258284) flagged that its documented docker_lint.py invocation,
python3 /path/to/ProjectTemplate/scripts/docker_lint.py --root "$PWD", mounts the live checkout
straight into each lint container.

Root cause

docker_mount() in scripts/docker_lint.py binds the --root path as-is
(type=bind,"src={root}",dst={destination},readonly); it never builds a sanitized snapshot or
excludes git-ignored paths. Read-only stops the container from writing back, not from reading
whatever real files sit in the working tree.

Why this matters

ESPHome-Config's OPERATIONS.md already documents this exact hazard for third-party lint
containers generally, from a real past incident (secrets.yaml holding live device credentials,
git-ignored but present on disk): the fix there is to snapshot tracked-plus-intended-untracked
files into a temp dir first (git ls-files --cached --others --exclude-standard), then mount
that. docker_lint.py --root "$PWD" bypasses that protection when run literally as the hub's own
docs show it, in any repo that keeps a real secret file on disk alongside a tracked placeholder
(this pattern is not unique to ESPHome-Config).

Suggested fix

Either have docker_lint.py build its own tracked-plus-untracked-unignored snapshot before
mounting (consistent with how it already discovers lint targets via git ls-files/unignored
files elsewhere in the script), or add a documented --root caveat next to the invocation in
GOVERNANCE.md "Running the Linters Locally" pointing at the same snapshot pattern, so a repo
carrying that section verbatim doesn't have to know to add its own caveat.

Workaround applied downstream

ESPHome-Config#115 extends its own OPERATIONS.md "Repository Tooling Hazards" bullet to say
docker_lint.py --root must be the sanitized snapshot path, never the live checkout, since
OPERATIONS.md is this repo's own content and not hub-carried.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions