Skip to content

Commit

Permalink
sboms: Update changelog and improve error message (#1116)
Browse files Browse the repository at this point in the history
* Update changelog + improve error message

* Remove newline
  • Loading branch information
willdollman authored Oct 14, 2024
1 parent ffe0913 commit 847a899
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ All notable changes to `src-cli` are documented in this file.

## 5.8.0

### Added

- SBOM support: Software Bill of Materials (SBOMs) can now be fetched for Sourcegraph releases after 5.8.0 using `src sbom fetch -v <release>`. [#1115](https://github.com/sourcegraph/src-cli/pull/1115)

### Changed

- Update Go to 1.22.8
Expand Down
6 changes: 6 additions & 0 deletions cmd/src/sbom_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strings"
"unicode"

"github.com/grafana/regexp"
"github.com/sourcegraph/sourcegraph/lib/errors"
"github.com/sourcegraph/sourcegraph/lib/output"

Expand Down Expand Up @@ -186,6 +187,11 @@ func (c sbomConfig) getImageList() ([]string, error) {
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
// Compare version number against a regex that matches versions up to and including 5.8.0
versionRegex := regexp.MustCompile(`^v?[0-5]\.([0-7]\.[0-9]+|8\.0)$`)
if versionRegex.MatchString(c.version) {
return nil, fmt.Errorf("unsupported version %s: SBOMs are only available for Sourcegraph releases after 5.8.0", c.version)
}
return nil, fmt.Errorf("failed to fetch list of images - check that %s is a valid Sourcegraph release: HTTP status %d", c.version, resp.StatusCode)
}

Expand Down

0 comments on commit 847a899

Please sign in to comment.