{"record":{"id":"f08165d7b8b808df","repo":"owasp-amass/amass","slug":"invalid-port-string-v","errorCode":null,"errorMessage":"invalid port string: %v","messagePattern":"invalid port string: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scope.go","lineNumber":118,"sourceCode":"\t}\n\n\tfor _, port := range s.PortsRaw {\n\t\tswitch p := port.(type) {\n\t\tcase int: // If it's an integer, just append\n\t\t\ts.Ports = append(s.Ports, p)\n\t\tcase string: // If it's a string, check if it's a range or a single port\n\t\t\tif strings.Contains(p, \"-\") {\n\t\t\t\t// Handle port range\n\t\t\t\tportRange, err := convertPortRangeToSlice(p)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\ts.Ports = append(s.Ports, portRange...)\n\t\t\t} else {\n\t\t\t\t// Handle single port string\n\t\t\t\tportNum, err := strconv.Atoi(p)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"invalid port string: %v\", err)\n\t\t\t\t}\n\t\t\t\ts.Ports = append(s.Ports, portNum)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unsupported port type: %T\", p)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc convertPortRangeToSlice(portRange string) ([]int, error) {\n\tvar ports []int\n\n\tparts := strings.Split(portRange, \"-\")\n\tif len(parts) != 2 {\n\t\treturn nil, fmt.Errorf(\"invalid port range format\")\n\t}","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/scope.go#L100-L136","documentation":"parsePorts accepts port entries as strings or ints; a string entry must be a plain integer or a range like '80-90'. When a string is neither and strconv.Atoi fails, this error wraps the Atoi error. Ranges are handled earlier, so this fires only for non-range strings.","triggerScenarios":"A scope Ports entry is a string like 'http', '80,443', '80 ', or '0x50' — anything strconv.Atoi cannot parse after the range path (contains '-') was not taken.","commonSituations":"Config lists service names or comma-separated ports in a single string instead of separate numeric entries; whitespace or typos like '8o'; ports pasted from nmap output.","solutions":["Change the entry to a numeric string, e.g. '80' instead of 'http'","Split comma-separated values '80,443' into separate entries 80 and 443","Trim whitespace/hidden characters from the string entry","Use the range syntax '80-90' if a span of ports was intended"],"exampleFix":"// before (config)\nports: [\"http\", \"80,443\"]\n// after\nports: [80, 443]","handlingStrategy":"validation","validationCode":"for _, p := range ports { if s, ok := p.(string); ok && !strings.Contains(s, \"-\") { if _, err := strconv.Atoi(strings.TrimSpace(s)); err != nil { return err } } }","typeGuard":"func isNumericPortString(s string) bool { _, err := strconv.Atoi(strings.TrimSpace(s)); return err == nil }","tryCatchPattern":"if err := parsePorts(raw); err != nil { return fmt.Errorf(\"ports config invalid: %w\", err) }","preventionTips":["Use integers for ports in config files","No service names or comma-packed strings","Trim whitespace on values","Use range syntax '80-90' for spans"],"tags":["config","ports","parsing"],"backgroundTag":"invalid-config-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"}