{"record":{"id":"f7a15aa93c640d26","repo":"kgretzky/evilginx2","slug":"export-format-can-only-be-text-csv-or-json","errorCode":null,"errorMessage":"export format can only be 'text', 'csv' or 'json'","messagePattern":"export format can only be 'text', 'csv' or 'json'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/terminal.go","lineNumber":1670,"sourceCode":"\t\t\t\t\t\t\t}\n\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn ret, ret_params, fmt.Errorf(\"array of parameters not found\")\n\t\t\t}*/\n\t}\n\treturn ret, ret_params, nil\n}\n\nfunc (t *Terminal) exportPhishUrls(export_path string, phish_urls []string, phish_params []map[string]string, format string) error {\n\tif len(phish_urls) != len(phish_params) {\n\t\treturn fmt.Errorf(\"phishing urls and phishing parameters count do not match\")\n\t}\n\tif !stringExists(format, []string{\"text\", \"csv\", \"json\"}) {\n\t\treturn fmt.Errorf(\"export format can only be 'text', 'csv' or 'json'\")\n\t}\n\n\tf, err := os.OpenFile(export_path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tif format == \"text\" {\n\t\tfor n, phish_url := range phish_urls {\n\t\t\tvar params string\n\t\t\tm := 0\n\t\t\tparams_row := phish_params[n]\n\t\t\tfor k, v := range params_row {\n\t\t\t\tif m > 0 {\n\t\t\t\t\tparams += \" \"\n\t\t\t\t}\n\t\t\t\tparams += fmt.Sprintf(\"%s=\\\"%s\\\"\", k, v)","sourceCodeStart":1652,"sourceCodeEnd":1688,"githubUrl":"https://github.com/kgretzky/evilginx2/blob/4c0988a1d9db4d172a185e979a38bfd0efdb5830/core/terminal.go#L1652-L1688","documentation":"exportPhishUrls validates the requested export format against a whitelist of 'text', 'csv' and 'json' and rejects anything else. The format string is chosen when invoking the lure URL export command, so an unsupported or misspelled format aborts the export before any file is written.","triggerScenarios":"Calling exportPhishUrls (via the lures export command) with format values like 'txt', 'JSON' (uppercase), 'yaml', or an empty string.","commonSituations":"Typing 'txt' instead of 'text', assuming case-insensitive matching (stringExists is case-sensitive), or scripting with a variable that defaults to a different format name.","solutions":["Use exactly one of: 'text', 'csv', 'json' (lowercase).","Fix casing — the check is case-sensitive, so 'JSON' fails.","Verify the scripted variable resolves to a supported value before invoking the export."],"exampleFix":"// before\nlures export urls out.txt txt\n// after\nlures export urls out.txt text","handlingStrategy":"validation","validationCode":"var allowed = map[string]bool{\"text\": true, \"csv\": true, \"json\": true}\nformat = strings.ToLower(format)\nif !allowed[format] {\n    return fmt.Errorf(\"unsupported export format %q; use text, csv or json\", format)\n}\nerr := t.exportPhishUrls(path, urls, params, format)","typeGuard":null,"tryCatchPattern":"if err := t.exportPhishUrls(path, urls, params, format); err != nil {\n    if strings.Contains(err.Error(), \"export format\") {\n        log.Printf(\"%q is not supported; pick text, csv or json\", format)\n        return\n    }\n    return err\n}","preventionTips":["Normalize format strings with strings.ToLower before use","Keep a constant list of supported formats in scripts","Validate user-supplied format at the CLI boundary"],"tags":["cli","validation","export-format"],"backgroundTag":"invalid-enum-value","analyzedSha":"4c0988a1d9db4d172a185e979a38bfd0efdb5830","analyzedAt":"2026-09-05T19:23:07.238Z","contentChangedAt":"2026-09-05T19:23:07.238Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}