Skip to content

Container audit loses the repository identity: git refuses the mounted repo (dubious ownership) #586

Open

Description

@Marc-cn

With the documented command, docker run --rm -v "$PWD:/repo" <image> audit, on Linux:

Platform API call /repos//repo/releases?per_page=5 could not be measured (unavailable)
handler github_branch_protection needs owner/repo (from context or config)
Trust: unknown repository untrusted (no repository identity)

The owner is empty and the name is the mount directory (repo), so every platform check fails.

The cause is the container runs as uid 10001. The mounted repository belongs to the host user. git refuses it:

$ git -C /repo remote get-url origin
fatal: detected dubious ownership in repository at '/repo'

Confirmed workaround

docker run --rm -v "$PWD:/repo" \
  -e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0=/repo \
  <image> audit

With this, git returns the remote and the audit calls /repos/darnitdevorg/darnit/....

Possible fix

Set safe.directory=/repo in the image (Dockerfile ENV or the entrypoint). This turns off git's ownership check for the mounted repo, so it is worth a short look at what a hostile .git/config could do inside the container. The alternative is to document --user "$(id -u):$(id -g)", which I have not tested.

Related

Seen on RHEL 10 with podman (rootful), image built from the #519 branch.

Activity

  1. mlieberman85 commented on Oct 16, 2026

    @mlieberman85
    Contributor

    Thanks for finding the cause and testing the workaround. Setting safe.directory=/repo in the image makes sense to me.

    On your question about a hostile .git/config: yes, it can run programs. darnit runs git status, which runs core.fsmonitor. But git clone never copies .git/config, so this only matters for a directory whose .git came from someone else. And that case is already exposed without the container: on the host the user owns the files, so git trusts the config anyway. The ownership check here only fires because of the uid mismatch, so turning it off in the image adds no risk over a native run. I've opened #617 for the underlying problem, which is darnit's own git calls.

    Could the same PR add -e GH_TOKEN to docs/install/container.md? The platform checks need it.

    Drafted with Claude Code; reviewed and posted by me.

  2. added
    infrastructureBuild, CI/CD, and project infrastructure
    documentationImprovements or additions to documentation
    and removed
    needs triageAwaiting maintainer review
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationinfrastructureBuild, CI/CD, and project infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions