Skip to content

Windows local Git scan duplicates the drive letter for file:///X:/ URIs #5161

Description

@paulcam206

TruffleHog Version

trufflehog 3.96.0

I reproduced this with the official
trufflehog_3.96.0_windows_amd64.tar.gz release artifact after verifying its
published SHA-256 checksum.

Trace Output

The minimized reproduction uses only a synthetic repository. The actionable
redacted parser/clone error is included below. I can provide a full
--log-level=5 Gist if additional trace detail is needed.

Expected Behavior

On Windows, trufflehog git should scan a local repository passed as an RFC
8089 absolute file URI such as file:///E:/temp/trufflehog-uri-repro.

RFC 8089 section E.2 explicitly identifies file:///c:/path/to/file as a
supported DOS/Windows file URI form.

Actual Behavior

The scan fails before scanning because the drive letter is duplicated:

failed to clone file Git repo (file://E:/E:/temp/trufflehog-uri-repro):
fatal: 'E:/E:/temp/trufflehog-uri-repro' does not appear to be a git repository

Changing only the source argument to file://E:/temp/trufflehog-uri-repro
allows the same repository to scan successfully. A raw native Windows path
(E:\temp\trufflehog-uri-repro) is rejected as an unsupported Git URI.

The current normalizeFileURI path parses file:///E:/... with an empty host
and /E:/... as the URL path, then calls filepath.Abs() on that value. On
Windows this expands to E:\E:\..., which is serialized as
file://E:/E:/....

Steps to Reproduce

  1. Create E:\temp\trufflehog-uri-repro as a Git repository with a baseline
    commit and a second commit containing only benign text.

  2. From the parent directory, run:

    trufflehog git file:///E:/temp/trufflehog-uri-repro `
      --since-commit <baseline-sha> `
      --branch HEAD `
      --no-update `
      --no-color `
      --results=verified,unknown `
      --fail `
      --fail-on-scan-errors
  3. Observe the duplicated-drive clone path and exit code 1.

  4. Run the same command with
    file://E:/temp/trufflehog-uri-repro; it completes successfully.

Environment

  • OS: Microsoft Windows 11 Enterprise Insider Preview
  • Shell: PowerShell 7.6.4
  • TruffleHog: official v3.96.0 Windows AMD64 release

Additional Context

Current main still contains the affected normalization path:

https://github.com/trufflesecurity/trufflehog/blob/6f3c981e7b77f235fd2702dd74af25fc4b72bf11/pkg/sources/git/git.go

A Windows regression test using file:///C:/... or file:///E:/... would
distinguish this case from the relative URI handling fixed by #4614.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions