Debian Codegraph @

pkg/output/file_html.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 "htmlscip-go gomod github.com/golang/go/src go1.18 html/"
5 "html/templatescip-go gomod github.com/golang/go/src go1.18 `html/template`/"
6 "osscip-go gomod github.com/golang/go/src go1.18 os/"
7 "timescip-go gomod github.com/golang/go/src go1.18 time/"
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 type htmlResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult# struct {
13 Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Input. map[string]string
14 Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Position. int
15 StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#StatusCode. int64
16 ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentLength. int64
17 ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentWords. int64
18 ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentLines. int64
19 ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentType. string
20 RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#RedirectLocation. string
21 ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ScraperData. string
22 Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Duration. timescip-go gomod github.com/golang/go/src go1.18 time/.Durationscip-go gomod github.com/golang/go/src go1.18 time/Duration#
23 ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ResultFile. string
24 Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Url. string
25 Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Host. string
26 HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#HTMLColor. string
27 FfufHashscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#FfufHash. string
28 }
29
30 type htmlFileOutputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput# struct {
31 CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#CommandLine. string
32 Timescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Time. string
33 Keysscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Keys. []string
34 Resultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Results. []htmlResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#
35 }
36
37 const (
38 htmlTemplatescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlTemplate. = `
39 <!DOCTYPE html>
40 <html>
41 <head>
42 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
43 <meta
44 name="viewport"
45 content="width=device-width, initial-scale=1, maximum-scale=1.0"
46 />
47 <title>FFUF Report - </title>
48
49 <!-- CSS -->
50 <link
51 href="https://fonts.googleapis.com/icon?family=Material+Icons"
52 rel="stylesheet"
53 />
54 <link
55 rel="stylesheet"
56 href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css"
57 />
58 <link
59 rel="stylesheet"
60 type="text/css"
61 href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css"
62 />
63
64 </head>
65
66 <body>
67 <nav>
68 <div class="nav-wrapper">
69 <a href="#" class="brand-logo">FFUF</a>
70 <ul id="nav-mobile" class="right hide-on-med-and-down">
71 </ul>
72 </div>
73 </nav>
74
75 <main class="section no-pad-bot" id="index-banner">
76 <div class="container">
77 <br /><br />
78 <h1 class="header center ">FFUF Report</h1>
79 <div class="row center">
80
81 <pre>{{ .CommandLine }}</pre>
82 <pre>{{ .Time }}</pre>
83
84 <table id="ffufreport">
85 <thead>
86 <div style="display:none">
87 |result_raw|StatusCode{{ range $keyword := .Keys }}|{{ $keyword | printf "%s" }}{{ end }}|Url|RedirectLocation|Position|ContentLength|ContentWords|ContentLines|ContentType|Duration|Resultfile|ScraperData|FfufHash|
88 </div>
89 <tr>
90 <th>Status</th>
91 {{ range .Keys }} <th>{{ . }}</th>{{ end }}
92 <th>URL</th>
93 <th>Redirect location</th>
94 <th>Position</th>
95 <th>Length</th>
96 <th>Words</th>
97 <th>Lines</th>
98 <th>Type</th>
99 <th>Duration</th>
100 <th>Resultfile</th>
101 <th>Scraper data</th>
102 <th>Ffuf Hash</th>
103 </tr>
104 </thead>
105
106 <tbody>
107 {{range $result := .Results}}
108 <div style="display:none">
109 |result_raw|{{ $result.StatusCode }}{{ range $keyword, $value := $result.Input }}|{{ $value | printf "%s" }}{{ end }}|{{ $result.Url }}|{{ $result.RedirectLocation }}|{{ $result.Position }}|{{ $result.ContentLength }}|{{ $result.ContentWords }}|{{ $result.ContentLines }}|{{ $result.ContentType }}|{{ $result.Duration }}|{{ $result.ResultFile }}|{{ $result.ScraperData }}|{{ $result.FfufHash }}|
110 </div>
111 <tr class="result-{{ $result.StatusCode }}" style="background-color: {{ $result.HTMLColor }};">
112 <td><font color="black" class="status-code">{{ $result.StatusCode }}</font></td>
113 {{ range $keyword, $value := $result.Input }}
114 <td>{{ $value | printf "%s" }}</td>
115 {{ end }}
116 <td><a href="{{ $result.Url }}">{{ $result.Url }}</a></td>
117 <td><a href="{{ $result.RedirectLocation }}">{{ $result.RedirectLocation }}</a></td>
118 <td>{{ $result.Position }}</td>
119 <td>{{ $result.ContentLength }}</td>
120 <td>{{ $result.ContentWords }}</td>
121 <td>{{ $result.ContentLines }}</td>
122 <td>{{ $result.ContentType }}</td>
123 <td>{{ $result.Duration }}</td>
124 <td>{{ $result.ResultFile }}</td>
125 <td>{{ $result.ScraperData }}</td>
126 <td>{{ $result.FfufHash }}</td>
127 </tr>
128 {{ end }}
129 </tbody>
130 </table>
131
132 </div>
133 <br /><br />
134 </div>
135 </main>
136
137 <!--JavaScript at end of body for optimized loading-->
138 <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
139 <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
140 <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.js"></script>
141 <script>
142 $(document).ready(function() {
143 $('#ffufreport').DataTable(
144 {
145 "aLengthMenu": [
146 [250, 500, 1000, 2500, -1],
147 [250, 500, 1000, 2500, "All"]
148 ]
149 }
150 )
151 $('select').formSelect();
152 });
153 </script>
154 <style>
155 body {
156 display: flex;
157 min-height: 100vh;
158 flex-direction: column;
159 }
160
161 main {
162 flex: 1 0 auto;
163 }
164 </style>
165 </body>
166 </html>
167
168 `
169 )
170
171 // colorizeResults returns a new slice with HTMLColor attribute
172 func colorizeResultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/colorizeResults().(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#) []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# {
173 newResults := make([]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#, 0)
174
175 for _, r := range results {
176 result := r
177 result.HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#HTMLColor. = "black"
178
179 s := result.StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#StatusCode.
180
181 if s >= 200 && s <= 299 {
182 result.HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#HTMLColor. = "#adea9e"
183 }
184
185 if s >= 300 && s <= 399 {
186 result.HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#HTMLColor. = "#bbbbe6"
187 }
188
189 if s >= 400 && s <= 499 {
190 result.HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#HTMLColor. = "#d2cb7e"
191 }
192
193 if s >= 500 && s <= 599 {
194 result.HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#HTMLColor. = "#de8dc1"
195 }
196
197 newResults = append(newResults, result)
198 }
199
200 return newResults
201 }
202
203 func writeHTMLscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/writeHTML().(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#, 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#) error {
204 results = colorizeResultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/colorizeResults().(results)
205
206 ti := timescip-go gomod github.com/golang/go/src go1.18 time/.Nowscip-go gomod github.com/golang/go/src go1.18 time/Now().()
207
208 keywords := make([]string, 0)
209 for _, inputprovider := range config.InputProvidersscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#InputProviders. {
210 keywords = append(keywords, inputprovider.Keywordscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/InputProviderConfig#Keyword.)
211 }
212 htmlResults := make([]htmlResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#, 0)
213
214 for _, r := range results {
215 ffufhash := ""
216 strinput := make(map[string]string)
217 for k, v := range r.Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Input. {
218 if k == "FFUFHASH" {
219 ffufhash = string(v)
220 } else {
221 strinput[k] = string(v)
222 }
223 }
224 strscraper := ""
225 for k, v := range r.ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ScraperData. {
226 if len(v) > 0 {
227 strscraper = strscraper + "<p><b>" + htmlscip-go gomod github.com/golang/go/src go1.18 html/.EscapeStringscip-go gomod github.com/golang/go/src go1.18 html/EscapeString().(k) + ":</b><br />"
228 firstval := true
229 for _, val := range v {
230 if !firstval {
231 strscraper += "<br />"
232 }
233 strscraper += htmlscip-go gomod github.com/golang/go/src go1.18 html/.EscapeStringscip-go gomod github.com/golang/go/src go1.18 html/EscapeString().(val)
234 firstval = false
235 }
236 strscraper += "</p>"
237 }
238 }
239 hres := htmlResultscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#{
240 Inputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Input.: strinput,
241 Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Position.: r.Positionscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Position.,
242 StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#StatusCode.: r.StatusCodescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#StatusCode.,
243 ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentLength.: r.ContentLengthscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLength.,
244 ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentWords.: r.ContentWordsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentWords.,
245 ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentLines.: r.ContentLinesscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentLines.,
246 ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ContentType.: r.ContentTypescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ContentType.,
247 RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#RedirectLocation.: r.RedirectLocationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#RedirectLocation.,
248 ScraperDatascip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ScraperData.: strscraper,
249 Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Duration.: r.Durationscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Duration.,
250 ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#ResultFile.: r.ResultFilescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#ResultFile.,
251 Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Url.: r.Urlscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Url.,
252 Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#Host.: r.Hostscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#Host.,
253 HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#HTMLColor.: r.HTMLColorscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Result#HTMLColor.,
254 FfufHashscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlResult#FfufHash.: ffufhash,
255 }
256 htmlResults = append(htmlResults, hres)
257 }
258 outHTML := htmlFileOutputscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#{
259 CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#CommandLine.: config.CommandLinescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/ffuf`/Config#CommandLine.,
260 Timescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Time.: ti.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.),
261 Resultsscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Results.: htmlResults,
262 Keysscip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlFileOutput#Keys.: keywords,
263 }
264
265 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)
266 if err != nil {
267 return err
268 }
269 defer f.Closescip-go gomod github.com/golang/go/src go1.18 os/File#Close().()
270
271 templateName := "output.html"
272 t := templatescip-go gomod github.com/golang/go/src go1.18 `html/template`/.Newscip-go gomod github.com/golang/go/src go1.18 `html/template`/New().(templateName).Delimsscip-go gomod github.com/golang/go/src go1.18 `html/template`/Template#Delims().("{{", "}}")
273 _, err = t.Parsescip-go gomod github.com/golang/go/src go1.18 `html/template`/Template#Parse().(htmlTemplatescip-go gomod github.com/ffuf/ffuf/v2 . `github.com/ffuf/ffuf/v2/pkg/output`/htmlTemplate.)
274 if err != nil {
275 return err
276 }
277 err = t.Executescip-go gomod github.com/golang/go/src go1.18 `html/template`/Template#Execute().(f, outHTML)
278 return err
279 }