Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ast 43120 changed Revoked to Invalid validationStatus in all reports #242

Merged
merged 5 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN go build -o /app/2ms .
# Runtime image
FROM cgr.dev/chainguard/wolfi-base@sha256:6bc98699de679ce5e9d1d53b9d06b99acde93584bf539690d61ec538916b1e74

RUN apk add --no-cache bash=5.2.21-r1 git=2.44.0-r0 glibc=2.39-r2 glibc-locale-posix=2.39-r2 ld-linux==2.39-r2 libcrypt1=2.39-r2 && git config --global --add safe.directory /repo
RUN apk add --no-cache bash=5.2.21-r1 git=2.44.0-r0 glibc=2.39-r5 glibc-locale-posix=2.39-r5 ld-linux==2.39-r5 libcrypt1=2.39-r5 && git config --global --add safe.directory /repo

COPY --from=builder /app/2ms .

Expand Down
782 changes: 391 additions & 391 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Execute() (int, error) {
rootCmd.PersistentFlags().StringSliceVar(&engineConfigVar.SpecialList, specialRulesFlagName, []string{}, "special (non-default) rules to apply.\nThis list is not affected by the --rule and --ignore-rule flags.")
rootCmd.PersistentFlags().Var(&ignoreOnExitVar, ignoreOnExitFlagName, "defines which kind of non-zero exits code should be ignored\naccepts: all, results, errors, none\nexample: if 'results' is set, only engine errors will make 2ms exit code different from 0")
rootCmd.PersistentFlags().IntVar(&engineConfigVar.MaxTargetMegabytes, maxTargetMegabytesFlagName, 0, "files larger than this will be skipped.\nOmit or set to 0 to disable this check.")
rootCmd.PersistentFlags().BoolVar(&validateVar, validate, false, "trigger additional validation to check if discovered secrets are active or revoked")
rootCmd.PersistentFlags().BoolVar(&validateVar, validate, false, "trigger additional validation to check if discovered secrets are valid or invalid")

rootCmd.AddCommand(engine.GetRulesCommand(&engineConfigVar))

Expand Down
2 changes: 1 addition & 1 deletion engine/validation/alibaba.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func alibabaRequest(accessKey, secretKey string) (secrets.ValidationResult, erro
// If the access key is invalid, the response will be 404
// If the secret key is invalid, the response will be 400 along with other signautre Errors
if resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusBadRequest {
return secrets.RevokedResult, nil
return secrets.InvalidResult, nil
}

if resp.StatusCode == http.StatusOK {
Expand Down
2 changes: 1 addition & 1 deletion engine/validation/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func checkGCPErrorResponse(resp *http.Response) (secrets.ValidationResult, strin
}

if resp.StatusCode != http.StatusForbidden {
return secrets.RevokedResult, "", nil
return secrets.InvalidResult, "", nil
}

bodyBytes, err := io.ReadAll(resp.Body)
Expand Down
2 changes: 1 addition & 1 deletion engine/validation/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ func validateGithub(s *secrets.Secret) (secrets.ValidationResult, string) {
if resp.StatusCode == http.StatusOK {
return secrets.ValidResult, ""
}
return secrets.RevokedResult, ""
return secrets.InvalidResult, ""
}
2 changes: 1 addition & 1 deletion engine/validation/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ func validateGitlab(s *secrets.Secret) (secrets.ValidationResult, string) {

return secrets.ValidResult, user.WebURL
}
return secrets.RevokedResult, ""
return secrets.InvalidResult, ""
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/checkmarx/2ms

go 1.22.2
go 1.22.3

require (
github.com/bwmarrin/discordgo v0.27.1
Expand Down
4 changes: 2 additions & 2 deletions lib/secrets/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type ValidationResult string

const (
ValidResult ValidationResult = "Valid"
RevokedResult ValidationResult = "Revoked"
InvalidResult ValidationResult = "Invalid"
UnknownResult ValidationResult = "Unknown"
)

Expand All @@ -26,7 +26,7 @@ func (v ValidationResult) CompareTo(other ValidationResult) compared {
if other == UnknownResult {
return first
}
if v == RevokedResult {
if v == InvalidResult {
return second
}
return first
Expand Down
8 changes: 4 additions & 4 deletions lib/secrets/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func TestValidationResultCompareTo(t *testing.T) {
message: "Valid should be equal to Valid",
},
{
first: RevokedResult,
first: InvalidResult,
second: ValidResult,
want: second,
message: "Valid should be greater than Revoked",
message: "Valid should be greater than Invalid",
},
{
first: ValidResult,
Expand All @@ -31,9 +31,9 @@ func TestValidationResultCompareTo(t *testing.T) {
},
{
first: UnknownResult,
second: RevokedResult,
second: InvalidResult,
want: second,
message: "Revoked should be greater than Unknown",
message: "Invalid should be greater than Unknown",
},
}

Expand Down
Loading