| 1 | package outputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ |
| 2 | |
| 3 | import ( |
| 4 | "encoding/base64scip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/" |
| 5 | "encoding/csvscip-go gomod github.com/golang/go/src go1.18 `encoding/csv`/" |
| 6 | "osscip-go gomod github.com/golang/go/src go1.18 os/" |
| 7 | "strconvscip-go gomod github.com/golang/go/src go1.18 strconv/" |
| 8 | |
| 9 | "github.com/ffuf/ffuf/v2/pkg/ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/" |
| 10 | ) |
| 11 | |
| 12 | var staticheadersscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/staticheaders. = []string{"url", "redirectlocation", "position", "status_code", "content_length", "content_words", "content_lines", "content_type", "duration", "resultfile", "Ffufhash"} |
| 13 | |
| 14 | func writeCSVscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/writeCSV().(filename string, config *ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Configscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#, res []ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Resultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#, encode bool) error { |
| 15 | header := make([]string, 0) |
| 16 | f, err := osscip-go gomod github.com/golang/go/src go1.18 os/.Createscip-go gomod github.com/golang/go/src go1.18 os/Create().(filename) |
| 17 | if err != nil { |
| 18 | return err |
| 19 | } |
| 20 | defer f.Closescip-go gomod github.com/golang/go/src go1.18 os/File#Close().() |
| 21 | |
| 22 | w := csvscip-go gomod github.com/golang/go/src go1.18 `encoding/csv`/.NewWriterscip-go gomod github.com/golang/go/src go1.18 `encoding/csv`/NewWriter().(f) |
| 23 | defer w.Flushscip-go gomod github.com/golang/go/src go1.18 `encoding/csv`/Writer#Flush().() |
| 24 | |
| 25 | for _, inputprovider := range config.InputProvidersscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#InputProviders. { |
| 26 | header = append(header, inputprovider.Keywordscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/InputProviderConfig#Keyword.) |
| 27 | } |
| 28 | header = append(header, staticheadersscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/staticheaders....) |
| 29 | |
| 30 | if err := w.Writescip-go gomod github.com/golang/go/src go1.18 `encoding/csv`/Writer#Write().(header); err != nil { |
| 31 | return err |
| 32 | } |
| 33 | for _, r := range res { |
| 34 | if encode { |
| 35 | inputs := make(map[string][]byte, len(r.Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Input.)) |
| 36 | for k, v := range r.Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Input. { |
| 37 | inputs[k] = []byte(base64encodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/base64encode().(v)) |
| 38 | } |
| 39 | r.Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Input. = inputs |
| 40 | } |
| 41 | |
| 42 | err := w.Writescip-go gomod github.com/golang/go/src go1.18 `encoding/csv`/Writer#Write().(toCSVscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/toCSV().(r)) |
| 43 | if err != nil { |
| 44 | return err |
| 45 | } |
| 46 | } |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | func base64encodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/base64encode().(in []byte) string { |
| 51 | return base64scip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/.StdEncodingscip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/StdEncoding..EncodeToStringscip-go gomod github.com/golang/go/src go1.18 `encoding/base64`/Encoding#EncodeToString().(in) |
| 52 | } |
| 53 | |
| 54 | func toCSVscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/toCSV().(r ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/.Resultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#) []string { |
| 55 | res := make([]string, 0) |
| 56 | ffufhash := "" |
| 57 | for k, v := range r.Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Input. { |
| 58 | if k == "FFUFHASH" { |
| 59 | ffufhash = string(v) |
| 60 | } else { |
| 61 | res = append(res, string(v)) |
| 62 | } |
| 63 | } |
| 64 | res = append(res, r.Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Url.) |
| 65 | res = append(res, r.RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#RedirectLocation.) |
| 66 | res = append(res, strconvscip-go gomod github.com/golang/go/src go1.18 strconv/.Itoascip-go gomod github.com/golang/go/src go1.18 strconv/Itoa().(r.Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Position.)) |
| 67 | res = append(res, strconvscip-go gomod github.com/golang/go/src go1.18 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.18 strconv/FormatInt().(r.StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#StatusCode., 10)) |
| 68 | res = append(res, strconvscip-go gomod github.com/golang/go/src go1.18 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.18 strconv/FormatInt().(r.ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLength., 10)) |
| 69 | res = append(res, strconvscip-go gomod github.com/golang/go/src go1.18 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.18 strconv/FormatInt().(r.ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentWords., 10)) |
| 70 | res = append(res, strconvscip-go gomod github.com/golang/go/src go1.18 strconv/.FormatIntscip-go gomod github.com/golang/go/src go1.18 strconv/FormatInt().(r.ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLines., 10)) |
| 71 | res = append(res, r.ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentType.) |
| 72 | res = append(res, r.Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Duration..Stringscip-go gomod github.com/golang/go/src go1.18 time/Duration#String().()) |
| 73 | res = append(res, r.ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ResultFile.) |
| 74 | res = append(res, ffufhash) |
| 75 | return res |
| 76 | } |