{"record":{"id":"f689fd2cba2408e9","repo":"owasp-amass/amass","slug":"s-is-not-a-valid-cidr","errorCode":null,"errorMessage":"%s is not a valid CIDR","messagePattern":"(.+?) is not a valid CIDR","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/parse.go","lineNumber":164,"sourceCode":"func (p *ParseCIDRs) String() string {\n\tif p == nil {\n\t\treturn \"\"\n\t}\n\n\tvar builder strings.Builder\n\tfor i, ipnet := range *p {\n\t\tif i > 0 {\n\t\t\tbuilder.WriteRune(',')\n\t\t}\n\t\tbuilder.WriteString(ipnet.String())\n\t}\n\treturn builder.String()\n}\n\n// Set implements the flag.Value interface.\nfunc (p *ParseCIDRs) Set(s string) error {\n\tif s == \"\" {\n\t\treturn fmt.Errorf(\"%s is not a valid CIDR\", s)\n\t}\n\n\tcidrs := strings.Split(s, \",\")\n\tfor _, cidr := range cidrs {\n\t\t_, ipnet, err := net.ParseCIDR(cidr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse %s as a CIDR\", cidr)\n\t\t}\n\n\t\t*p = append(*p, ipnet)\n\t}\n\treturn nil\n}\n\nfunc (p *ParseASNs) String() string {\n\tif p == nil {\n\t\treturn \"\"\n\t}","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/parse.go#L146-L182","documentation":"ParseCIDRs is a flag.Value implementation for comma-separated CIDR flags. Set returns this error when the entire flag value is the empty string — the interpolated s is empty, so the message reads \" is not a valid CIDR\". It guards against producing an empty or meaningless []*net.IPNet.","triggerScenarios":"Calling Set(\"\") on a *ParseCIDRs, e.g. `-cidr \"$CIDRS\"` with CIDRS unset, or explicitly passing `-cidr \"\"`.","commonSituations":"Unset shell variables, templated commands with unfilled values, or attempts to clear the flag with an empty string.","solutions":["Provide a non-empty comma-separated CIDR list such as \"10.0.0.0/8,192.168.0.0/16\".","Test the shell variable for non-emptiness before invoking.","Omit the flag when no CIDRs are needed."],"exampleFix":"// before\n-cidr \"$CIDRS\"    # CIDRS empty -> \" is not a valid CIDR\"\n// after\n-cidr \"10.0.0.0/24\"","handlingStrategy":"validation","validationCode":"func validateCIDRsFlag(value string) error {\n\tif strings.TrimSpace(value) == \"\" {\n\t\treturn errors.New(\"flag requires a non-empty CIDR list\")\n\t}\n\tfor _, c := range strings.Split(value, \",\") {\n\t\tif _, _, err := net.ParseCIDR(strings.TrimSpace(c)); err != nil {\n\t\t\treturn fmt.Errorf(\"entry %q is not valid CIDR\", c)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isCIDRList(s string) bool {\n\tif strings.TrimSpace(s) == \"\" { return false }\n\tfor _, c := range strings.Split(s, \",\") {\n\t\tif _, _, err := net.ParseCIDR(strings.TrimSpace(c)); err != nil { return false }\n\t}\n\treturn true\n}","tryCatchPattern":null,"preventionTips":["Never pass an empty string to CIDR flags; omit the flag instead.","Pre-validate with net.ParseCIDR before running the tool.","Keep CIDR lists in config files and load them through validated paths."],"tags":["cli","flag-parsing","cidr","network"],"backgroundTag":"invalid-flag-value","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}