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

feat(cmd/update): add UA header with current ver when check for update #2100

Merged

Conversation

hainenber
Copy link
Contributor

@hainenber hainenber commented Sep 6, 2023

Implements #2072

PR description

When check for version update during syft commands, specify UA header with current version of the binary.

Notes

  • Test updated

@hainenber hainenber force-pushed the add-user-agent-when-check-for-version-update branch from 966e004 to 2d1f75a Compare September 6, 2023 14:51
req, err := http.NewRequest(http.MethodGet, latestAppVersionURL.host+latestAppVersionURL.path, nil)
if err != nil {
return nil, fmt.Errorf("failed to create request for latest version: %w", err)
}
req.Header.Add("User-Agent", fmt.Sprintf("%v %v", "Syft", currentVersion))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should instead modify this function to take the id clio.Identification as a parameter (and, by association the isUpdateAvailable function), then this line would be something like:

req.Header.Add("User-Agent", fmt.Sprintf("%v %v", id.Name, id.Version))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the prompt review! Sounds reasonable to me, I'll try pushing new commits to amend this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done pushing. PTAL again. Thanks!

@hainenber hainenber force-pushed the add-user-agent-when-check-for-version-update branch from 74a7ffd to 535a8e7 Compare September 6, 2023 15:20
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @hainenber!

@kzantow kzantow linked an issue Sep 6, 2023 that may be closed by this pull request
@kzantow kzantow merged commit f8ab7c4 into anchore:main Sep 6, 2023
9 checks passed
@hainenber hainenber deleted the add-user-agent-when-check-for-version-update branch September 6, 2023 16:24
spiffcs added a commit to dlorenc/syft that referenced this pull request Sep 7, 2023
* main:
  chore(deps): update bootstrap tools to latest versions (anchore#2086)
  chore(deps): update CPE dictionary index (anchore#2089)
  chore(deps): bump github.com/saferwall/pe from 1.4.4 to 1.4.5 (anchore#2096)
  chore(deps): bump github.com/docker/docker (anchore#2098)
  chore(deps): bump golang.org/x/net from 0.14.0 to 0.15.0 (anchore#2099)
  feat(cmd/update): add UA header with current ver when check for update (anchore#2100)
  fix(cdx): validate external refs before encoding (anchore#2091)
  expose cobra command in cli package (anchore#2097)

Signed-off-by: Christopher Phillips <[email protected]>
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
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.

Add User-Agent with Syft version during update check
2 participants