Skip to content

Conversation

@JoeyShapiro
Copy link
Contributor

Description

This is a fix to allow windows to properly open and get the MIME type of a file during an FS scan. This was a PR to stereoscope, but it was decided to move it here. It also moves in a function and test from there that is only used for syft.

This allows this function to properly use the windows package to check and convert back to a windows path, so the file can be opened.

The function moved in still calls to stereoscope, because it requires structs and functions that are heavily integrated into that package.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

@kzantow
Copy link
Contributor

kzantow commented Oct 15, 2025

Thanks for the update here, @JoeyShapiro. It looks like your commits just need to have the DCO Sign-Off

Signed-off-by: Joseph Shapiro <[email protected]>
@JoeyShapiro
Copy link
Contributor Author

ok. I did a sign off. and I also made get_xid cross platform


f, err := os.Open(usablePath)
if err != nil {
// TODO: it may be that the file is inaccessible, however, this is not an error or a warning. In the future we need to track these as known-unknowns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this would be good to do as part of this PR, since we're introducing a function that we have full control over, e.g. return this error and have this returned as an "unknown" error, which can be reported in the SBOM. I can have a look at making this change, if you like

Signed-off-by: Joseph Shapiro <[email protected]>
@JoeyShapiro
Copy link
Contributor Author

I did the close and log part, but im not sure how to make an unknown error. I am fine doing it myself if you give me a hint of some kind

@kzantow
Copy link
Contributor

kzantow commented Oct 16, 2025

I haven't quite worked out all the details, but we will want to collect all the errors, for example in the errPaths and we will want to get all these path errors added to the Unknowns section of the SBOM. This is something many people probably don't know about, but we capture many errors and surface these with the file that the error originated from. Maybe we could add an option and get a reference to these path errors around here, it would probably require type asserting the file resolver to a new interface that has a PathErrs() <something>, because we shouldn't change the public API in a breaking way. I'm happy for you to make these changes, but it might take a little experimentation & digging to find the right spots for it, which is why I offered to help out.

@JoeyShapiro
Copy link
Contributor Author

I can try it out. I have had some experience with the unknowns. That is how I found this problem in the first place. It might have to wait until later today though, as I am currently at work. Especially if it would require some more work to add in the interfaces

@flichtenheld
Copy link

I can confirm that this fixes #4271

@kzantow
Copy link
Contributor

kzantow commented Oct 17, 2025

We can always get this merged as-is and worry about the unknowns later, I didn't mean to add a large ask here. I think I'm going to merge this, and if you do feel like contributing updates to handle unknowns, that would be great but can come as a new PR 👍

@kzantow kzantow merged commit 538b4a2 into anchore:main Oct 17, 2025
12 checks passed
@kzantow kzantow linked an issue Oct 17, 2025 that may be closed by this pull request
@JoeyShapiro
Copy link
Contributor Author

yeah, I didn't get a chance to look at it yesterday. I can always make another PR, or someone else can if they beat me to it. thanks for helping get this pulled in

spiffcs added a commit that referenced this pull request Oct 22, 2025
* main:
  chore(deps): update tools to latest versions (#4302)
  chore(deps): bump github.com/github/go-spdx/v2 from 2.3.3 to 2.3.4 (#4301)
  chore(deps): bump github/codeql-action from 4.30.8 to 4.30.9 (#4299)
  support universal (fat) mach-o binary files (#4278)
  chore(deps): bump sigstore/cosign-installer from 3.10.0 to 4.0.0 (#4296)
  chore(deps): bump anchore/sbom-action from 0.20.7 to 0.20.8 (#4297)
  convert posix path back to windows (#4285)
  Remove duplicate image source providers (#4289)
  chore(deps): bump anchore/sbom-action from 0.20.6 to 0.20.7 (#4293)
  feat: add option to fetch remote licenses for pnpm-lock.yaml files (#4286)
  Add PDM parser (#4234)
  chore(deps): update tools to latest versions (#4291)
  fix: panic during java archive maven resolution (#4290)
  Extract zip archive with multiple entries (#4283)
  chore: update to use old configuration on new cosign (#4287)
  chore(deps): update anchore dependencies (#4282)
  chore(deps): bump github.com/mholt/archives from 0.1.3 to 0.1.5 (#4280)
  add docs to configs (#4281)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

syft can't extract go module information from executables on Windows

3 participants