Skip to content

Commit 01bff25

Browse files
committed
remove comments
1 parent b17919d commit 01bff25

File tree

9 files changed

+7
-47
lines changed

9 files changed

+7
-47
lines changed

evidence/cli/command_build.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func NewEvidenceBuildCommand(ctx *components.Context, execute execCommandFunc) E
2121
}
2222

2323
func (ebc *evidenceBuildCommand) CreateEvidence(ctx *components.Context, serverDetails *config.ServerDetails) error {
24-
// Check if sigstore-bundle is provided (currently not supported for build evidence)
2524
if ebc.ctx.GetStringFlagValue(sigstoreBundle) != "" {
2625
return errorutils.CheckErrorf("--sigstore-bundle is currently not supported for build evidence. This feature may be supported in future releases.")
2726
}

evidence/cli/command_cli.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ func validateCreateEvidenceCommonContext(ctx *components.Context) error {
119119
return pluginsCommon.WrongNumberOfArgumentsHandler(ctx)
120120
}
121121

122-
// If sigstore-bundle is provided, validate conflicting parameters
123-
// We check both IsFlagSet and assertValueProvided to ensure the flag is both set and has a value
124122
if ctx.IsFlagSet(sigstoreBundle) && assertValueProvided(ctx, sigstoreBundle) == nil {
125123
if err := validateSigstoreBundleConflicts(ctx); err != nil {
126124
return err
@@ -146,14 +144,9 @@ func validateCreateEvidenceCommonContext(ctx *components.Context) error {
146144
return nil
147145
}
148146

149-
// validateSigstoreBundleConflicts checks if conflicting parameters are provided when using sigstore-bundle.
150-
// When --sigstore-bundle is used, the following parameters cannot be provided:
151-
// --key, --key-alias, --predicate, --predicate-type
152-
// Returns an error if any conflicting parameters are found.
153147
func validateSigstoreBundleConflicts(ctx *components.Context) error {
154148
var conflictingParams []string
155149

156-
// Check each conflicting parameter
157150
if ctx.IsFlagSet(key) && ctx.GetStringFlagValue(key) != "" {
158151
conflictingParams = append(conflictingParams, "--key")
159152
}
@@ -203,7 +196,6 @@ func getAndValidateSubject(ctx *components.Context) ([]string, error) {
203196
}
204197

205198
if len(foundSubjects) == 0 {
206-
// If sigstore-bundle is provided, subject will be extracted from bundle
207199
if ctx.IsFlagSet(sigstoreBundle) && assertValueProvided(ctx, sigstoreBundle) == nil {
208200
return []string{subjectRepoPath}, nil // Return subjectRepoPath as the type for routing
209201
}

evidence/cli/command_custom.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func NewEvidenceCustomCommand(ctx *components.Context, execute execCommandFunc)
2020
}
2121
}
2222
func (ecc *evidenceCustomCommand) CreateEvidence(_ *components.Context, serverDetails *config.ServerDetails) error {
23-
// Validate that subject-sha256 is not used with sigstore-bundle
2423
if ecc.ctx.GetStringFlagValue(sigstoreBundle) != "" && ecc.ctx.GetStringFlagValue(subjectSha256) != "" {
2524
return errorutils.CheckErrorf("The parameter --subject-sha256 cannot be used with --sigstore-bundle. When using --sigstore-bundle, the subject hash is extracted from the bundle itself.")
2625
}

evidence/cli/command_github.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ func NewEvidenceGitHubCommand(ctx *components.Context, execute execCommandFunc)
2020
}
2121

2222
func (ebc *evidenceGitHubCommand) CreateEvidence(ctx *components.Context, serverDetails *config.ServerDetails) error {
23-
// Check if sigstore-bundle is provided (currently not supported for GitHub evidence)
2423
if ebc.ctx.GetStringFlagValue(sigstoreBundle) != "" {
2524
return errorutils.CheckErrorf("--sigstore-bundle is currently not supported for GitHub evidence. This feature may be supported in future releases.")
2625
}

evidence/cli/command_package.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func NewEvidencePackageCommand(ctx *components.Context, execute execCommandFunc)
2121
}
2222

2323
func (epc *evidencePackageCommand) CreateEvidence(ctx *components.Context, serverDetails *config.ServerDetails) error {
24-
// Check if sigstore-bundle is provided (currently not supported for package evidence)
2524
if epc.ctx.GetStringFlagValue(sigstoreBundle) != "" {
2625
return errorutils.CheckErrorf("--sigstore-bundle is currently not supported for package evidence. This feature may be supported in future releases.")
2726
}

evidence/cli/command_release_bundle.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func NewEvidenceReleaseBundleCommand(ctx *components.Context, execute execComman
2121
}
2222

2323
func (erc *evidenceReleaseBundleCommand) CreateEvidence(ctx *components.Context, serverDetails *config.ServerDetails) error {
24-
// Check if sigstore-bundle is provided (currently not supported for release bundle evidence)
2524
if erc.ctx.GetStringFlagValue(sigstoreBundle) != "" {
2625
return errorutils.CheckErrorf("--sigstore-bundle is currently not supported for release bundle evidence. This feature may be supported in future releases.")
2726
}

evidence/create/create_custom.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package create
22

33
import (
4-
"os"
4+
"encoding/json"
5+
"github.com/sigstore/sigstore-go/pkg/bundle"
56
"strings"
67

78
"github.com/jfrog/jfrog-cli-artifactory/evidence"
@@ -68,34 +69,25 @@ func (c *createEvidenceCustom) Run() error {
6869
return nil
6970
}
7071

71-
// processSigstoreBundle reads and processes a Sigstore bundle, returning the envelope and subject
7272
func (c *createEvidenceCustom) processSigstoreBundle() ([]byte, error) {
73-
// Read the Sigstore bundle file
74-
bundle, err := os.ReadFile(c.sigstoreBundlePath)
73+
sigstoreBundle, err := sigstore.ParseBundle(c.sigstoreBundlePath)
7574
if err != nil {
7675
return nil, errorutils.CheckErrorf("failed to read sigstore bundle: %s", err.Error())
7776
}
7877

79-
// Only extract subject from bundle if current subject is empty
8078
if c.subjectRepoPath == "" {
81-
extractedSubject, err := c.extractSubjectFromBundle()
79+
80+
extractedSubject, err := c.extractSubjectFromBundle(sigstoreBundle)
8281
if err != nil {
8382
return nil, err
8483
}
8584
c.subjectRepoPath = extractedSubject
8685
}
8786

88-
return bundle, nil
87+
return json.Marshal(sigstoreBundle)
8988
}
9089

91-
func (c *createEvidenceCustom) extractSubjectFromBundle() (string, error) {
92-
// Parse the bundle first
93-
bundle, err := sigstore.ParseBundle(c.sigstoreBundlePath)
94-
if err != nil {
95-
return "", err
96-
}
97-
98-
// Extract subject from the parsed bundle
90+
func (c *createEvidenceCustom) extractSubjectFromBundle(bundle *bundle.Bundle) (string, error) {
9991
repoPath, err := sigstore.ExtractSubjectFromBundle(bundle)
10092
if err != nil {
10193
return "", err
@@ -104,7 +96,6 @@ func (c *createEvidenceCustom) extractSubjectFromBundle() (string, error) {
10496
return repoPath, nil
10597
}
10698

107-
// createDSSEEnvelope creates a DSSE envelope from the provided predicate and subject information
10899
func (c *createEvidenceCustom) createDSSEEnvelope() ([]byte, error) {
109100
envelope, err := c.createEnvelope(c.subjectRepoPath, c.subjectSha256)
110101
if err != nil {

evidence/sigstore/bundle_parser.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import (
77
"github.com/sigstore/sigstore-go/pkg/bundle"
88
)
99

10-
// ParseBundle reads and validates a sigstore bundle file using sigstore-go
1110
func ParseBundle(bundlePath string) (*bundle.Bundle, error) {
12-
// Use sigstore-go to load the bundle
1311
b, err := bundle.LoadJSONFromPath(bundlePath)
1412
if err != nil {
1513
return nil, errorutils.CheckErrorf("failed to parse sigstore bundle: %s", err.Error())
@@ -18,18 +16,14 @@ func ParseBundle(bundlePath string) (*bundle.Bundle, error) {
1816
return b, nil
1917
}
2018

21-
// GetDSSEEnvelope extracts the DSSE envelope from the bundle using sigstore types
2219
func GetDSSEEnvelope(b *bundle.Bundle) (*protodsse.Envelope, error) {
23-
// Get the protobuf bundle
2420
pb := b.Bundle
2521

26-
// Check if bundle contains DSSE envelope
2722
content := pb.GetContent()
2823
if content == nil {
2924
return nil, errorutils.CheckErrorf("bundle does not contain content")
3025
}
3126

32-
// Extract DSSE envelope based on content type
3327
switch c := content.(type) {
3428
case *protobundle.Bundle_DsseEnvelope:
3529
if c.DsseEnvelope == nil {

evidence/sigstore/subject_extractor.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,31 @@ import (
88
"github.com/sigstore/sigstore-go/pkg/bundle"
99
)
1010

11-
// ExtractSubjectFromBundle extracts subject information from a parsed bundle
1211
func ExtractSubjectFromBundle(b *bundle.Bundle) (repoPath string, err error) {
13-
// Get DSSE envelope
1412
envelope, err := GetDSSEEnvelope(b)
1513
if err != nil {
1614
return "", err
1715
}
1816

19-
// Extract subject from envelope
2017
return extractSubjectFromEnvelope(envelope)
2118
}
2219

23-
// extractSubjectFromEnvelope extracts subject information from a protobuf DSSE envelope
2420
func extractSubjectFromEnvelope(envelope *protodsse.Envelope) (repoPath string, err error) {
2521
if envelope == nil {
2622
return "", errorutils.CheckErrorf("envelope is nil")
2723
}
2824

29-
// Parse the payload as In-toto statement
3025
var statement map[string]interface{}
3126
if err := json.Unmarshal(envelope.Payload, &statement); err != nil {
3227
return "", errorutils.CheckErrorf("failed to parse statement from DSSE payload: %s", err.Error())
3328
}
3429

35-
// Try to extract repo path from the statement
3630
repoPath = extractRepoPathFromStatement(statement)
3731

3832
return repoPath, nil
3933
}
4034

41-
// extractRepoPathFromStatement attempts to extract repo path from various fields in the statement
4235
func extractRepoPathFromStatement(statement map[string]interface{}) string {
43-
// Try to get from subject name first
4436
if subjects, ok := statement["subject"].([]interface{}); ok && len(subjects) > 0 {
4537
if subject, ok := subjects[0].(map[string]interface{}); ok {
4638
if name, ok := subject["name"].(string); ok && name != "" {
@@ -49,9 +41,7 @@ func extractRepoPathFromStatement(statement map[string]interface{}) string {
4941
}
5042
}
5143

52-
// Try to extract from predicate
5344
if predicate, ok := statement["predicate"].(map[string]interface{}); ok {
54-
// Check artifact field
5545
if artifact, ok := predicate["artifact"].(map[string]interface{}); ok {
5646
if path, ok := artifact["path"].(string); ok && path != "" {
5747
return path
@@ -61,7 +51,6 @@ func extractRepoPathFromStatement(statement map[string]interface{}) string {
6151
}
6252
}
6353

64-
// Check subject field in predicate
6554
if subject, ok := predicate["subject"].(map[string]interface{}); ok {
6655
if path, ok := subject["path"].(string); ok && path != "" {
6756
return path
@@ -71,7 +60,6 @@ func extractRepoPathFromStatement(statement map[string]interface{}) string {
7160
}
7261
}
7362

74-
// Check materials field (SLSA predicates)
7563
if materials, ok := predicate["materials"].([]interface{}); ok && len(materials) > 0 {
7664
if material, ok := materials[0].(map[string]interface{}); ok {
7765
if uri, ok := material["uri"].(string); ok && uri != "" {

0 commit comments

Comments
 (0)