Skip to content

Commit 4c1f692

Browse files
author
elchananarb
committed
fix
1 parent 8cc186e commit 4c1f692

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

internal/commands/pre_commit.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package commands
22

33
import (
44
"fmt"
5+
"strings"
6+
57
precommit "github.com/Checkmarx/secret-detection/pkg/hooks"
68
"github.com/MakeNowJust/heredoc"
79
"github.com/checkmarx/ast-cli/internal/params"
810
"github.com/checkmarx/ast-cli/internal/wrappers"
911
"github.com/pkg/errors"
1012
"github.com/spf13/cobra"
11-
"strings"
1213
)
1314

1415
// NewHooksCommand creates the hooks command with pre-commit subcommand
@@ -63,9 +64,8 @@ func PreCommitCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command {
6364
return preCommitCmd
6465
}
6566

66-
// / validateLicense verifies the user has the required license for secret detection
67-
func validateLicense(jwtWrapper wrappers.JWTWrapper) error {
68-
67+
// ValidateLicense verifies the user has the required license for secret detection
68+
func ValidateLicense(jwtWrapper wrappers.JWTWrapper) error {
6969
allowed, err := jwtWrapper.IsAllowedEngine(params.EnterpriseSecretsLabel)
7070
if err != nil {
7171
return errors.Wrapf(err, "Failed checking license")
@@ -87,7 +87,7 @@ func secretsInstallGitHookCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command
8787
`,
8888
),
8989
PreRunE: func(cmd *cobra.Command, args []string) error {
90-
return validateLicense(jwtWrapper)
90+
return ValidateLicense(jwtWrapper)
9191
},
9292
RunE: func(cmd *cobra.Command, args []string) error {
9393
global, _ := cmd.Flags().GetBool("global")
@@ -128,7 +128,7 @@ func secretsUpdateGitHookCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command
128128
`,
129129
),
130130
PreRunE: func(cmd *cobra.Command, args []string) error {
131-
return validateLicense(jwtWrapper)
131+
return ValidateLicense(jwtWrapper)
132132
},
133133
RunE: func(cmd *cobra.Command, args []string) error {
134134
global, _ := cmd.Flags().GetBool("global")
@@ -150,7 +150,7 @@ func secretsScanCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command {
150150
`,
151151
),
152152
PreRunE: func(cmd *cobra.Command, args []string) error {
153-
return validateLicense(jwtWrapper)
153+
return ValidateLicense(jwtWrapper)
154154
},
155155
RunE: func(cmd *cobra.Command, args []string) error {
156156
return precommit.Scan()
@@ -173,7 +173,7 @@ func secretsIgnoreCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command {
173173
`,
174174
),
175175
PreRunE: func(cmd *cobra.Command, args []string) error {
176-
if err := validateLicense(jwtWrapper); err != nil {
176+
if err := ValidateLicense(jwtWrapper); err != nil {
177177
return err
178178
}
179179

test/integration/pre_commit_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"testing"
1111

12+
"github.com/checkmarx/ast-cli/internal/commands"
1213
"github.com/checkmarx/ast-cli/internal/wrappers/mock"
1314
"github.com/stretchr/testify/assert"
1415
)
@@ -41,7 +42,7 @@ func TestHooksPreCommitValidateLicenseIntegration(t *testing.T) {
4142
AIEnabled: mock.AIProtectionDisabled,
4243
}
4344

44-
err := validateLicense(mockJWT)
45+
err := commands.ValidateLicense(mockJWT)
4546

4647
assert.Error(t, err)
4748
assert.Contains(t, err.Error(), "License validation failed")

0 commit comments

Comments
 (0)