Skip to content

Commit 83ca770

Browse files
authored
Merge pull request #64 from xm1k3/validate-fix
Validate fix
2 parents 12e484f + 562415e commit 83ca770

File tree

4 files changed

+70
-479
lines changed

4 files changed

+70
-479
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ after installation run `cent init` to initialize cent with the configuration fil
3535
| init | Cent init configuration file |
3636
| summary | Print summary table |
3737
| update | Update your repository |
38-
| validate | Validate templates, if the template is invalid it is deleted from the folder |
38+
| validate | The validate command is a part of the application's functionality to validate templates. When executed, it scans a specified folder for YAML files. Each YAML file is checked for validity. If a template is found to be invalid, it is deleted from the folder. |
3939
| version | Print cent version |
4040

4141
# Root flags

cmd/validate.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package cmd
66
import (
77
"fmt"
88
"io/ioutil"
9+
"log"
910
"os"
1011
"path/filepath"
1112
"sync"
@@ -22,12 +23,12 @@ var validateCmd = &cobra.Command{
2223
When executed, it scans a specified folder for YAML files. Each YAML file is checked for validity.
2324
If a template is found to be invalid, it is deleted from the folder.`,
2425
Run: func(cmd *cobra.Command, args []string) {
25-
path, _ := rootCmd.Flags().GetString("path")
26+
path, _ := cmd.Flags().GetString("path")
2627

2728
var wg sync.WaitGroup
2829
filepath.Walk(path, func(filePath string, info os.FileInfo, err error) error {
2930
if err != nil {
30-
return err
31+
log.Fatal(err)
3132
}
3233
if info.IsDir() {
3334
} else if filepath.Ext(filePath) == ".yaml" {
@@ -67,4 +68,6 @@ func readFile(filePath string) (string, error) {
6768

6869
func init() {
6970
rootCmd.AddCommand(validateCmd)
71+
validateCmd.Flags().StringP("path", "p", "cent-nuclei-templates", "Root path to save the templates")
72+
7073
}

go.mod

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ module github.com/xm1k3/cent
33
go 1.19
44

55
require (
6-
github.com/fatih/color v1.15.0
7-
github.com/go-git/go-git/v5 v5.9.0
8-
github.com/hashicorp/go-retryablehttp v0.7.4
6+
github.com/fatih/color v1.16.0
7+
github.com/go-git/go-git/v5 v5.11.0
8+
github.com/hashicorp/go-retryablehttp v0.7.5
99
github.com/jedib0t/go-pretty v4.3.0+incompatible
1010
github.com/mitchellh/go-homedir v1.1.0
11-
github.com/spf13/cobra v1.7.0
12-
github.com/spf13/viper v1.17.0
11+
github.com/spf13/cobra v1.8.0
12+
github.com/spf13/viper v1.18.1
1313
gopkg.in/yaml.v2 v2.4.0
1414
gopkg.in/yaml.v3 v3.0.1
1515
)
@@ -18,16 +18,15 @@ require (
1818
dario.cat/mergo v1.0.0 // indirect
1919
github.com/Microsoft/go-winio v0.6.1 // indirect
2020
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
21-
github.com/acomagu/bufpipe v1.0.4 // indirect
2221
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
2322
github.com/cloudflare/circl v1.3.3 // indirect
2423
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
2524
github.com/emirpasic/gods v1.18.1 // indirect
26-
github.com/fsnotify/fsnotify v1.6.0 // indirect
25+
github.com/fsnotify/fsnotify v1.7.0 // indirect
2726
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
2827
github.com/go-git/go-billy/v5 v5.5.0 // indirect
29-
github.com/go-openapi/errors v0.20.3 // indirect
30-
github.com/go-openapi/strfmt v0.21.7 // indirect
28+
github.com/go-openapi/errors v0.20.4 // indirect
29+
github.com/go-openapi/strfmt v0.21.9 // indirect
3130
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3231
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
3332
github.com/hashicorp/hcl v1.0.0 // indirect
@@ -36,32 +35,32 @@ require (
3635
github.com/kevinburke/ssh_config v1.2.0 // indirect
3736
github.com/magiconair/properties v1.8.7 // indirect
3837
github.com/mattn/go-colorable v0.1.13 // indirect
39-
github.com/mattn/go-isatty v0.0.17 // indirect
38+
github.com/mattn/go-isatty v0.0.20 // indirect
4039
github.com/mattn/go-runewidth v0.0.15 // indirect
4140
github.com/mitchellh/mapstructure v1.5.0 // indirect
4241
github.com/oklog/ulid v1.3.1 // indirect
4342
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
4443
github.com/pjbgf/sha1cd v0.3.0 // indirect
4544
github.com/rivo/uniseg v0.2.0 // indirect
46-
github.com/sagikazarmark/locafero v0.3.0 // indirect
45+
github.com/sagikazarmark/locafero v0.4.0 // indirect
4746
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
4847
github.com/sergi/go-diff v1.1.0 // indirect
49-
github.com/skeema/knownhosts v1.2.0 // indirect
48+
github.com/skeema/knownhosts v1.2.1 // indirect
5049
github.com/sourcegraph/conc v0.3.0 // indirect
51-
github.com/spf13/afero v1.10.0 // indirect
52-
github.com/spf13/cast v1.5.1 // indirect
50+
github.com/spf13/afero v1.11.0 // indirect
51+
github.com/spf13/cast v1.6.0 // indirect
5352
github.com/spf13/pflag v1.0.5 // indirect
5453
github.com/subosito/gotenv v1.6.0 // indirect
5554
github.com/xanzy/ssh-agent v0.3.3 // indirect
56-
go.mongodb.org/mongo-driver v1.11.3 // indirect
55+
go.mongodb.org/mongo-driver v1.13.0 // indirect
5756
go.uber.org/atomic v1.9.0 // indirect
5857
go.uber.org/multierr v1.9.0 // indirect
59-
golang.org/x/crypto v0.13.0 // indirect
58+
golang.org/x/crypto v0.16.0 // indirect
6059
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
6160
golang.org/x/mod v0.12.0 // indirect
62-
golang.org/x/net v0.15.0 // indirect
63-
golang.org/x/sys v0.12.0 // indirect
64-
golang.org/x/text v0.13.0 // indirect
61+
golang.org/x/net v0.19.0 // indirect
62+
golang.org/x/sys v0.15.0 // indirect
63+
golang.org/x/text v0.14.0 // indirect
6564
golang.org/x/tools v0.13.0 // indirect
6665
gopkg.in/ini.v1 v1.67.0 // indirect
6766
gopkg.in/warnings.v0 v0.1.2 // indirect

0 commit comments

Comments
 (0)