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

Return both failures when failed to retrive an image with a scheme #1801

Merged
merged 1 commit into from
May 23, 2023

Conversation

FrimIdan
Copy link
Contributor

@FrimIdan FrimIdan commented May 9, 2023

This PR is meant to solve an issue we've got when syft failed to print the "right" error upon fetch failure.

For example, i'm trying to scan an arm64 image with an amd64 syft CLI and i'm getting the following error:

$ syft docker:idanfrim/multi-arch:only-arm64
 ⠸ Pulling image

2023/05/09 10:29:44 error during command execution: 1 error occurred:
	* failed to construct source from user input "docker:idanfrim/multi-arch:only-arm64": could not fetch image "idanfrim/multi-arch:only-arm64": unable to determine image source to select platform

The error is not clear, unable to determine image source is wrong since i've provided docker scheme.
When running the same command with debug I can see the correct failure.

$ syft -v docker:idanfrim/multi-arch:only-arm64
[0000]  INFO syft version: 0.77.0
[0003]  INFO new version of syft is available: 0.80.0 (current version is 0.77.0)
[0006]  WARN scheme "docker" specified, but it coincides with a common image name; re-examining user input "docker:idanfrim/multi-arch:only-arm64" without scheme parsing because image retrieval using scheme parsing was unsuccessful: unable to use DockerDaemon source: image has unexpected architecture "arm64", which differs from the user specified architecture "amd64"
2023/05/09 12:04:11 error during command execution: 1 error occurred:
	* failed to construct source from user input "docker:idanfrim/multi-arch:only-arm64": could not fetch image "idanfrim/multi-arch:only-arm64": unable to determine image source to select platform

So in this PR I've returned both errors so it will be more clear:

$ ./snapshot/darwin-build_darwin_amd64_v1/syft docker:idanfrim/multi-arch:only-arm64
 ⠙ Pulling image

2023/05/09 10:29:09 error during command execution: 1 error occurred:
	* failed to construct source from user input "docker:idanfrim/multi-arch:only-arm64": could not fetch image "idanfrim/multi-arch:only-arm64": scheme "docker" specified; image retrieval using scheme parsing (idanfrim/multi-arch:only-arm64) was unsuccessful: unable to use DockerDaemon source: image has unexpected architecture "arm64", which differs from the user specified architecture "amd64"; image retrieval without scheme parsing (docker:idanfrim/multi-arch:only-arm64) was unsuccessful: unable to determine image source to select platform

Solves #1569

Signed-off-by: Idan Frimark <idanf@cisco.com>
@FrimIdan FrimIdan force-pushed the scheme-image-retrieval-failure branch from e64e4a2 to 3e4b84e Compare May 9, 2023 09:13
@FrimIdan
Copy link
Contributor Author

@kzantow @tgerla Do you mind to take a look at the PR?

@tgerla
Copy link
Contributor

tgerla commented May 11, 2023

Hi @FrimIdan, thank you for the pull request! We've been looking at similar issues recently, and we might want to move some of this processing into stereoscope itself. We will keep this ticket updated as we investigate. Thanks again.

@tgerla
Copy link
Contributor

tgerla commented May 11, 2023

I believe this issue is also related: #1695

@FrimIdan
Copy link
Contributor Author

@tgerla ok. I hope it can be sorted quickly, the current situation is confusing and my pr might be a temp solution until a better will be integrated.

Copy link
Contributor

@spiffcs spiffcs left a comment

Choose a reason for hiding this comment

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

@anchore/tools This is approved - waiting on a 2nd before merge!

Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

this is a step in the right direction as it at least raises up enough information for the user to see. In a future iteration there may be opportunity to make it a little less verbose.

@spiffcs spiffcs added the bug Something isn't working label May 23, 2023
@spiffcs spiffcs merged commit 087a635 into anchore:main May 23, 2023
9 checks passed
spiffcs added a commit that referenced this pull request Jun 5, 2023
* main: (21 commits)
  chore(deps): bump github.com/sirupsen/logrus from 1.9.2 to 1.9.3 (#1862)
  chore(deps): bump modernc.org/sqlite from 1.22.1 to 1.23.0 (#1863)
  feat: source-version flag (#1859)
  chore(deps): bump github.com/spf13/viper from 1.15.0 to 1.16.0 (#1851)
  accept main.version ldflags even without vcs (#1855)
  feat: add scope to pom properties (#1779)
  chore(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4 (#1852)
  chore(deps): bump github.com/docker/docker (#1849)
  Add test to ensure package metadata is represented in the JSON schema (#1841)
  Fix directory resolver to consider CWD and root path input correctly (#1840)
  Migrate location-related structs to the file package (#1751)
  chore(deps): bump github.com/go-git/go-git/v5 from 5.6.1 to 5.7.0 (#1843)
  fix: add panic recovery for license parse (#1839)
  chore: return both failures when failed to retrieve an image with a scheme (#1801)
  Extract go module versions from ldflags for binaries built by go (#1832)
  fix: duplicate packages, support pnpm lockfile v6 (#1778)
  chore(deps): update stereoscope to e14bc4437b2eac481c5b6f101890b22df4f33596 (#1834)
  chore(deps): bump github.com/stretchr/testify from 1.8.2 to 1.8.3 (#1829)
  chore(deps): bump github.com/docker/docker (#1833)
  Keep original FileInfo persisted on file.Metadata structs (#1794)
  ...

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
…cheme (anchore#1801)

Signed-off-by: Idan Frimark <idanf@cisco.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants