Skip to content

Fix missing file hashes when running on windows system - #5341

Merged
wagoodman merged 8 commits into
mainfrom
triage/issue-5325-missing-hashes
Sep 30, 2026
Merged

wagoodman merged 8 commits into
mainfrom
triage/issue-5325-missing-hashes

Conversation

@wagoodman

@wagoodman wagoodman commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

On windows, the directory and file resolvers could not find files by path. The file tree is keyed on posix paths (/c/some/path), but lookups searched it with the native path (C:\some\path), so every FilesByPath, HasPath and root-anchored FilesByGlob call silently returned nothing. The most visible symptom is empty file digests for dir: scans (#5325), but anything resolving files by path was affected.

  • resolver requests are converted to posix before searching the file tree on windows
  • location paths from ToChrootPath and the directory source name derived from base are now always posix (previously backslash paths on windows)
  • windows.FromPosix no longer panics on input that isn't volume-encoded
  • added a Unit tests (Windows) CI job running a new make unit:windows task, scoped to the packages that handle host paths... Unit tests is now a gate over the linux and windows unit test jobs

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

Issue references

Closes #5325

@wagoodman wagoodman added bug Something isn't working windows regarding the windows OS labels Sep 28, 2026
- add a `Unit tests (Windows)` job running a new `make unit:windows` task, scoped to the packages that own host path handling (tests needing linux docker fixtures are skipped)
- `Unit tests` is now a gate job over the Linux and Windows unit jobs
- add a resolver test asserting that locations from `AllLocations` resolve again via `FilesByPath` and use posix paths. This is expected to fail on windows today, which is why file digests come back empty for `dir:` scans (#5325)
- fix windows-only test files that no longer compiled

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman
wagoodman force-pushed the triage/issue-5325-missing-hashes branch from 00d0808 to 9e18c6d Compare September 28, 2026 21:09
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
- chroot paths are always posix (`ToChrootPath` no longer returns backslash paths on windows), same for the directory source name derived from `base`
- `windows.FromPosix` no longer panics on input that isn't volume-encoded (e.g. relative or already native paths)
- skip tests on windows that rely on symlink fixtures, shell script fixtures, or emulate windows paths on a posix host
- disable `core.autocrlf` on the windows CI job so fixture digests match linux

This leaves only the `FilesByPath` lookup failures from #5325.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
- `allContainedPaths` cleaned with the native separator but split on `/`, so a root reached through a symlink never had its ancestors indexed on windows
- index assertions in tests now key on the posix path the index actually stores
- skip symlink fixture tests and a posix-only test helper on windows

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@oss-housekeeper oss-housekeeper Bot added the dependencies dealing with project dependencies label Sep 28, 2026
- restore `go.sum` and `.make/go.sum` (accidentally populated by a local `-mod=mod` invocation)
- revert the `allContainedPaths` separator change: production passes native windows paths there, and splitting them on `/` produces drive-relative ancestors, so skip the posix-only test on windows instead
- annotate the remaining `filepath` usages that operate on native paths

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@oss-housekeeper oss-housekeeper Bot removed the dependencies dealing with project dependencies label Sep 29, 2026
The directory and file resolvers key their file tree on posix paths (`/c/some/path`), but `FilesByPath`, `HasPath` and root-anchored `FilesByGlob` searched it with the native path from the chroot context (`C:\some\path`). On windows every lookup silently missed, so anything that resolves files by path found nothing. This is why file digests were empty for `dir:` scans.

Requests are now converted to posix before searching the tree.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman assigned wagoodman and unassigned wagoodman Sep 29, 2026
@wagoodman
wagoodman marked this pull request as ready for review September 29, 2026 01:37
@wagoodman
wagoodman enabled auto-merge (squash) September 29, 2026 13:21
Comment thread .github/workflows/validations.yaml Resolved
Comment thread .make/main.go Resolved
- check out text files with lf on every platform via `* text=auto eol=lf`, so windows checkouts match linux regardless of `core.autocrlf`
- keep the fixtures that are intentionally crlf (jar manifests, etc) untouched with `-text`
- drop the `core.autocrlf` step from the windows CI job, which this replaces

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman
wagoodman merged commit 6ac7afb into main Sep 30, 2026
17 checks passed
@wagoodman
wagoodman deleted the triage/issue-5325-missing-hashes branch September 30, 2026 13:08
spiffcs added a commit that referenced this pull request Sep 30, 2026
* main: (91 commits)
  feat: catalog CPAN distributions installed by perl clients (#5131)
  fix(binary): correct traefik version detection on big-endian arches (#5281)
  Fix hang when scanning a Java resource adapter (.rar) file (#5348)
  chore(deps): update SPDX license list (#5315)
  fix: match opensource.org license URLs across SPDX URL forms (#5361)
  Speed up unit tests in CI (#5360)
  Fix missing file hashes when running on windows system (#5341)
  Stop reading the mount table for every single-file source (#5257)
  fix: conan expat CPE (#5259)
  fix(spdx): write a name for the root package when the source has none (#5349)
  fix(python): link uv.lock dependents to the locked version they name (#5351)
  fix: suppress misleading upstream CPE for PHP extension binaries (#5102)
  fix: report scanner errors and raise the line cap in metadata parsers (#5353)
  Harden cataloger parsers against truncated input (do not panic) (#5355)
  fix(cpe): bound CPE candidate generation for pathological package metadata (#5356)
  test(golang): make the UPX fixture exercise loader padding (#5354)
  fix(golang): account for UPX's loader padding when unpacking Go binaries (#5347)
  test(snap): bound the kernel changelog bomb fixture by ratio, not a fixed 1MB (#5352)
  test(debian): bound the bomb fixture by ratio, not a fixed 1MB (#5350)
  fix(ai): handle malformed GGUF headers without panicking (#5345)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working windows regarding the windows OS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File Digests Remain at Zero, No Hashes Available Despite .syft.yaml Settings Should Support.

2 participants