Debian Codegraph @

pkg/output/file_json.go

raw symbols SCIP
1 package outputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/
2
3 import (
4 "encoding/jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/"
5 "osscip-go gomod github.com/golang/go/src go1.18 os/"
6 "timescip-go gomod github.com/golang/go/src go1.18 time/"
7
8 "github.com/ffuf/ffuf/v2/pkg/ffufscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/"
9 )
10
11 type ejsonFileOutputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput# struct {
12 CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#CommandLine. string `json:"commandline"`
13 Timescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#Time. string `json:"time"`
14 Resultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#Results. []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# `json:"results"`
15 Configscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#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# `json:"config"`
16 }
17
18 type JsonResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult# struct {
19 Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Input. map[string]string `json:"input"`
20 Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Position. int `json:"position"`
21 StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#StatusCode. int64 `json:"status"`
22 ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentLength. int64 `json:"length"`
23 ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentWords. int64 `json:"words"`
24 ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentLines. int64 `json:"lines"`
25 ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentType. string `json:"content-type"`
26 RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#RedirectLocation. string `json:"redirectlocation"`
27 ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ScraperData. map[string][]string `json:"scraper"`
28 Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Duration. timescip-go gomod github.com/golang/go/src go1.18 time/.Durationscip-go gomod github.com/golang/go/src go1.18 time/Duration# `json:"duration"`
29 ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ResultFile. string `json:"resultfile"`
30 Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Url. string `json:"url"`
31 Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Host. string `json:"host"`
32 }
33
34 type jsonFileOutputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput# struct {
35 CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#CommandLine. string `json:"commandline"`
36 Timescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#Time. string `json:"time"`
37 Resultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#Results. []JsonResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult# `json:"results"`
38 Configscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#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# `json:"config"`
39 }
40
41 func writeEJSONscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/writeEJSON().(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#) error {
42 t := timescip-go gomod github.com/golang/go/src go1.18 time/.Nowscip-go gomod github.com/golang/go/src go1.18 time/Now().()
43 outJSON := ejsonFileOutputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#{
44 CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#CommandLine.: config.CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#CommandLine.,
45 Timescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#Time.: t.Formatscip-go gomod github.com/golang/go/src go1.18 time/Time#Format().(timescip-go gomod github.com/golang/go/src go1.18 time/.RFC3339scip-go gomod github.com/golang/go/src go1.18 time/RFC3339.),
46 Resultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/ejsonFileOutput#Results.: res,
47 }
48
49 outBytes, err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Marshal().(outJSON)
50 if err != nil {
51 return err
52 }
53 err = osscip-go gomod github.com/golang/go/src go1.18 os/.WriteFilescip-go gomod github.com/golang/go/src go1.18 os/WriteFile().(filename, outBytes, 0644)
54 if err != nil {
55 return err
56 }
57 return nil
58 }
59
60 func writeJSONscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/writeJSON().(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#) error {
61 t := timescip-go gomod github.com/golang/go/src go1.18 time/.Nowscip-go gomod github.com/golang/go/src go1.18 time/Now().()
62 jsonRes := make([]JsonResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#, 0)
63 for _, r := range res {
64 strinput := make(map[string]string)
65 for k, v := range r.Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Input. {
66 strinput[k] = string(v)
67 }
68 jsonRes = append(jsonRes, JsonResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#{
69 Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Input.: strinput,
70 Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Position.: r.Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Position.,
71 StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#StatusCode.: r.StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#StatusCode.,
72 ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentLength.: r.ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLength.,
73 ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentWords.: r.ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentWords.,
74 ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentLines.: r.ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLines.,
75 ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ContentType.: r.ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentType.,
76 RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#RedirectLocation.: r.RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#RedirectLocation.,
77 ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ScraperData.: r.ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ScraperData.,
78 Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Duration.: r.Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Duration.,
79 ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#ResultFile.: r.ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ResultFile.,
80 Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Url.: r.Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Url.,
81 Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/JsonResult#Host.: r.Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Host.,
82 })
83 }
84 outJSON := jsonFileOutputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#{
85 CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#CommandLine.: config.CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#CommandLine.,
86 Timescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#Time.: t.Formatscip-go gomod github.com/golang/go/src go1.18 time/Time#Format().(timescip-go gomod github.com/golang/go/src go1.18 time/.RFC3339scip-go gomod github.com/golang/go/src go1.18 time/RFC3339.),
87 Resultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#Results.: jsonRes,
88 Configscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/jsonFileOutput#Config.: config,
89 }
90 outBytes, err := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Marshal().(outJSON)
91 if err != nil {
92 return err
93 }
94 err = osscip-go gomod github.com/golang/go/src go1.18 os/.WriteFilescip-go gomod github.com/golang/go/src go1.18 os/WriteFile().(filename, outBytes, 0644)
95 if err != nil {
96 return err
97 }
98 return nil
99 }