{"record":{"id":"6c12551fc3aa4d23","repo":"owasp-amass/amass","slug":"asn-parsing-failed","errorCode":null,"errorMessage":"ASN parsing failed","messagePattern":"ASN parsing failed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/afmt/parse.go","lineNumber":196,"sourceCode":"\nfunc (p *ParseASNs) String() string {\n\tif p == nil {\n\t\treturn \"\"\n\t}\n\tvar builder strings.Builder\n\tfor i, n := range *p {\n\t\tif i > 0 {\n\t\t\tbuilder.WriteRune(',')\n\t\t}\n\t\tbuilder.WriteString(strconv.Itoa(n))\n\t}\n\treturn builder.String()\n}\n\n// Set implements the flag.Value interface.\nfunc (p *ParseASNs) Set(s string) error {\n\tif s == \"\" {\n\t\treturn fmt.Errorf(\"ASN parsing failed\")\n\t}\n\n\tasns := strings.Split(s, \",\")\n\tfor _, asn := range asns {\n\t\ti, err := strconv.Atoi(strings.TrimPrefix(strings.TrimSpace(asn), \"AS\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*p = append(*p, i)\n\t}\n\treturn nil\n}\n","sourceCodeStart":178,"sourceCodeEnd":209,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/internal/afmt/parse.go#L178-L209","documentation":"ParseASNs is a flag.Value implementation for comma-separated ASN flags. Set rejects an empty string with this error; otherwise each token has an optional \"AS\" prefix stripped (via TrimPrefix after trimming whitespace) and parsed with strconv.Atoi. Any token that is not numeric aborts the whole flag.","triggerScenarios":"Calling Set(\"\") on a *ParseASNs, or tokens like \"AS123x\", \"AS \", \"AS13335,foo\", or numbers exceeding platform int range.","commonSituations":"Paste with stray characters or spaces after \"AS\", lists joined with semicolons or spaces instead of commas, empty environment variables in scripted runs.","solutions":["Provide comma-separated numeric ASNs, with or without the AS prefix: \"AS13335,15169\".","Strip whitespace and non-digit characters from each token before passing.","Confirm the feeding variable is non-empty before invocation."],"exampleFix":"// before\n-asn \"$ASNS\"                # empty -> ASN parsing failed\n// after\n-asn \"AS13335,AS15169\"","handlingStrategy":"validation","validationCode":"func validateASNsFlag(value string) error {\n\tif strings.TrimSpace(value) == \"\" {\n\t\treturn errors.New(\"flag requires a non-empty ASN list\")\n\t}\n\tfor _, a := range strings.Split(value, \",\") {\n\t\tif _, err := strconv.Atoi(strings.TrimPrefix(strings.TrimSpace(a), \"AS\")); err != nil {\n\t\t\treturn fmt.Errorf(\"token %q is not a valid ASN\", a)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isASNToken(s string) bool { _, err := strconv.Atoi(strings.TrimPrefix(strings.TrimSpace(s), \"AS\")); return err == nil }","tryCatchPattern":null,"preventionTips":["Use the canonical \"AS<number>\" form with no internal whitespace.","Join ASN lists with commas only, never semicolons or spaces.","Pre-check each token with strconv.Atoi after stripping the AS prefix."],"tags":["cli","flag-parsing","asn","integer"],"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-14T05:17:10.506Z"}