From 67d6a52e2ba656accd1e90c91e72e4bd2c813640 Mon Sep 17 00:00:00 2001 From: JonJagger Date: Thu, 15 Aug 2024 15:10:43 +0100 Subject: [PATCH 1/4] Fix minor error in some docs examples --- cmd/kosli/attestGeneric.go | 3 ++- cmd/kosli/attestJira.go | 3 ++- cmd/kosli/attestJunit.go | 3 ++- cmd/kosli/attestSnyk.go | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/kosli/attestGeneric.go b/cmd/kosli/attestGeneric.go index c1c00d5a..c6a2076e 100644 --- a/cmd/kosli/attestGeneric.go +++ b/cmd/kosli/attestGeneric.go @@ -58,6 +58,7 @@ kosli attest generic \ --name yourTemplateArtifactName.yourAttestationName \ --flow yourFlowName \ --trail yourTrailName \ + --commit yourArtifactGitCommit \ --api-token yourAPIToken \ --org yourOrgName @@ -66,7 +67,7 @@ kosli attest generic \ --name yourAttestationName \ --flow yourFlowName \ --trail yourTrailName \ - --attachments=yourAttachmentPathName \ + --attachments yourAttachmentPathName \ --api-token yourAPIToken \ --org yourOrgName diff --git a/cmd/kosli/attestJira.go b/cmd/kosli/attestJira.go index fda8c6ec..3647ac08 100644 --- a/cmd/kosli/attestJira.go +++ b/cmd/kosli/attestJira.go @@ -86,6 +86,7 @@ kosli attest jira \ --name yourTemplateArtifactName.yourAttestationName \ --flow yourFlowName \ --trail yourTrailName \ + --commit yourArtifactGitCommit \ --jira-base-url https://kosli.atlassian.net \ --jira-username user@domain.com \ --jira-api-token yourJiraAPIToken \ @@ -100,7 +101,7 @@ kosli attest jira \ --jira-base-url https://kosli.atlassian.net \ --jira-username user@domain.com \ --jira-api-token yourJiraAPIToken \ - --attachments=yourAttachmentPathName \ + --attachments yourAttachmentPathName \ --api-token yourAPIToken \ --org yourOrgName diff --git a/cmd/kosli/attestJunit.go b/cmd/kosli/attestJunit.go index 6268e435..1af4cd72 100644 --- a/cmd/kosli/attestJunit.go +++ b/cmd/kosli/attestJunit.go @@ -63,6 +63,7 @@ kosli attest junit \ --name yourTemplateArtifactName.yourAttestationName \ --flow yourFlowName \ --trail yourTrailName \ + --commit yourArtifactGitCommit \ --results-dir yourFolderWithJUnitResults \ --api-token yourAPIToken \ --org yourOrgName @@ -73,7 +74,7 @@ kosli attest junit \ --flow yourFlowName \ --trail yourTrailName \ --results-dir yourFolderWithJUnitResults \ - --attachments=yourAttachmentPathName \ + --attachments yourAttachmentPathName \ --api-token yourAPIToken \ --org yourOrgName ` diff --git a/cmd/kosli/attestSnyk.go b/cmd/kosli/attestSnyk.go index 1a2abc43..f3cd143a 100644 --- a/cmd/kosli/attestSnyk.go +++ b/cmd/kosli/attestSnyk.go @@ -72,6 +72,7 @@ kosli attest snyk \ --name yourTemplateArtifactName.yourAttestationName \ --flow yourFlowName \ --trail yourTrailName \ + --commit yourArtifactGitCommit \ --scan-results yourSnykSARIFScanResults \ --api-token yourAPIToken \ --org yourOrgName @@ -82,7 +83,7 @@ kosli attest snyk \ --flow yourFlowName \ --trail yourTrailName \ --scan-results yourSnykSARIFScanResults \ - --attachments=yourEvidencePathName \ + --attachments yourEvidencePathName \ --api-token yourAPIToken \ --org yourOrgName From c0e340fdabefb35eed5654e07906f26f29c75df6 Mon Sep 17 00:00:00 2001 From: JonJagger Date: Thu, 15 Aug 2024 15:21:51 +0100 Subject: [PATCH 2/4] Update fmt.Errorf calls to try and fix newly appearing lint errors --- cmd/kosli/attestation.go | 2 +- cmd/kosli/cli_utils.go | 2 +- internal/sonar/sonar.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/kosli/attestation.go b/cmd/kosli/attestation.go index d7fe697a..bb96c728 100644 --- a/cmd/kosli/attestation.go +++ b/cmd/kosli/attestation.go @@ -169,7 +169,7 @@ func newAttestationForm(payload interface{}, attachments []string) ( func wrapAttestationError(err error) error { if err != nil { - return fmt.Errorf(strings.Replace(err.Error(), "requires at least one of: artifact_fingerprint or git_commit_info.", + return fmt.Errorf("%s", strings.Replace(err.Error(), "requires at least one of: artifact_fingerprint or git_commit_info.", "requires at least one of: specifying the fingerprint (either by calculating it using the artifact name/path and --artifact-type, or by providing it using --fingerprint) or providing --commit (requires an available git repo to access commit details)", 1)) } return err diff --git a/cmd/kosli/cli_utils.go b/cmd/kosli/cli_utils.go index 1fdd58ef..dd35ce76 100644 --- a/cmd/kosli/cli_utils.go +++ b/cmd/kosli/cli_utils.go @@ -493,7 +493,7 @@ func ValidateArtifactArg(args []string, artifactType, inputSha256 string, always if argsWithLeadingSpace { errMsg = append(errMsg, "Arguments with a leading space are probably caused by a lone backslash that has a space after it.") } - return fmt.Errorf(strings.Join(errMsg, "\n")) + return fmt.Errorf("%s", strings.Join(errMsg, "\n")) } if len(args) == 0 || args[0] == "" { diff --git a/internal/sonar/sonar.go b/internal/sonar/sonar.go index d8f83aaa..fe381907 100644 --- a/internal/sonar/sonar.go +++ b/internal/sonar/sonar.go @@ -116,7 +116,7 @@ func (sc *SonarConfig) GetSonarResults() (*SonarResults, error) { message = fmt.Sprintf("%s\n", message) } } - return nil, fmt.Errorf(message) + return nil, fmt.Errorf("%s", message) } return sonarResult, nil From bd6b8b99fe303f4177688cb3d5090ea966cfeae7 Mon Sep 17 00:00:00 2001 From: JonJagger Date: Thu, 15 Aug 2024 15:24:03 +0100 Subject: [PATCH 3/4] Update fmt.Errorf calls to try and fix newly appearing lint errors --- internal/requests/requests.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/requests/requests.go b/internal/requests/requests.go index f4eec232..2704a1a7 100644 --- a/internal/requests/requests.go +++ b/internal/requests/requests.go @@ -233,7 +233,7 @@ func (c *Client) Do(p *RequestParams) (*HTTPResponse, error) { cleanedErrorMessage = fmt.Sprintf("%s", respBodyMap) } } - return nil, fmt.Errorf(cleanedErrorMessage) + return nil, fmt.Errorf("%s", cleanedErrorMessage) } return &HTTPResponse{string(body), resp}, nil } From d4e2463b3ddf23e39d4aca7998ecf60f86b66285 Mon Sep 17 00:00:00 2001 From: JonJagger Date: Thu, 15 Aug 2024 15:34:35 +0100 Subject: [PATCH 4/4] Update master file for docs-test after udpate to kosli-attest-snyk docs --- cmd/kosli/testdata/output/docs/snyk.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/kosli/testdata/output/docs/snyk.md b/cmd/kosli/testdata/output/docs/snyk.md index 97df9a9c..e5dc43a1 100644 --- a/cmd/kosli/testdata/output/docs/snyk.md +++ b/cmd/kosli/testdata/output/docs/snyk.md @@ -111,6 +111,7 @@ kosli attest snyk \ --name yourTemplateArtifactName.yourAttestationName \ --flow yourFlowName \ --trail yourTrailName \ + --commit yourArtifactGitCommit \ --scan-results yourSnykSARIFScanResults \ --api-token yourAPIToken \ --org yourOrgName @@ -125,7 +126,7 @@ kosli attest snyk \ --flow yourFlowName \ --trail yourTrailName \ --scan-results yourSnykSARIFScanResults \ - --attachments=yourEvidencePathName \ + --attachments yourEvidencePathName \ --api-token yourAPIToken \ --org yourOrgName