From 3e2e845477a7864c8f5413527acd523cadedc661 Mon Sep 17 00:00:00 2001 From: kchason Date: Sun, 23 Jul 2023 21:06:16 -0400 Subject: [PATCH 01/19] Add custom help text to support nuclei usage --- .gitignore | 4 ++++ goflags.go | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1a027c --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDE Settings +/.idea +/.vscode +/.vs \ No newline at end of file diff --git a/goflags.go b/goflags.go index de76313..ef4f965 100644 --- a/goflags.go +++ b/goflags.go @@ -25,6 +25,7 @@ type FlagSet struct { CaseSensitive bool Marshal bool description string + customHelpText string flagKeys InsertionOrderedMap groups []groupData CommandLine *flag.FlagSet @@ -82,6 +83,11 @@ func (flagSet *FlagSet) SetDescription(description string) { flagSet.description = description } +// SetCustomHelpText sets the help text for a flagSet to a value. This variable appends text to the default help text. +func (flagSet *FlagSet) SetCustomHelpText(helpText string) { + flagSet.customHelpText = helpText +} + // SetGroup sets a group with name and description for the command line options // // The order in which groups are passed is also kept as is, similar to flags. @@ -501,8 +507,7 @@ func (flagSet *FlagSet) usageFunc() { writer := tabwriter.NewWriter(cliOutput, 0, 0, 1, ' ', 0) - // If user has specified group with help and we have groups, return - // with it's usage function + // If a user has specified a group with help, and we have groups, return with the tool's usage function if len(flagSet.groups) > 0 && len(os.Args) == 3 { group := flagSet.getGroupbyName(strings.ToLower(os.Args[2])) if group.name != "" { @@ -521,6 +526,11 @@ func (flagSet *FlagSet) usageFunc() { } else { flagSet.usageFuncInternal(writer) } + + // If there is a custom help text specified, print it + if isNotBlank(flagSet.customHelpText) { + fmt.Fprintf(cliOutput, "\n%s\n", flagSet.customHelpText) + } } func (flagSet *FlagSet) getGroupbyName(name string) groupData { From 1115d2a2450a15cf1571a6c5e834000080e682b2 Mon Sep 17 00:00:00 2001 From: kchason Date: Sun, 23 Jul 2023 21:33:47 -0400 Subject: [PATCH 02/19] Add usage to example docs --- examples/basic/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/basic/main.go b/examples/basic/main.go index f4fc21a..8f730bf 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -36,6 +36,7 @@ func main() { flagSet.SizeVarP(&testOptions.fileSize, "max-size", "ms", "", "max file size"), flagSet.DurationVar(&testOptions.duration, "timeout", time.Hour, "timeout"), ) + flagSet.SetCustomHelpText("EXAMPLE USAGE:\ngo run ./examples/basic [OPTIONS]") if err := flagSet.Parse(); err != nil { log.Fatal(err) From dbf9da12bb5c5d563b2d942313a86b17d36566c0 Mon Sep 17 00:00:00 2001 From: Dogan Can Bakir <65292895+dogancanbakir@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:47:09 +0300 Subject: [PATCH 03/19] add ratelimit flag (#123) * add ratelimit flag * use StringSlice * limit unit to m * add example + Max threshold * fix build test * fmt --------- Co-authored-by: Tarun Koyalwar Co-authored-by: mzack --- examples/basic/main.go | 5 ++ ratelimit_var.go | 170 +++++++++++++++++++++++++++++++++++++++++ ratelimit_var_test.go | 93 ++++++++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 ratelimit_var.go create mode 100644 ratelimit_var_test.go diff --git a/examples/basic/main.go b/examples/basic/main.go index f4fc21a..a73d8ae 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -15,6 +15,7 @@ type Options struct { Address goflags.StringSlice fileSize goflags.Size duration time.Duration + rls goflags.RateLimitMap } func main() { @@ -28,6 +29,7 @@ func main() { flagSet.CreateGroup("info", "Info", flagSet.StringVarP(&testOptions.name, "name", "n", "", "name of the user"), flagSet.StringSliceVarP(&testOptions.Email, "email", "e", nil, "email of the user", goflags.CommaSeparatedStringSliceOptions), + flagSet.RateLimitMapVarP(&testOptions.rls, "rate-limits", "rls", nil, "rate limits in format k=v/d i.e hackertarget=10/s", goflags.CommaSeparatedStringSliceOptions), ) flagSet.CreateGroup("additional", "Additional", flagSet.StringVarP(&testOptions.Phone, "phone", "ph", "", "phone of the user"), @@ -40,4 +42,7 @@ func main() { if err := flagSet.Parse(); err != nil { log.Fatal(err) } + + // ratelimits value is + fmt.Printf("Got RateLimits: %+v\n", testOptions.rls) } diff --git a/ratelimit_var.go b/ratelimit_var.go new file mode 100644 index 0000000..bcd9cdb --- /dev/null +++ b/ratelimit_var.go @@ -0,0 +1,170 @@ +package goflags + +import ( + "errors" + "fmt" + "strconv" + "strings" + "time" + "unicode" + + stringsutil "github.com/projectdiscovery/utils/strings" + timeutil "github.com/projectdiscovery/utils/time" +) + +var ( + MaxRateLimitTime = time.Minute // anything above time.Minute is not practical (for our use case) + rateLimitOptionMap map[*RateLimitMap]Options +) + +func init() { + rateLimitOptionMap = make(map[*RateLimitMap]Options) +} + +type RateLimit struct { + MaxCount uint + Duration time.Duration +} + +type RateLimitMap struct { + kv map[string]RateLimit +} + +// Set inserts a value to the map. Format: key=value +func (rateLimitMap *RateLimitMap) Set(value string) error { + if rateLimitMap.kv == nil { + rateLimitMap.kv = make(map[string]RateLimit) + } + + option, ok := rateLimitOptionMap[rateLimitMap] + if !ok { + option = StringSliceOptions + } + rateLimits, err := ToStringSlice(value, option) + if err != nil { + return err + } + + for _, rateLimit := range rateLimits { + var k, v string + if idxSep := strings.Index(rateLimit, kvSep); idxSep > 0 { + k = rateLimit[:idxSep] + v = rateLimit[idxSep+1:] + } + + // note: + // - inserting multiple times the same key will override the previous v + // - empty string is legitimate rateLimit + if k != "" { + rateLimit, err := parseRateLimit(v) + if err != nil { + return err + } + rateLimitMap.kv[k] = rateLimit + } + } + return nil +} + +// Del removes the specified key +func (rateLimitMap *RateLimitMap) Del(key string) error { + if rateLimitMap.kv == nil { + return errors.New("empty runtime map") + } + delete(rateLimitMap.kv, key) + return nil +} + +// IsEmpty specifies if the underlying map is empty +func (rateLimitMap *RateLimitMap) IsEmpty() bool { + return rateLimitMap.kv == nil || len(rateLimitMap.kv) == 0 +} + +// AsMap returns the internal map as reference - changes are allowed +func (rateLimitMap *RateLimitMap) AsMap() map[string]RateLimit { + return rateLimitMap.kv +} + +func (rateLimitMap RateLimitMap) String() string { + defaultBuilder := &strings.Builder{} + defaultBuilder.WriteString("{") + + var items string + for k, v := range rateLimitMap.kv { + items += fmt.Sprintf("\"%s\":\"%d/%s\",", k, v.MaxCount, v.Duration.String()) + } + defaultBuilder.WriteString(stringsutil.TrimSuffixAny(items, ",", ":")) + defaultBuilder.WriteString("}") + return defaultBuilder.String() +} + +// RateLimitMapVar adds a ratelimit flag with a longname +func (flagSet *FlagSet) RateLimitMapVar(field *RateLimitMap, long string, defaultValue []string, usage string, options Options) *FlagData { + return flagSet.RateLimitMapVarP(field, long, "", defaultValue, usage, options) +} + +// RateLimitMapVarP adds a ratelimit flag with a short name and long name. +// It is equivalent to RateLimitMapVar, and also allows specifying ratelimits in days (e.g., "hackertarget=2/d" 2 requests per day, which is equivalent to 24h). +func (flagSet *FlagSet) RateLimitMapVarP(field *RateLimitMap, long, short string, defaultValue StringSlice, usage string, options Options) *FlagData { + if field == nil { + panic(fmt.Errorf("field cannot be nil for flag -%v", long)) + } + + rateLimitOptionMap[field] = options + for _, defaultItem := range defaultValue { + values, _ := ToStringSlice(defaultItem, options) + for _, value := range values { + if err := field.Set(value); err != nil { + panic(fmt.Errorf("failed to set default value for flag -%v: %v", long, err)) + } + } + } + + flagData := &FlagData{ + usage: usage, + long: long, + defaultValue: defaultValue, + skipMarshal: true, + } + if short != "" { + flagData.short = short + flagSet.CommandLine.Var(field, short, usage) + flagSet.flagKeys.Set(short, flagData) + } + flagSet.CommandLine.Var(field, long, usage) + flagSet.flagKeys.Set(long, flagData) + return flagData +} + +func parseRateLimit(s string) (RateLimit, error) { + sArr := strings.Split(s, "/") + + if len(sArr) < 2 { + return RateLimit{}, errors.New("parse error: expected format k=v/d (e.g., scanme.sh=10/s got " + s) + } + + maxCount, err := strconv.ParseUint(sArr[0], 10, 64) + if err != nil { + return RateLimit{}, errors.New("parse error: " + err.Error()) + } + timeValue := sArr[1] + if len(timeValue) > 0 { + // check if time is given ex: 1s + // if given value is just s (add prefix 1) + firstChar := timeValue[0] + if !unicode.IsDigit(rune(firstChar)) { + timeValue = "1" + timeValue + } + } + + duration, err := timeutil.ParseDuration(timeValue) + if err != nil { + return RateLimit{}, errors.New("parse error: " + err.Error()) + } + + if MaxRateLimitTime < duration { + return RateLimit{}, fmt.Errorf("duration cannot be more than %v but got %v", MaxRateLimitTime, duration) + } + + return RateLimit{MaxCount: uint(maxCount), Duration: duration}, nil +} diff --git a/ratelimit_var_test.go b/ratelimit_var_test.go new file mode 100644 index 0000000..41730cc --- /dev/null +++ b/ratelimit_var_test.go @@ -0,0 +1,93 @@ +package goflags + +import ( + "os" + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestRateLimitMapVar(t *testing.T) { + + t.Run("default-value", func(t *testing.T) { + var rateLimitMap RateLimitMap + flagSet := NewFlagSet() + flagSet.CreateGroup("Config", "Config", + flagSet.RateLimitMapVarP(&rateLimitMap, "rate-limits", "rls", []string{"hackertarget=1/ms"}, "rate limits", CommaSeparatedStringSliceOptions), + ) + os.Args = []string{ + os.Args[0], + } + err := flagSet.Parse() + assert.Nil(t, err) + assert.Equal(t, RateLimit{MaxCount: 1, Duration: time.Millisecond}, rateLimitMap.AsMap()["hackertarget"]) + tearDown(t.Name()) + }) + + t.Run("multiple-default-value", func(t *testing.T) { + var rateLimitMap RateLimitMap + flagSet := NewFlagSet() + flagSet.CreateGroup("Config", "Config", + flagSet.RateLimitMapVarP(&rateLimitMap, "rate-limits", "rls", []string{"hackertarget=1/s,github=1/ms"}, "rate limits", CommaSeparatedStringSliceOptions), + ) + os.Args = []string{ + os.Args[0], + } + err := flagSet.Parse() + assert.Nil(t, err) + assert.Equal(t, RateLimit{MaxCount: 1, Duration: time.Second}, rateLimitMap.AsMap()["hackertarget"]) + assert.Equal(t, RateLimit{MaxCount: 1, Duration: time.Millisecond}, rateLimitMap.AsMap()["github"]) + tearDown(t.Name()) + }) + + t.Run("valid-rate-limit", func(t *testing.T) { + var rateLimitMap RateLimitMap + flagSet := NewFlagSet() + flagSet.CreateGroup("Config", "Config", + flagSet.RateLimitMapVarP(&rateLimitMap, "rate-limits", "rls", nil, "rate limits", CommaSeparatedStringSliceOptions), + ) + os.Args = []string{ + os.Args[0], + "-rls", "hackertarget=10/m", + } + err := flagSet.Parse() + assert.Nil(t, err) + assert.Equal(t, RateLimit{MaxCount: 10, Duration: time.Minute}, rateLimitMap.AsMap()["hackertarget"]) + + tearDown(t.Name()) + }) + + t.Run("valid-rate-limits", func(t *testing.T) { + var rateLimitMap RateLimitMap + flagSet := NewFlagSet() + flagSet.CreateGroup("Config", "Config", + flagSet.RateLimitMapVarP(&rateLimitMap, "rate-limits", "rls", nil, "rate limits", CommaSeparatedStringSliceOptions), + ) + os.Args = []string{ + os.Args[0], + "-rls", "hackertarget=1/s,github=1/ms", + } + err := flagSet.Parse() + assert.Nil(t, err) + assert.Equal(t, RateLimit{MaxCount: 1, Duration: time.Second}, rateLimitMap.AsMap()["hackertarget"]) + assert.Equal(t, RateLimit{MaxCount: 1, Duration: time.Millisecond}, rateLimitMap.AsMap()["github"]) + tearDown(t.Name()) + }) + + t.Run("without-unit", func(t *testing.T) { + var rateLimitMap RateLimitMap + err := rateLimitMap.Set("hackertarget=1") + assert.NotNil(t, err) + assert.ErrorContains(t, err, "parse error") + tearDown(t.Name()) + }) + + t.Run("invalid-unit", func(t *testing.T) { + var rateLimitMap RateLimitMap + err := rateLimitMap.Set("hackertarget=1/x") + assert.NotNil(t, err) + assert.ErrorContains(t, err, "parse error") + tearDown(t.Name()) + }) +} From 9ad0a8d10f107d8129e14876e5b983a5daa6f5f6 Mon Sep 17 00:00:00 2001 From: mzack Date: Tue, 25 Jul 2023 00:01:03 +0200 Subject: [PATCH 04/19] removing javaish code --- goflags.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/goflags.go b/goflags.go index ef4f965..37ae4db 100644 --- a/goflags.go +++ b/goflags.go @@ -528,7 +528,7 @@ func (flagSet *FlagSet) usageFunc() { } // If there is a custom help text specified, print it - if isNotBlank(flagSet.customHelpText) { + if !isEmpty(flagSet.customHelpText) { fmt.Fprintf(cliOutput, "\n%s\n", flagSet.customHelpText) } } @@ -651,10 +651,6 @@ func (u *uniqueDeduper) isUnique(data *FlagData) bool { return true } -func isNotBlank(value string) bool { - return len(strings.TrimSpace(value)) != 0 -} - func createUsageString(data *FlagData, currentFlag *flag.Flag) string { valueType := reflect.TypeOf(currentFlag.Value) @@ -713,7 +709,7 @@ func createUsageFlagNames(data *FlagData) string { var validFlags []string addValidParam := func(value string) { - if isNotBlank(value) { + if !isEmpty(value) { validFlags = append(validFlags, fmt.Sprintf("-%s", value)) } } From d0f37e900317155e9ec290cec17e138688a8193a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Fri, 4 Aug 2023 08:42:14 +0000 Subject: [PATCH 05/19] add EnumSliceVar flag --- enum_slice_var.go | 30 +++++++++++++++++++++ enum_slice_var_test.go | 61 ++++++++++++++++++++++++++++++++++++++++++ goflags.go | 35 ++++++++++++++++++++++++ goflags_test.go | 12 ++++++++- 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 enum_slice_var.go create mode 100644 enum_slice_var_test.go diff --git a/enum_slice_var.go b/enum_slice_var.go new file mode 100644 index 0000000..137c2be --- /dev/null +++ b/enum_slice_var.go @@ -0,0 +1,30 @@ +package goflags + +import ( + "fmt" + "strings" +) + +type EnumSliceVar struct { + allowedTypes AllowdTypes + value *[]string +} + +func (e *EnumSliceVar) String() string { + if e.value != nil { + return strings.Join(*e.value, ",") + } + return "" +} + +func (e *EnumSliceVar) Set(value string) error { + values := strings.Split(value, ",") + for _, v := range values { + _, ok := e.allowedTypes[v] + if !ok { + return fmt.Errorf("allowed values are %v", e.allowedTypes.String()) + } + } + *e.value = values + return nil +} diff --git a/enum_slice_var_test.go b/enum_slice_var_test.go new file mode 100644 index 0000000..fe651f4 --- /dev/null +++ b/enum_slice_var_test.go @@ -0,0 +1,61 @@ +package goflags + +import ( + "os" + "os/exec" + "testing" + + "github.com/stretchr/testify/assert" +) + +var enumSliceData []string + +func TestEnumSliceVar(t *testing.T) { + t.Run("Test with single value", func(t *testing.T) { + flagSet := NewFlagSet() + flagSet.EnumSliceVar(&enumSliceData, "enum", []EnumVariable{Type1}, "enum", AllowdTypes{"type1": Type1, "type2": Type2}) + os.Args = []string{ + os.Args[0], + "--enum", "type1", + } + err := flagSet.Parse() + assert.Nil(t, err) + assert.Equal(t, []string{"type1"}, enumSliceData) + tearDown(t.Name()) + }) + + t.Run("Test with multiple value", func(t *testing.T) { + flagSet := NewFlagSet() + flagSet.EnumSliceVar(&enumSliceData, "enum", []EnumVariable{Type1}, "enum", AllowdTypes{"type1": Type1, "type2": Type2}) + os.Args = []string{ + os.Args[0], + "--enum", "type1,type2", + } + err := flagSet.Parse() + assert.Nil(t, err) + assert.Equal(t, []string{"type1", "type2"}, enumSliceData) + tearDown(t.Name()) + }) + + t.Run("Test with invalid value", func(t *testing.T) { + if os.Getenv("IS_SUB_PROCESS") == "1" { + flagSet := NewFlagSet() + + flagSet.EnumSliceVar(&enumSliceData, "enum", []EnumVariable{Nil}, "enum", AllowdTypes{"type1": Type1, "type2": Type2}) + os.Args = []string{ + os.Args[0], + "--enum", "type3", + } + _ = flagSet.Parse() + return + } + cmd := exec.Command(os.Args[0], "-test.run=TestFailEnumVar") + cmd.Env = append(os.Environ(), "IS_SUB_PROCESS=1") + err := cmd.Run() + if e, ok := err.(*exec.ExitError); ok && !e.Success() { + return + } + t.Fatalf("process ran with err %v, want exit error", err) + tearDown(t.Name()) + }) +} diff --git a/goflags.go b/goflags.go index 37ae4db..5d5acac 100644 --- a/goflags.go +++ b/goflags.go @@ -486,6 +486,41 @@ func (flagSet *FlagSet) EnumVarP(field *string, long, short string, defaultValue return flagData } +// EnumVar adds a enum flag with a longname +func (flagSet *FlagSet) EnumSliceVar(field *[]string, long string, defaultValues []EnumVariable, usage string, allowedTypes AllowdTypes) *FlagData { + return flagSet.EnumSliceVarP(field, long, "", defaultValues, usage, allowedTypes) +} + +// EnumVarP adds a enum flag with a shortname and longname +func (flagSet *FlagSet) EnumSliceVarP(field *[]string, long, short string, defaultValues []EnumVariable, usage string, allowedTypes AllowdTypes) *FlagData { + var defaults []string + for k, v := range allowedTypes { + for _, defaultValue := range defaultValues { + if v == defaultValue { + defaults = append(defaults, k) + } + } + } + if len(defaults) == 0 { + panic("undefined default value") + } + + *field = defaults + flagData := &FlagData{ + usage: usage, + long: long, + defaultValue: strings.Join(*field, ","), + } + if short != "" { + flagData.short = short + flagSet.CommandLine.Var(&EnumSliceVar{allowedTypes, field}, short, usage) + flagSet.flagKeys.Set(short, flagData) + } + flagSet.CommandLine.Var(&EnumSliceVar{allowedTypes, field}, long, usage) + flagSet.flagKeys.Set(long, flagData) + return flagData +} + func (flagSet *FlagSet) usageFunc() { var helpAsked bool diff --git a/goflags_test.go b/goflags_test.go index 4d49764..f818c01 100644 --- a/goflags_test.go +++ b/goflags_test.go @@ -3,6 +3,7 @@ package goflags import ( "bytes" "flag" + "fmt" "os" "reflect" "strconv" @@ -87,6 +88,7 @@ func TestUsageOrder(t *testing.T) { var intData int var boolData bool var enumData string + var enumSliceData []string flagSet.SetGroup("String", "String") flagSet.StringVar(&stringData, "string-value", "", "String example value example").Group("String") @@ -119,6 +121,12 @@ func TestUsageOrder(t *testing.T) { "two": EnumVariable(2), }).Group("Enum") + flagSet.EnumSliceVarP(&enumSliceData, "enum-slice-with-default-value", "esn", []EnumVariable{EnumVariable(0)}, "Enum with default value(zero/one/two)", AllowdTypes{ + "zero": EnumVariable(0), + "one": EnumVariable(1), + "two": EnumVariable(2), + }).Group("Enum") + flagSet.SetGroup("Update", "Update") flagSet.CallbackVar(func() {}, "update", "update tool_1 to the latest released version").Group("Update") flagSet.CallbackVarP(func() {}, "disable-update-check", "duc", "disable automatic update check").Group("Update") @@ -134,6 +142,7 @@ func TestUsageOrder(t *testing.T) { resultOutput := output.String() actual := resultOutput[strings.Index(resultOutput, "Flags:\n"):] + fmt.Println(actual) expected := `Flags: @@ -158,7 +167,8 @@ BOOLEAN: -bool-with-default-value Bool with default value example (default true) -bwdv, -bool-with-default-value2 Bool with default value example #2 (default true) ENUM: - -en, -enum-with-default-value value Enum with default value(zero/one/two) (default zero) + -en, -enum-with-default-value value Enum with default value(zero/one/two) (default zero) + -esn, -enum-slice-with-default-value value Enum with default value(zero/one/two) (default zero) UPDATE: -update update tool_1 to the latest released version -duc, -disable-update-check disable automatic update check From 6bebe11af6e69402c0af9e05e674233435760ee8 Mon Sep 17 00:00:00 2001 From: Tarun Koyalwar Date: Mon, 7 Aug 2023 18:54:31 +0530 Subject: [PATCH 06/19] add example to examples/basic --- .gitignore | 5 ++++- examples/basic/main.go | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a1a027c..1a6d520 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ # IDE Settings /.idea /.vscode -/.vs \ No newline at end of file +/.vs + +examples/basic/basic +examples/basic/basic.exe \ No newline at end of file diff --git a/examples/basic/main.go b/examples/basic/main.go index 909504f..e7f3ba1 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -16,6 +16,7 @@ type Options struct { fileSize goflags.Size duration time.Duration rls goflags.RateLimitMap + severity []string } func main() { @@ -37,6 +38,7 @@ func main() { flagSet.CallbackVarP(CheckUpdate, "update", "ut", "update this tool to latest version"), flagSet.SizeVarP(&testOptions.fileSize, "max-size", "ms", "", "max file size"), flagSet.DurationVar(&testOptions.duration, "timeout", time.Hour, "timeout"), + flagSet.EnumSliceVarP(&testOptions.severity, "severity", "s", []goflags.EnumVariable{2}, "severity of the scan", goflags.AllowdTypes{"low": goflags.EnumVariable(0), "medium": goflags.EnumVariable(1), "high": goflags.EnumVariable(2)}), ) flagSet.SetCustomHelpText("EXAMPLE USAGE:\ngo run ./examples/basic [OPTIONS]") @@ -45,5 +47,11 @@ func main() { } // ratelimits value is - fmt.Printf("Got RateLimits: %+v\n", testOptions.rls) + if len(testOptions.rls.AsMap()) > 0 { + fmt.Printf("Got RateLimits: %+v\n", testOptions.rls) + } + + if len(testOptions.severity) > 0 { + fmt.Printf("Got Severity: %+v\n", testOptions.severity) + } } From a634ac4b5c5df61f5925a557b6855094190a13a2 Mon Sep 17 00:00:00 2001 From: Ramana Reddy Date: Thu, 10 Aug 2023 01:00:30 +0530 Subject: [PATCH 07/19] add flag support act as flag with defaultValue or option with value --- dynamic_var.go | 114 +++++++++++++++++++++++++++++++++++++++++ examples/basic/main.go | 11 ++++ 2 files changed, 125 insertions(+) create mode 100644 dynamic_var.go diff --git a/dynamic_var.go b/dynamic_var.go new file mode 100644 index 0000000..b5e69b2 --- /dev/null +++ b/dynamic_var.go @@ -0,0 +1,114 @@ +package goflags + +import ( + "errors" + "fmt" + "reflect" + "strconv" +) + +type dynamicFlag struct { + field interface{} + defaultValue interface{} + name string +} + +func (df *dynamicFlag) Set(value string) error { + fieldKind := reflect.TypeOf(df.field).Elem().Kind() + var isBoolValue bool + if _, err := strconv.ParseBool(value); err == nil { + isBoolValue = true + } + if fieldKind == reflect.Bool && isBoolValue { + boolField := df.field.(*bool) + *boolField = true + return nil + } + switch fieldKind { + case reflect.Int: + intField := df.field.(*int) + if isBoolValue { + *intField = df.defaultValue.(int) + return nil + } + newValue, err := strconv.Atoi(value) + if err != nil { + return err + } + *intField = newValue + case reflect.Float64: + floatField := df.field.(*float64) + if isBoolValue { + *floatField = df.defaultValue.(float64) + return nil + } + newValue, err := strconv.ParseFloat(value, 64) + if err != nil { + return err + } + *floatField = newValue + case reflect.String: + stringField := df.field.(*string) + if isBoolValue { + *stringField = df.defaultValue.(string) + return nil + } + *stringField = value + default: + return errors.New("unsupported type") + } + return nil +} + +func (df *dynamicFlag) IsBoolFlag() bool { + return true +} + +func (df *dynamicFlag) String() string { + return df.name +} + +// DynamicVar acts as flag with a default value or a option with value +// example: +// var titleSize int +// flagSet.DynamicVar(&titleSize, "title", 50, "first N characters of the title") +// > go run ./examples/basic -title or go run ./examples/basic -title=100 +// In case of `go run ./examples/basic -title` it will use default value 50 +func (flagSet *FlagSet) DynamicVar(field interface{}, long string, defaultValue interface{}, usage string) *FlagData { + return flagSet.DynamicVarP(field, long, "", defaultValue, usage) +} + +// DynamicVarP same as DynamicVar but with short name +func (flagSet *FlagSet) DynamicVarP(field interface{}, long, short string, defaultValue interface{}, usage string) *FlagData { + // validate field and defaultValue + if reflect.TypeOf(field).Kind() != reflect.Ptr { + panic(fmt.Errorf("-%v flag field must be a pointer", long)) + } + if reflect.TypeOf(field).Elem().Kind() != reflect.TypeOf(defaultValue).Kind() { + panic(fmt.Errorf("-%v flag field and defaultValue mismatch: fied type is %v and defaultValue Type is %T", long, reflect.TypeOf(field).Elem().Kind(), defaultValue)) + } + if field == nil { + panic(fmt.Errorf("field cannot be nil for flag -%v", long)) + } + + var dynamicFlag dynamicFlag + dynamicFlag.field = field + dynamicFlag.name = long + if defaultValue != nil { + dynamicFlag.defaultValue = defaultValue + } + + flagData := &FlagData{ + usage: usage, + long: long, + defaultValue: defaultValue, + } + if short != "" { + flagData.short = short + flagSet.CommandLine.Var(&dynamicFlag, short, usage) + flagSet.flagKeys.Set(short, flagData) + } + flagSet.CommandLine.Var(&dynamicFlag, long, usage) + flagSet.flagKeys.Set(long, flagData) + return flagData +} diff --git a/examples/basic/main.go b/examples/basic/main.go index e7f3ba1..2a10776 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -17,6 +17,9 @@ type Options struct { duration time.Duration rls goflags.RateLimitMap severity []string + // Dynamic + titleSize int + target string } func main() { @@ -40,12 +43,20 @@ func main() { flagSet.DurationVar(&testOptions.duration, "timeout", time.Hour, "timeout"), flagSet.EnumSliceVarP(&testOptions.severity, "severity", "s", []goflags.EnumVariable{2}, "severity of the scan", goflags.AllowdTypes{"low": goflags.EnumVariable(0), "medium": goflags.EnumVariable(1), "high": goflags.EnumVariable(2)}), ) + flagSet.CreateGroup("Dynmaic", "Dynamic", + flagSet.DynamicVarP(&testOptions.titleSize, "title", "t", 50, "first N characters of the title"), + flagSet.DynamicVarP(&testOptions.target, "target", "u", "https://example.com", "target url"), + ) flagSet.SetCustomHelpText("EXAMPLE USAGE:\ngo run ./examples/basic [OPTIONS]") if err := flagSet.Parse(); err != nil { log.Fatal(err) } + // TODO: remove this + fmt.Println("title size:", testOptions.titleSize) + fmt.Println("target:", testOptions.target) + // ratelimits value is if len(testOptions.rls.AsMap()) > 0 { fmt.Printf("Got RateLimits: %+v\n", testOptions.rls) From 3a1d0e959734b3a0df96d548d720a6b1b761271f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Thu, 10 Aug 2023 08:25:07 +0000 Subject: [PATCH 08/19] use default perms --- .gitignore | 4 +++- go.mod | 8 ++++---- go.sum | 8 ++++++++ goflags.go | 5 +++-- goflags_test.go | 7 ++++--- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 1a6d520..1027e09 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ /.vs examples/basic/basic -examples/basic/basic.exe \ No newline at end of file +examples/basic/basic.exe + +.devcontainer \ No newline at end of file diff --git a/go.mod b/go.mod index f9e7b97..4938c2d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/miekg/dns v1.1.55 // indirect github.com/projectdiscovery/blackrock v0.0.1 // indirect golang.org/x/mod v0.8.0 // indirect - golang.org/x/sys v0.9.0 // indirect + golang.org/x/sys v0.11.0 // indirect golang.org/x/tools v0.6.0 // indirect ) @@ -23,9 +23,9 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/gorilla/css v1.0.0 // indirect - github.com/microcosm-cc/bluemonday v1.0.24 // indirect + github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c + github.com/projectdiscovery/utils v0.0.48 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect - golang.org/x/net v0.11.0 // indirect + golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index b898859..db793ee 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/microcosm-cc/bluemonday v1.0.24 h1:NGQoPtwGVcbGkKfvyYk1yRqknzBuoMiUrO6R7uFTPlw= github.com/microcosm-cc/bluemonday v1.0.24/go.mod h1:ArQySAMps0790cHSkdPEJ7bGkF2VePWH773hsJNSHf8= +github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= +github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -20,6 +22,8 @@ github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c h1:mNV/VSMi9wVpq3gcz4km2oUml9M+La20GaFoJPe3Ils= github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c/go.mod h1:rrd8dTBuKEScNMLgs1Xiu8rPCVeR0QTzmRcQ5iM3ymo= +github.com/projectdiscovery/utils v0.0.48 h1:eXJfOYQ3whDIo4uBX68UiPCLCmGE7Isv9348YukaCbY= +github.com/projectdiscovery/utils v0.0.48/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= @@ -30,9 +34,13 @@ golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/goflags.go b/goflags.go index 5d5acac..75401ad 100644 --- a/goflags.go +++ b/goflags.go @@ -16,6 +16,7 @@ import ( "github.com/cnf/structhash" fileutil "github.com/projectdiscovery/utils/file" + permissionutil "github.com/projectdiscovery/utils/permission" "golang.org/x/exp/maps" "gopkg.in/yaml.v3" ) @@ -110,10 +111,10 @@ func (flagSet *FlagSet) Parse() error { if err != nil { return err } - _ = os.MkdirAll(filepath.Dir(configFilePath), os.ModePerm) + _ = os.MkdirAll(filepath.Dir(configFilePath), permissionutil.ConfigFolderPermission) if !fileutil.FileExists(configFilePath) { configData := flagSet.generateDefaultConfig() - return os.WriteFile(configFilePath, configData, os.ModePerm) + return os.WriteFile(configFilePath, configData, permissionutil.ConfigFilePermission) } _ = flagSet.MergeConfigFile(configFilePath) // try to read default config after parsing flags return nil diff --git a/goflags_test.go b/goflags_test.go index f818c01..85ed9bc 100644 --- a/goflags_test.go +++ b/goflags_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + permissionutil "github.com/projectdiscovery/utils/permission" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -63,7 +64,7 @@ severity: int-value: 543 bool-value: true duration-value: 1h` - err := os.WriteFile("test.yaml", []byte(configFileData), os.ModePerm) + err := os.WriteFile("test.yaml", []byte(configFileData), permissionutil.ConfigFilePermission) require.Nil(t, err, "could not write temporary config") defer os.Remove("test.yaml") @@ -303,7 +304,7 @@ func TestParseFileCommaSeparatedStringSlice(t *testing.T) { testFileData := `value1 Value2 " value3` - err := os.WriteFile(testFile, []byte(testFileData), os.ModePerm) + err := os.WriteFile(testFile, []byte(testFileData), permissionutil.ConfigFilePermission) require.Nil(t, err, "could not write temporary values file") defer os.Remove(testFile) @@ -332,7 +333,7 @@ config-only: - test - test2 ` - err := os.WriteFile("test.yaml", []byte(configFileData), os.ModePerm) + err := os.WriteFile("test.yaml", []byte(configFileData), permissionutil.ConfigFilePermission) require.Nil(t, err, "could not write temporary config") defer os.Remove("test.yaml") From c92eaab9f48b2e8fb24c2c5ed3ab6a9043098ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Thu, 10 Aug 2023 11:57:21 +0000 Subject: [PATCH 09/19] go mod tidy --- go.sum | 8 -------- 1 file changed, 8 deletions(-) diff --git a/go.sum b/go.sum index db793ee..2cc9e7d 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= -github.com/microcosm-cc/bluemonday v1.0.24 h1:NGQoPtwGVcbGkKfvyYk1yRqknzBuoMiUrO6R7uFTPlw= -github.com/microcosm-cc/bluemonday v1.0.24/go.mod h1:ArQySAMps0790cHSkdPEJ7bGkF2VePWH773hsJNSHf8= github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= @@ -20,8 +18,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c h1:mNV/VSMi9wVpq3gcz4km2oUml9M+La20GaFoJPe3Ils= -github.com/projectdiscovery/utils v0.0.40-0.20230627061640-8ec2b35f851c/go.mod h1:rrd8dTBuKEScNMLgs1Xiu8rPCVeR0QTzmRcQ5iM3ymo= github.com/projectdiscovery/utils v0.0.48 h1:eXJfOYQ3whDIo4uBX68UiPCLCmGE7Isv9348YukaCbY= github.com/projectdiscovery/utils v0.0.48/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= @@ -32,13 +28,9 @@ golang.org/x/exp v0.0.0-20221019170559-20944726eadf h1:nFVjjKDgNY37+ZSYCJmtYf7tO golang.org/x/exp v0.0.0-20221019170559-20944726eadf/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= From 2d473ed2d5aaa435c4335754d8f1c31963654b06 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Thu, 10 Aug 2023 18:45:45 +0200 Subject: [PATCH 10/19] Fixing utils permissions (#135) * Fixing utils permissions * dep update --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4938c2d..5457d73 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/gorilla/css v1.0.0 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/utils v0.0.48 + github.com/projectdiscovery/utils v0.0.49 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 2cc9e7d..2839a00 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.0.48 h1:eXJfOYQ3whDIo4uBX68UiPCLCmGE7Isv9348YukaCbY= -github.com/projectdiscovery/utils v0.0.48/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= +github.com/projectdiscovery/utils v0.0.49 h1:yzOkC4suvvhFB2jVh2HzIHuGA5qLyo+NQOlXscsUW6I= +github.com/projectdiscovery/utils v0.0.49/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= From 821b811e2254cd449cbc353a9a973ef4ff2f8cc1 Mon Sep 17 00:00:00 2001 From: sandeep <8293321+ehsandeep@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:22:49 +0530 Subject: [PATCH 11/19] workflow fixes --- .github/dependabot.yml | 40 ++++++++++++++-------------- .github/release.yml | 17 ++++++++++++ .github/workflows/build-test.yml | 4 +++ .github/workflows/dep-auto-merge.yml | 26 ++++++++++++++++++ .github/workflows/lint-test.yml | 4 +++ 5 files changed, 71 insertions(+), 20 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/dep-auto-merge.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 69d9543..d068e53 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,32 +6,32 @@ version: 2 updates: - # Maintain dependencies for GitHub Actions - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - target-branch: "dev" - commit-message: - prefix: "chore" - include: "scope" - # Maintain dependencies for go modules - package-ecosystem: "gomod" directory: "/" schedule: interval: "weekly" - target-branch: "dev" + target-branch: "main" commit-message: prefix: "chore" include: "scope" - # Maintain dependencies for docker - - package-ecosystem: "docker" - directory: "/" - schedule: - interval: "weekly" - target-branch: "dev" - commit-message: - prefix: "chore" - include: "scope" \ No newline at end of file +# # Maintain dependencies for docker +# - package-ecosystem: "docker" +# directory: "/" +# schedule: +# interval: "weekly" +# target-branch: "dev" +# commit-message: +# prefix: "chore" +# include: "scope" +# +# # Maintain dependencies for GitHub Actions +# - package-ecosystem: "github-actions" +# directory: "/" +# schedule: +# interval: "weekly" +# target-branch: "dev" +# commit-message: +# prefix: "chore" +# include: "scope" \ No newline at end of file diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..596ba07 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,17 @@ +changelog: + exclude: + authors: + - dependabot + categories: + - title: 🎉 New Features + labels: + - "Type: Enhancement" + - title: 🐞 Bugs Fixes + labels: + - "Type: Bug" + - title: 🔨 Maintenance + labels: + - "Type: Maintenance" + - title: Other Changes + labels: + - "*" \ No newline at end of file diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index d2467fd..a6398bf 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,6 +1,10 @@ name: 🔨 Build Test + on: pull_request: + paths: + - '**.go' + - '**.mod' workflow_dispatch: diff --git a/.github/workflows/dep-auto-merge.yml b/.github/workflows/dep-auto-merge.yml new file mode 100644 index 0000000..fc26472 --- /dev/null +++ b/.github/workflows/dep-auto-merge.yml @@ -0,0 +1,26 @@ +name: 🤖 dep auto merge + +on: + pull_request: + branches: + - main + workflow_dispatch: + +permissions: + pull-requests: write + issues: write + repository-projects: write + +jobs: + automerge: + runs-on: ubuntu-latest + if: github.actor == 'dependabot[bot]' + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.DEPENDABOT_PAT }} + + - uses: ahmadnassri/action-dependabot-auto-merge@v2 + with: + github-token: ${{ secrets.DEPENDABOT_PAT }} + target: all \ No newline at end of file diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index b8aabe2..e75e50c 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -1,6 +1,10 @@ name: 🙏🏻 Lint Test + on: pull_request: + paths: + - '**.go' + - '**.mod' workflow_dispatch: jobs: From 14d114ec17869c0e46ddf3cf4ef06e38379ecf65 Mon Sep 17 00:00:00 2001 From: Ramana Reddy Date: Fri, 11 Aug 2023 22:28:14 +0530 Subject: [PATCH 12/19] add slice support to dynamic var --- dynamic_var.go | 14 ++++++++++++-- examples/basic/main.go | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dynamic_var.go b/dynamic_var.go index b5e69b2..ceff9b2 100644 --- a/dynamic_var.go +++ b/dynamic_var.go @@ -5,6 +5,7 @@ import ( "fmt" "reflect" "strconv" + "strings" ) type dynamicFlag struct { @@ -54,6 +55,13 @@ func (df *dynamicFlag) Set(value string) error { return nil } *stringField = value + case reflect.Slice: + sliceField := df.field.(*[]string) + if isBoolValue { + *sliceField = df.defaultValue.([]string) + return nil + } + *sliceField = append(*sliceField, strings.Split(value, ",")...) default: return errors.New("unsupported type") } @@ -70,8 +78,10 @@ func (df *dynamicFlag) String() string { // DynamicVar acts as flag with a default value or a option with value // example: -// var titleSize int -// flagSet.DynamicVar(&titleSize, "title", 50, "first N characters of the title") +// +// var titleSize int +// flagSet.DynamicVar(&titleSize, "title", 50, "first N characters of the title") +// // > go run ./examples/basic -title or go run ./examples/basic -title=100 // In case of `go run ./examples/basic -title` it will use default value 50 func (flagSet *FlagSet) DynamicVar(field interface{}, long string, defaultValue interface{}, usage string) *FlagData { diff --git a/examples/basic/main.go b/examples/basic/main.go index 2a10776..6f3f644 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -20,6 +20,7 @@ type Options struct { // Dynamic titleSize int target string + hashes []string } func main() { @@ -46,6 +47,7 @@ func main() { flagSet.CreateGroup("Dynmaic", "Dynamic", flagSet.DynamicVarP(&testOptions.titleSize, "title", "t", 50, "first N characters of the title"), flagSet.DynamicVarP(&testOptions.target, "target", "u", "https://example.com", "target url"), + flagSet.DynamicVarP(&testOptions.hashes, "hashes", "hs", []string{"md5", "sha1"}, "supported hashes"), ) flagSet.SetCustomHelpText("EXAMPLE USAGE:\ngo run ./examples/basic [OPTIONS]") @@ -56,6 +58,7 @@ func main() { // TODO: remove this fmt.Println("title size:", testOptions.titleSize) fmt.Println("target:", testOptions.target) + fmt.Println("hashes:", testOptions.hashes) // ratelimits value is if len(testOptions.rls.AsMap()) > 0 { From fbfc334ef2064d38f173e85a8217ab0759a9db40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Tue, 15 Aug 2023 11:53:53 +0000 Subject: [PATCH 13/19] run test on win and osx --- .github/workflows/build-test.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index a6398bf..c657e55 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -11,12 +11,17 @@ on: jobs: build: name: Test Builds - runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.20.x] + os: [ubuntu-latest, windows-latest, macOS-latest] + + runs-on: ${{ matrix.os }} steps: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.20.x + go-version: ${{ matrix.go-version }} - name: Check out code uses: actions/checkout@v3 From 3f5e47e3a7cb53019c05c1a59b8fc93801b87211 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:54:25 +0000 Subject: [PATCH 14/19] chore(deps): bump github.com/projectdiscovery/utils Bumps [github.com/projectdiscovery/utils](https://github.com/projectdiscovery/utils) from 0.0.49 to 0.0.50. - [Release notes](https://github.com/projectdiscovery/utils/releases) - [Commits](https://github.com/projectdiscovery/utils/compare/v0.0.49...v0.0.50) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5457d73..037cb40 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/gorilla/css v1.0.0 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/utils v0.0.49 + github.com/projectdiscovery/utils v0.0.50 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 2839a00..65713ab 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.0.49 h1:yzOkC4suvvhFB2jVh2HzIHuGA5qLyo+NQOlXscsUW6I= -github.com/projectdiscovery/utils v0.0.49/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= +github.com/projectdiscovery/utils v0.0.50 h1:nP62c7dLUTwXaZf7ijjL9DmClolSJvp7NfOdtdYlmQ0= +github.com/projectdiscovery/utils v0.0.50/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= From b8aadabeb08ffe5f2de2326a3ef1af2aacd5bf17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 21:07:19 +0000 Subject: [PATCH 15/19] chore(deps): bump github.com/projectdiscovery/utils Bumps [github.com/projectdiscovery/utils](https://github.com/projectdiscovery/utils) from 0.0.50 to 0.0.52. - [Release notes](https://github.com/projectdiscovery/utils/releases) - [Commits](https://github.com/projectdiscovery/utils/compare/v0.0.50...v0.0.52) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 037cb40..63a5abd 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/gorilla/css v1.0.0 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/utils v0.0.50 + github.com/projectdiscovery/utils v0.0.52 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 65713ab..6d389d0 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.0.50 h1:nP62c7dLUTwXaZf7ijjL9DmClolSJvp7NfOdtdYlmQ0= -github.com/projectdiscovery/utils v0.0.50/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= +github.com/projectdiscovery/utils v0.0.52 h1:2ljEbt9bUDP3rhOB4i7bkiOpMXZGFA/l1FCZjSr1WDE= +github.com/projectdiscovery/utils v0.0.52/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= From a3afacc00fb64d66e503e0713e8c48f87631548b Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Tue, 29 Aug 2023 08:11:23 +0200 Subject: [PATCH 16/19] go 1.20 (via utils) --- examples/basic/main.go | 10 +++++----- go.mod | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/basic/main.go b/examples/basic/main.go index 6f3f644..ef600bb 100644 --- a/examples/basic/main.go +++ b/examples/basic/main.go @@ -55,11 +55,6 @@ func main() { log.Fatal(err) } - // TODO: remove this - fmt.Println("title size:", testOptions.titleSize) - fmt.Println("target:", testOptions.target) - fmt.Println("hashes:", testOptions.hashes) - // ratelimits value is if len(testOptions.rls.AsMap()) > 0 { fmt.Printf("Got RateLimits: %+v\n", testOptions.rls) @@ -68,4 +63,9 @@ func main() { if len(testOptions.severity) > 0 { fmt.Printf("Got Severity: %+v\n", testOptions.severity) } + + fmt.Println("Dynamic Values Output") + fmt.Println("title size:", testOptions.titleSize) + fmt.Println("target:", testOptions.target) + fmt.Println("hashes:", testOptions.hashes) } diff --git a/go.mod b/go.mod index f9e7b97..0937e78 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/projectdiscovery/goflags -go 1.18 +go 1.20 require ( github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 From 4cbc30d3aa65f4a761a6601377a4824929f191ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 21:23:53 +0000 Subject: [PATCH 17/19] chore(deps): bump github.com/projectdiscovery/utils Bumps [github.com/projectdiscovery/utils](https://github.com/projectdiscovery/utils) from 0.0.52 to 0.0.54. - [Release notes](https://github.com/projectdiscovery/utils/releases) - [Changelog](https://github.com/projectdiscovery/utils/blob/main/CHANGELOG.md) - [Commits](https://github.com/projectdiscovery/utils/compare/v0.0.52...v0.0.54) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b0ef4d3..51d7763 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/gorilla/css v1.0.0 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/utils v0.0.52 + github.com/projectdiscovery/utils v0.0.54 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 6d389d0..ae56549 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.0.52 h1:2ljEbt9bUDP3rhOB4i7bkiOpMXZGFA/l1FCZjSr1WDE= -github.com/projectdiscovery/utils v0.0.52/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= +github.com/projectdiscovery/utils v0.0.54 h1:qwTIalrK8pKYaxFObdeSfCtwDmVCN9qswc8+7jIpnBM= +github.com/projectdiscovery/utils v0.0.54/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= From a976ad4da9c48aa229009d44474379c90a241ff9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:42:16 +0000 Subject: [PATCH 18/19] chore(deps): bump github.com/projectdiscovery/utils Bumps [github.com/projectdiscovery/utils](https://github.com/projectdiscovery/utils) from 0.0.54 to 0.0.55. - [Release notes](https://github.com/projectdiscovery/utils/releases) - [Changelog](https://github.com/projectdiscovery/utils/blob/main/CHANGELOG.md) - [Commits](https://github.com/projectdiscovery/utils/compare/v0.0.54...v0.0.55) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 51d7763..c20c9c7 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/gorilla/css v1.0.0 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/utils v0.0.54 + github.com/projectdiscovery/utils v0.0.55 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index ae56549..1a09eb5 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.0.54 h1:qwTIalrK8pKYaxFObdeSfCtwDmVCN9qswc8+7jIpnBM= -github.com/projectdiscovery/utils v0.0.54/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= +github.com/projectdiscovery/utils v0.0.55 h1:QcJhedFVr13ZIJwr81fdXVxylhrub6oQCTFqweDjxe8= +github.com/projectdiscovery/utils v0.0.55/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= From 8b40163a2d3a30f77c38ad6f5f6cdb9dacdcee9f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Sep 2023 21:59:24 +0000 Subject: [PATCH 19/19] chore(deps): bump github.com/projectdiscovery/utils Bumps [github.com/projectdiscovery/utils](https://github.com/projectdiscovery/utils) from 0.0.55 to 0.0.56. - [Release notes](https://github.com/projectdiscovery/utils/releases) - [Changelog](https://github.com/projectdiscovery/utils/blob/main/CHANGELOG.md) - [Commits](https://github.com/projectdiscovery/utils/compare/v0.0.55...v0.0.56) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/utils dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c20c9c7..1f4f8db 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/gorilla/css v1.0.0 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/utils v0.0.55 + github.com/projectdiscovery/utils v0.0.56 github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect golang.org/x/net v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 1a09eb5..4b8409a 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.0.55 h1:QcJhedFVr13ZIJwr81fdXVxylhrub6oQCTFqweDjxe8= -github.com/projectdiscovery/utils v0.0.55/go.mod h1:WhzbWSyGkTDn4Jvw+7jM2yP675/RARegNjoA6S7zYcc= +github.com/projectdiscovery/utils v0.0.56 h1:n6L7eGauQ/qiuIb6ayGfsJrXydZov51HNv5nuzARFrc= +github.com/projectdiscovery/utils v0.0.56/go.mod h1:5ub86JF91NnI3nTMIzEpL/pfsNb0jtHznzKi9hv03X4= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI= github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=