@@ -4,47 +4,19 @@ import (
44 "fmt"
55 "strings"
66
7- precommit "github.com/Checkmarx/secret-detection/pkg/hooks"
7+ precommit "github.com/Checkmarx/secret-detection/pkg/hooks/pre-commit "
88 "github.com/MakeNowJust/heredoc"
9- "github.com/checkmarx/ast-cli/internal/params"
109 "github.com/checkmarx/ast-cli/internal/wrappers"
11- "github.com/pkg/errors"
1210 "github.com/spf13/cobra"
1311)
1412
15- // NewHooksCommand creates the hooks command with pre-commit subcommand
16- func NewHooksCommand (jwtWrapper wrappers.JWTWrapper ) * cobra.Command {
17- hooksCmd := & cobra.Command {
18- Use : "hooks" ,
19- Short : "Manage Git hooks" ,
20- Long : "The hooks command enables the ability to manage Git hooks for Checkmarx One" ,
21- Example : heredoc .Doc (
22- `
23- $ cx hooks pre-commit secrets-install-git-hook
24- $ cx hooks pre-commit secrets-scan
25- ` ,
26- ),
27- Annotations : map [string ]string {
28- "command:doc" : heredoc .Doc (
29- `
30- https://checkmarx.com/resource/documents/en/xxxxx-xxxxx-hooks.html
31- ` ,
32- ),
33- },
34- }
35-
36- // Add pre-commit subcommand
37- hooksCmd .AddCommand (PreCommitCommand (jwtWrapper ))
38-
39- return hooksCmd
40- }
41-
4213// PreCommitCommand creates the pre-commit subcommand
14+
4315func PreCommitCommand (jwtWrapper wrappers.JWTWrapper ) * cobra.Command {
4416 preCommitCmd := & cobra.Command {
4517 Use : "pre-commit" ,
4618 Short : "Manage pre-commit hooks and run secret detection scans" ,
47- Long : "The pre-commit command enables the ability to manage Git pre-commit hooks for secret detection" ,
19+ Long : "The pre-commit command enables the ability to manage Git pre-commit hooks for secret detection. " ,
4820 Example : heredoc .Doc (
4921 `
5022 $ cx hooks pre-commit secrets-install-git-hook
@@ -65,22 +37,12 @@ func PreCommitCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command {
6537}
6638
6739// / validateLicense verifies the user has the required license for secret detection
68- func validateLicense (jwtWrapper wrappers.JWTWrapper ) error {
69- allowed , err := jwtWrapper .IsAllowedEngine (params .EnterpriseSecretsLabel )
70- if err != nil {
71- return errors .Wrapf (err , "Failed checking license" )
72- }
73- if ! allowed {
74- return errors .New ("Error: License validation failed. Please verify your CxOne license includes Enterprise Secrets." )
75- }
76- return nil
77- }
7840
7941func secretsInstallGitHookCommand (jwtWrapper wrappers.JWTWrapper ) * cobra.Command {
8042 cmd := & cobra.Command {
8143 Use : "secrets-install-git-hook" ,
8244 Short : "Install the pre-commit hook" ,
83- Long : "Install the pre-commit hook for secret detection in your repository" ,
45+ Long : "Install the pre-commit hook for secret detection in your repository. " ,
8446 Example : heredoc .Doc (
8547 `
8648 $ cx hooks pre-commit secrets-install-git-hook
@@ -102,7 +64,7 @@ func secretsUninstallGitHookCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Comma
10264 cmd := & cobra.Command {
10365 Use : "secrets-uninstall-git-hook" ,
10466 Short : "Uninstall the pre-commit hook" ,
105- Long : "Uninstall the pre-commit hook for secret detection from your repository" ,
67+ Long : "Uninstall the pre-commit hook for secret detection from your repository. " ,
10668 Example : heredoc .Doc (
10769 `
10870 $ cx hooks pre-commit secrets-uninstall-git-hook
@@ -121,7 +83,7 @@ func secretsUpdateGitHookCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command
12183 cmd := & cobra.Command {
12284 Use : "secrets-update-git-hook" ,
12385 Short : "Update the pre-commit hook" ,
124- Long : "Update the pre-commit hook for secret detection to the latest version" ,
86+ Long : "Update the pre-commit hook for secret detection to the latest version. " ,
12587 Example : heredoc .Doc (
12688 `
12789 $ cx hooks pre-commit secrets-update-git-hook
@@ -143,7 +105,7 @@ func secretsScanCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command {
143105 return & cobra.Command {
144106 Use : "secrets-scan" ,
145107 Short : "Run the real-time secret detection scan" ,
146- Long : "Run a real-time scan to detect secrets in your code before committing" ,
108+ Long : "Run a real-time scan to detect secrets in your code before committing. " ,
147109 Example : heredoc .Doc (
148110 `
149111 $ cx hooks pre-commit secrets-scan
@@ -165,7 +127,7 @@ func secretsIgnoreCommand(jwtWrapper wrappers.JWTWrapper) *cobra.Command {
165127 cmd := & cobra.Command {
166128 Use : "secrets-ignore" ,
167129 Short : "Ignore one or more detected secrets" ,
168- Long : "Add detected secrets to the ignore list so they won't be flagged in future scans" ,
130+ Long : "Add detected secrets to the ignore list so they won't be flagged in future scans. " ,
169131 Example : heredoc .Doc (
170132 `
171133 $ cx hooks pre-commit secrets-ignore --resultIds=a1b2c3d4e5f6,f1e2d3c4b5a6
@@ -209,7 +171,7 @@ func secretsHelpCommand() *cobra.Command {
209171 return & cobra.Command {
210172 Use : "secrets-help" ,
211173 Short : "Display help for pre-commit commands" ,
212- Long : "Display detailed information about the pre-commit commands and options" ,
174+ Long : "Display detailed information about the pre-commit commands and options. " ,
213175 RunE : func (cmd * cobra.Command , args []string ) error {
214176 return cmd .Parent ().Help ()
215177 },
0 commit comments