Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repro/windows go issues #485

Merged
merged 2 commits into from
Apr 21, 2023
Merged

Repro/windows go issues #485

merged 2 commits into from
Apr 21, 2023

Conversation

tommyknows
Copy link
Contributor

chore: reproduce windows scanning issues

Customer has reported a bug with scanning some Go binaries on windows.
Interestingly, not all binaries seem to fail, only some. For the
failing binaries, no dependencies are being found.

This commit adds a test that runs on Windows to make sure that the
scanning works. The snapshot has been generated by running the test on
MacOS, which illustrates the point that they should produce the exact
same snapshot as the Windows one.

The only thing that needed changing was the filepaths, e.g. from
"targetFile": "/livenessprobe" to "targetFile": "\\livenessprobe".

fix: use path.posix for Go file / module lookup

This commit switches the usage of the path module to use path.posix
instead, fixing an issue where when the CLI was running on Windows, the
Go dependency resolution returned no results.

The underlying issue is that the Go binary metadata always contains
normal slashes in it's path, while our usage of path.join and
path.parse meant that we were constructing paths with backward-slashes
instead.

Customer has reported a bug with scanning some Go binaries on windows.
Interestingly, not all binaries seem to fail, only some. For the
failing binaries, no dependencies are being found.

This commit adds a test that runs on Windows to make sure that the
scanning works. The snapshot has been generated by running the test on
MacOS, which illustrates the point that they _should_ produce the exact
same snapshot as the Windows one.

The only thing that needed changing was the filepaths, e.g. from
`"targetFile": "/livenessprobe"` to `"targetFile": "\\livenessprobe"`.
This commit switches the usage of the `path` module to use `path.posix`
instead, fixing an issue where when the CLI was running on Windows, the
Go dependency resolution returned no results.

The underlying issue is that the Go binary metadata always contains
normal slashes in it's path, while our usage of `path.join` and
`path.parse` meant that we were constructing paths with backward-slashes
instead.
@tommyknows tommyknows requested a review from a team as a code owner April 21, 2023 09:35
@github-actions
Copy link

github-actions bot commented Apr 21, 2023

Expected release notes (by @tommyknows)

fixes:
use path.posix for Go file / module lookup (7401d21)

others (will not be included in Semantic-Release notes):
reproduce windows scanning issues (ecc5a7b)

  • I hereby acknowledge these release notes are 🥙 AWESOME 🥙

Copy link
Contributor

@pecodez pecodez left a comment

Choose a reason for hiding this comment

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

LGTM

@tommyknows tommyknows merged commit b56f997 into main Apr 21, 2023
@tommyknows tommyknows deleted the repro/windows-go-issues branch April 21, 2023 10:30
tommyknows added a commit to snyk/cli that referenced this pull request Apr 21, 2023
The new version contains a fix for Go binary scanning on Windows.

See snyk/snyk-docker-plugin#485.
@snyksec
Copy link

snyksec commented Apr 21, 2023

🎉 This PR is included in version 6.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

tommyknows added a commit to snyk/cli that referenced this pull request Apr 24, 2023
The new version contains a fix for Go binary scanning on Windows.

See snyk/snyk-docker-plugin#485.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants