Skip to content

Commit 7de173c

Browse files
authored
Merge branch 'main' into es/06-12-chore_remove_deprecated_extensions_commands
2 parents 3b9316c + 983280c commit 7de173c

16 files changed

Lines changed: 1144 additions & 11 deletions

.github/workflows/goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
args: release --clean --config=${{ env.config_file }}
203203
env:
204204
# Use separate access token, because we need a scope:repo token to publish the brew formula.
205-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
205+
GITHUB_TOKEN: ${{ secrets.BOT_CROSS_REPO_PAT }}
206206

207207
# goreleaser_post updates the symlink name to refer to the new release version. The
208208
# symlink enables users to install the latest src-cli with the versioned command:

CHANGELOG.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@ All notable changes to `src-cli` are documented in this file.
1111

1212
## Unreleased
1313

14+
### Added
15+
16+
- SBOM support: Added `--image` and `--exclude-image` flags to `src sbom fetch` for filtering which docker images SBOMs are fetched for. Both flags support glob patterns (e.g., `frontend`, `*api*`) and comma-separated lists. The `sourcegraph/` image name prefix is optional.
17+
18+
### Changed
19+
1420
- The deprecated `src extensions` commands have been removed.
1521

22+
## 6.4.0
23+
24+
## 6.3.0
25+
26+
## 6.2.0
27+
1628
## 6.1.1
1729

1830
### Added
@@ -24,6 +36,7 @@ All notable changes to `src-cli` are documented in this file.
2436
- Updated Go to 1.24.1
2537

2638
## 6.1.0
39+
2740
- Support uploading GZIP compressed SCIP indexes [1146](https://github.com/sourcegraph/src-cli/pull/1146)
2841
- Remove deprecated `lsif` subcommand, and remove LSIF->SCIP conversion support [1147](https://github.com/sourcegraph/src-cli/pull/1147)
2942

@@ -40,6 +53,7 @@ All notable changes to `src-cli` are documented in this file.
4053
- Update x/crypto to fix reported CVE-2024-45337
4154

4255
## 5.10.0
56+
4357
- cody gateway benchmark changes
4458
- fix local builds for non sourcegraph team [1121](https://github.com/sourcegraph/src-cli/pull/1121)
4559

@@ -80,7 +94,7 @@ All notable changes to `src-cli` are documented in this file.
8094

8195
### Added
8296

83-
- Batch Changes: Added support for batch spec versions. Batch specs with `version: 2` will default to keyword search to resolve workspaces if the pattern type is not specified explicitly. (https://github.com/sourcegraph/sourcegraph/pull/63613)
97+
- Batch Changes: Added support for batch spec versions. Batch specs with `version: 2` will default to keyword search to resolve workspaces if the pattern type is not specified explicitly. (<https://github.com/sourcegraph/sourcegraph/pull/63613>)
8498

8599
### Changed
86100

@@ -147,11 +161,13 @@ All notable changes to `src-cli` are documented in this file.
147161
## 5.1.0
148162

149163
### Added
164+
150165
- `src validate install` can check executor connections [#974](https://github.com/sourcegraph/src-cli/pull/974)
151166
- `src validate install` can send test SMTP message [#973](https://github.com/sourcegraph/src-cli/pull/973)
152167
- `src repos {add|update|delete}-metadata -repo-name` flag support [#977](https://github.com/sourcegraph/src-cli/pull/977)
153168

154169
### Changed
170+
155171
- Renamed `src repo {add|update|delete}-kvp` to `repo {add|update|delete}-metadata` [#972](https://github.com/sourcegraph/src-cli/pull/972)
156172

157173
## 5.0.3
@@ -192,7 +208,7 @@ No noteworthy changes, mechanical release to match Sourcegraph release.
192208

193209
### Fixed
194210

195-
- `src codeintel upload` will no longer overwrite the entire route supplied via `-upload-route` if SCIP data is detected. [#934](https://github.com/sourcegraph/src-cli/pull/934)
211+
- `src codeintel upload` will no longer overwrite the entire route supplied via `-upload-route` if SCIP data is detected. [#934](https://github.com/sourcegraph/src-cli/pull/934)
196212

197213
## 4.4.1
198214

@@ -238,7 +254,7 @@ No noteworthy changes, mechanical release to match Sourcegraph release.
238254
### Added
239255

240256
- Batch specs being run locally with `src batch preview` or `src batch apply` can now be run with the `-run-as-root` flag, which will run all step containers as root instead of the default user for the image. This is off by default. [#886](https://github.com/sourcegraph/src-cli/pull/886)
241-
- An **experimental** set of `src snapshot` commands for generating and sharing snapshots of Sourcegraph instances, as well as testing Sourcegraph instances restored from snapshots. [#888](https://github.com/sourcegraph/src-cli/pull/888), [#889](https://github.com/sourcegraph/src-cli/pull/889), [#890](https://github.com/sourcegraph/src-cli/pull/890)
257+
- An __experimental__ set of `src snapshot` commands for generating and sharing snapshots of Sourcegraph instances, as well as testing Sourcegraph instances restored from snapshots. [#888](https://github.com/sourcegraph/src-cli/pull/888), [#889](https://github.com/sourcegraph/src-cli/pull/889), [#890](https://github.com/sourcegraph/src-cli/pull/890)
242258

243259
### Changed
244260

@@ -312,7 +328,7 @@ No noteworthy changes, mechanical release to match Sourcegraph release.
312328

313329
### Changed
314330

315-
- **IMPORTANT:** Searches using the command `src search -stream` is updated to use a **new and better search result schema**, improving highlighting and accurate result counts for multiline matches. Please see the new JSON schema for results if you use the `src search -stream -json` output: [#807](https://github.com/sourcegraph/src-cli/pull/807)
331+
- __IMPORTANT:__ Searches using the command `src search -stream` is updated to use a __new and better search result schema__, improving highlighting and accurate result counts for multiline matches. Please see the new JSON schema for results if you use the `src search -stream -json` output: [#807](https://github.com/sourcegraph/src-cli/pull/807)
316332

317333
### Fixed
318334

@@ -935,7 +951,7 @@ Re-release of 3.29.3 for Sourcegraph 3.30.
935951
### Changed
936952

937953
- `src campaign [apply|preview]` now prints more detailed information about the diffs produced in each repository when run in verbose mode with `-v`. [#390](https://github.com/sourcegraph/src-cli/pull/390)
938-
- The dependency `go-diff` has been upgraded to 0.6.1 to include https://github.com/sourcegraph/go-diff/pull/55.
954+
- The dependency `go-diff` has been upgraded to 0.6.1 to include <https://github.com/sourcegraph/go-diff/pull/55>.
939955

940956
## 3.22.2
941957

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We adhere to the [general Sourcegraph principles for testing](https://docs.sourc
8383
[...]
8484
```
8585
After updating the checksums, rerun the command to verify that the values are correct.
86-
4. Run `sg generate bazel` (this may not result in any changes)
86+
4. Run `sg generate bazel` and `sg bazel configure` (this may not result in any changes)
8787
4. Commit the changes, and open a PR.
8888
6. Once the version bump PR is merged and the commit is live on dotcom, check that the [curl commands in the README](README.md#installation) also fetch the new latest version.
8989

cmd/src/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The commands are:
6060
repos,repo manages repositories
6161
sbom manages SBOM (Software Bill of Materials) data
6262
search search for results on Sourcegraph
63+
search-jobs manages search jobs
6364
serve-git serves your local git repositories over HTTP for Sourcegraph to pull
6465
users,user manages users
6566
codeowners manages code ownership information

cmd/src/sbom_fetch.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,32 @@ func init() {
2525
2626
Usage:
2727
28-
src sbom fetch -v <version>
28+
src sbom fetch -v <version> [--image <image-patterns>] [--exclude-image <exclude-patterns>]
2929
3030
Examples:
3131
32-
$ src sbom fetch -v 5.8.0 # Fetch all SBOMs for the 5.8.0 release
32+
$ src sbom fetch -v 5.8.0 # Fetch all SBOMs for the 5.8.0 release
3333
34-
$ src sbom fetch -v 5.8.123 -internal -d /tmp/sboms # Fetch all SBOMs for the internal 5.8.123 release and store them in /tmp/sboms
34+
$ src sbom fetch -v 5.8.0 --image frontend # Fetch SBOM only for the frontend image
35+
36+
$ src sbom fetch -v 5.8.0 --image "redis*" # Fetch SBOMs for all images with names beginning with 'redis'
37+
38+
$ src sbom fetch -v 5.8.0 --image "frontend,redis*" # Fetch SBOMs for frontend, and all redis images
39+
40+
$ src sbom fetch -v 5.8.0 --exclude-image "sg,*redis*" # Fetch SBOMs for all images, except sg and redis
41+
42+
$ src sbom fetch -v 5.8.0 --image "postgres*" --exclude-image "*exporter*" # Fetch SBOMs for all postgres images, except exporters
43+
44+
$ src sbom fetch -v 5.8.123 -internal -d /tmp/sboms # Fetch all SBOMs for the internal 5.8.123 release and store them in /tmp/sboms
3545
`
3646

3747
flagSet := flag.NewFlagSet("fetch", flag.ExitOnError)
3848
versionFlag := flagSet.String("v", "", "The version of Sourcegraph to fetch SBOMs for.")
3949
outputDirFlag := flagSet.String("d", "sourcegraph-sboms", "The directory to store validated SBOMs in.")
4050
internalReleaseFlag := flagSet.Bool("internal", false, "Fetch SBOMs for an internal release. Defaults to false.")
4151
insecureIgnoreTransparencyLogFlag := flagSet.Bool("insecure-ignore-tlog", false, "Disable transparency log verification. Defaults to false.")
52+
imageFlag := flagSet.String("image", "", "Filter list of image names, to only fetch SBOMs for Docker images with names matching these patterns. Supports literal names, like frontend, and glob patterns like '*postgres*'. Multiple patterns can be specified as a comma-separated list (e.g., 'frontend,*postgres-1?-*'). The 'sourcegraph/' prefix is optional. If not specified, SBOMs for all images are fetched.")
53+
excludeImageFlag := flagSet.String("exclude-image", "", "Exclude Docker images with names matching these patterns from being fetched. Supports the same formats as --image. Takes precedence over --image filters.")
4254

4355
handler := func(args []string) error {
4456
c := cosignConfig{
@@ -73,6 +85,24 @@ Examples:
7385
c.insecureIgnoreTransparencyLog = true
7486
}
7587

88+
if imageFlag != nil && *imageFlag != "" {
89+
// Parse comma-separated patterns
90+
patterns := strings.Split(*imageFlag, ",")
91+
for i, pattern := range patterns {
92+
patterns[i] = strings.TrimSpace(pattern)
93+
}
94+
c.imageFilters = patterns
95+
}
96+
97+
if excludeImageFlag != nil && *excludeImageFlag != "" {
98+
// Parse comma-separated exclude patterns
99+
patterns := strings.Split(*excludeImageFlag, ",")
100+
for i, pattern := range patterns {
101+
patterns[i] = strings.TrimSpace(pattern)
102+
}
103+
c.excludeImageFilters = patterns
104+
}
105+
76106
out := output.NewOutput(flagSet.Output(), output.OutputOpts{Verbose: *verbose})
77107

78108
if err := verifyCosign(); err != nil {

cmd/src/sbom_utils.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net/http"
1111
"os/exec"
1212
"path"
13+
"path/filepath"
1314
"regexp"
1415
"strings"
1516
"time"
@@ -26,6 +27,8 @@ type cosignConfig struct {
2627
version string
2728
internalRelease bool
2829
insecureIgnoreTransparencyLog bool
30+
imageFilters []string
31+
excludeImageFilters []string
2932
}
3033

3134
// TokenResponse represents the JSON response from dockerHub's token service
@@ -251,7 +254,21 @@ func (c cosignConfig) getImageList() ([]string, error) {
251254
if image != "" {
252255
// Strip off a version suffix if present
253256
parts := strings.SplitN(image, ":", 2)
254-
images = append(images, parts[0])
257+
imageName := parts[0]
258+
259+
// If the --image arg was provided, and if the image name doesn't match any of the filters
260+
// then skip this image
261+
if len(c.imageFilters) > 0 && !matchesImageFilter(c.imageFilters, imageName) {
262+
continue
263+
}
264+
265+
// If the --exclude-image arg was provided, and if the image name does match any of the filters
266+
// then skip this image
267+
if len(c.excludeImageFilters) > 0 && matchesImageFilter(c.excludeImageFilters, imageName) {
268+
continue
269+
}
270+
271+
images = append(images, imageName)
255272
}
256273
}
257274

@@ -270,3 +287,24 @@ func (c *cosignConfig) getImageReleaseListURL() string {
270287
return fmt.Sprintf("%s/release/%s/%s", imageListBaseURL, c.version, imageListFilename)
271288
}
272289
}
290+
291+
// matchesImageFilter checks if the image name from the list of published images
292+
// matches any user-provided --image or --exclude-image glob patterns
293+
// It matches against both the full image name, and the image name without the "sourcegraph/" prefix.
294+
func matchesImageFilter(patterns []string, imageName string) bool {
295+
for _, pattern := range patterns {
296+
// Try matching against the full image name
297+
if matched, _ := filepath.Match(pattern, imageName); matched {
298+
return true
299+
}
300+
301+
// Try matching against the image name without "sourcegraph/" prefix
302+
if strings.HasPrefix(imageName, "sourcegraph/") {
303+
shortName := strings.TrimPrefix(imageName, "sourcegraph/")
304+
if matched, _ := filepath.Match(pattern, shortName); matched {
305+
return true
306+
}
307+
}
308+
}
309+
return false
310+
}

0 commit comments

Comments
 (0)