-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
175 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
main | ||
.idea | ||
.idea | ||
/*.html | ||
linx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package output | ||
|
||
type OutputData struct { | ||
Target string | ||
Filename string | ||
Results []Result | ||
} | ||
|
||
type Result struct { | ||
URL string | ||
Location string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package output | ||
|
||
import ( | ||
"html/template" | ||
"os" | ||
) | ||
|
||
const templateFile = "./internal/output/output_html_template.html" | ||
|
||
type OutputHTML struct { | ||
output OutputData | ||
} | ||
|
||
func NewOutputHTML(output OutputData) OutputHTML { | ||
return OutputHTML{output: output} | ||
} | ||
|
||
func (oh OutputHTML) RenderAndSave() error { | ||
f, err := os.Create(oh.output.Filename) | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
|
||
t, err := template.ParseFiles(templateFile) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = t.Execute(f, oh.output) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>{{ .Target }} - linx report</title> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
|
||
<div class="col-lg-8 mx-auto p-3 py-md-5"> | ||
<header class="d-flex align-items-center pb-3 mb-5 border-bottom"> | ||
<a href="/" class="d-flex align-items-center text-dark text-decoration-none"> | ||
<span class="fs-4">{{ .Target }}</span> | ||
</a> | ||
</header> | ||
|
||
<main> | ||
<div class="row g-12"> | ||
<div class="col-md-12"> | ||
<table style="table-layout: fixed" class="table table-striped table-hover"> | ||
<thead> | ||
<tr> | ||
<th scope="col">URL</th> | ||
<th scope="col">Location in file</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{range .Results}} | ||
<tr> | ||
<td>{{ .URL }}</td> | ||
<td> | ||
<pre><code>{{ .Location }}</code></pre> | ||
</td> | ||
</tr> | ||
{{end}} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</main> | ||
<footer class="pt-5 my-5 text-muted border-top"> | ||
created with <a href="https://github.com/riza/linx">linx</a> | ||
</footer> | ||
</div> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" | ||
crossorigin="anonymous"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package scanner | ||
|
||
var ( | ||
errGetFileContent = "error getting content err: %w" | ||
errGetFileContent = "error getting content err: %w" | ||
errOutputFailed = "output fail render and save err: %w" | ||
errOutputOpenFailed = "output fail opening err: %w" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ package strategies | |
|
||
type ScanStrategy interface { | ||
GetContent() ([]byte, error) | ||
GetFileName() string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters