Skip to content

Commit 9890439

Browse files
committed
remove previously deprecated attach/download sbom commands
Signed-off-by: hectorj2f <[email protected]>
1 parent 677a262 commit 9890439

File tree

7 files changed

+0
-379
lines changed

7 files changed

+0
-379
lines changed

cmd/cosign/cli/attach.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
package cli
1717

1818
import (
19-
"fmt"
20-
"os"
21-
2219
"github.com/sigstore/cosign/v2/cmd/cosign/cli/attach"
2320
"github.com/sigstore/cosign/v2/cmd/cosign/cli/options"
2421
"github.com/spf13/cobra"
@@ -32,7 +29,6 @@ func Attach() *cobra.Command {
3229

3330
cmd.AddCommand(
3431
attachSignature(),
35-
attachSBOM(),
3632
attachAttestation(),
3733
)
3834

@@ -75,32 +71,6 @@ func attachSignature() *cobra.Command {
7571
return cmd
7672
}
7773

78-
func attachSBOM() *cobra.Command {
79-
o := &options.AttachSBOMOptions{}
80-
81-
cmd := &cobra.Command{
82-
Use: "sbom",
83-
Short: "DEPRECATED: Attach sbom to the supplied container image",
84-
Long: "Attach sbom to the supplied container image\n\n" + options.SBOMAttachmentDeprecation,
85-
Example: " cosign attach sbom <image uri>",
86-
Args: cobra.ExactArgs(1),
87-
PersistentPreRun: options.BindViper,
88-
RunE: func(cmd *cobra.Command, args []string) error {
89-
fmt.Fprintln(os.Stderr, options.SBOMAttachmentDeprecation)
90-
mediaType, err := o.MediaType()
91-
if err != nil {
92-
return err
93-
}
94-
fmt.Fprintf(os.Stderr, "WARNING: Attaching SBOMs this way does not sign them. To sign them, use 'cosign attest --predicate %s --key <key path>'.\n", o.SBOM)
95-
return attach.SBOMCmd(cmd.Context(), o.Registry, o.RegistryExperimental, o.SBOM, mediaType, args[0])
96-
},
97-
}
98-
99-
o.AddFlags(cmd)
100-
101-
return cmd
102-
}
103-
10474
func attachAttestation() *cobra.Command {
10575
o := &options.AttachAttestationOptions{}
10676

cmd/cosign/cli/attach/sbom.go

Lines changed: 0 additions & 149 deletions
This file was deleted.

cmd/cosign/cli/download.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
package cli
1717

1818
import (
19-
"fmt"
20-
"os"
21-
2219
"github.com/spf13/cobra"
2320

2421
"github.com/sigstore/cosign/v2/cmd/cosign/cli/download"
@@ -33,7 +30,6 @@ func Download() *cobra.Command {
3330

3431
cmd.AddCommand(
3532
downloadSignature(),
36-
downloadSBOM(),
3733
downloadAttestation(),
3834
)
3935

@@ -59,31 +55,6 @@ func downloadSignature() *cobra.Command {
5955
return cmd
6056
}
6157

62-
func downloadSBOM() *cobra.Command {
63-
o := &options.RegistryOptions{}
64-
do := &options.SBOMDownloadOptions{}
65-
66-
cmd := &cobra.Command{
67-
Use: "sbom",
68-
Short: "DEPRECATED: Download SBOMs from the supplied container image",
69-
Long: "Download SBOMs from the supplied container image\n\n" + options.SBOMAttachmentDeprecation,
70-
Example: " cosign download sbom <image uri>",
71-
Args: cobra.ExactArgs(1),
72-
PersistentPreRun: options.BindViper,
73-
RunE: func(cmd *cobra.Command, args []string) error {
74-
fmt.Fprintln(os.Stderr, options.SBOMAttachmentDeprecation)
75-
fmt.Fprintln(os.Stderr, "WARNING: Downloading SBOMs this way does not ensure its authenticity. If you want to ensure a tamper-proof SBOM, download it using 'cosign download attestation <image uri>'.")
76-
_, err := download.SBOMCmd(cmd.Context(), *o, *do, args[0], cmd.OutOrStdout())
77-
return err
78-
},
79-
}
80-
81-
do.AddFlags(cmd)
82-
o.AddFlags(cmd)
83-
84-
return cmd
85-
}
86-
8758
func downloadAttestation() *cobra.Command {
8859
o := &options.RegistryOptions{}
8960
ao := &options.AttestationDownloadOptions{}

doc/cosign_attach.md

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/cosign_download.md

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e_attach_test.go

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
"github.com/google/go-containerregistry/pkg/name"
4040
"github.com/google/go-containerregistry/pkg/v1/types"
4141
"github.com/sigstore/cosign/v2/cmd/cosign/cli/attach"
42-
"github.com/sigstore/cosign/v2/cmd/cosign/cli/download"
4342
"github.com/sigstore/cosign/v2/cmd/cosign/cli/generate"
4443
"github.com/sigstore/cosign/v2/cmd/cosign/cli/options"
4544
cliverify "github.com/sigstore/cosign/v2/cmd/cosign/cli/verify"
@@ -402,95 +401,3 @@ func TestUploadDownload(t *testing.T) {
402401
})
403402
}
404403
}
405-
406-
func TestAttachSBOM_bom_flag(t *testing.T) {
407-
repo, stop := reg(t)
408-
defer stop()
409-
td := t.TempDir()
410-
ctx := context.Background()
411-
bomData, err := os.ReadFile("./testdata/bom-go-mod.spdx")
412-
must(err, t)
413-
414-
testCases := map[string]struct {
415-
bom string
416-
bomType attach.SignatureArgType
417-
expectedErr bool
418-
}{
419-
"stdin containing bom": {
420-
bom: string(bomData),
421-
bomType: attach.StdinSignature,
422-
expectedErr: false,
423-
},
424-
"file containing bom": {
425-
bom: string(bomData),
426-
bomType: attach.FileSignature,
427-
expectedErr: false,
428-
},
429-
"raw bom as argument": {
430-
bom: string(bomData),
431-
bomType: attach.RawSignature,
432-
expectedErr: true,
433-
},
434-
"empty bom as argument": {
435-
bom: "",
436-
bomType: attach.RawSignature,
437-
expectedErr: true,
438-
},
439-
}
440-
441-
for testName, testCase := range testCases {
442-
t.Run(testName, func(t *testing.T) {
443-
imgName := path.Join(repo, "sbom-image")
444-
img, _, cleanup := mkimage(t, imgName)
445-
var sbomRef string
446-
restoreStdin := func() {}
447-
switch {
448-
case testCase.bomType == attach.FileSignature:
449-
sbomRef = mkfile(testCase.bom, td, t)
450-
case testCase.bomType == attach.StdinSignature:
451-
sbomRef = "-"
452-
restoreStdin = mockStdin(testCase.bom, td, t)
453-
default:
454-
sbomRef = testCase.bom
455-
}
456-
457-
out := bytes.Buffer{}
458-
_, errPl := download.SBOMCmd(ctx, options.RegistryOptions{}, options.SBOMDownloadOptions{Platform: "darwin/amd64"}, img.Name(), &out)
459-
if errPl == nil {
460-
t.Fatalf("Expected error when passing Platform to single arch image")
461-
}
462-
_, err := download.SBOMCmd(ctx, options.RegistryOptions{}, options.SBOMDownloadOptions{}, img.Name(), &out)
463-
if err == nil {
464-
t.Fatal("Expected error")
465-
}
466-
t.Log(out.String())
467-
out.Reset()
468-
469-
// Upload it!
470-
err = attach.SBOMCmd(ctx, options.RegistryOptions{}, options.RegistryExperimentalOptions{}, sbomRef, "spdx", imgName)
471-
restoreStdin()
472-
473-
if testCase.expectedErr {
474-
mustErr(err, t)
475-
} else {
476-
sboms, err := download.SBOMCmd(ctx, options.RegistryOptions{}, options.SBOMDownloadOptions{}, imgName, &out)
477-
if err != nil {
478-
t.Fatal(err)
479-
}
480-
t.Log(out.String())
481-
if len(sboms) != 1 {
482-
t.Fatalf("Expected one sbom, got %d", len(sboms))
483-
}
484-
want, err := os.ReadFile("./testdata/bom-go-mod.spdx")
485-
if err != nil {
486-
t.Fatal(err)
487-
}
488-
if diff := cmp.Diff(string(want), sboms[0]); diff != "" {
489-
t.Errorf("diff: %s", diff)
490-
}
491-
}
492-
493-
cleanup()
494-
})
495-
}
496-
}

0 commit comments

Comments
 (0)