Skip to content

Commit 1149417

Browse files
committed
(chore) code cleanups & go-staticcheck fixes
1 parent 57dffb7 commit 1149417

File tree

5 files changed

+12
-27
lines changed

5 files changed

+12
-27
lines changed

cmd/file.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import (
1515
var fileCmd = &cobra.Command{
1616
Use: "file [input]",
1717
Short: "screenshot URLs sourced from a file or stdin",
18-
Long: `Screenshot URLs sourced from a file or stdin. URLs in the source
19-
file should be newline separated. Invalid URLs are simply logged and ignored.`,
18+
Long: `Screenshot URLs sourced from a file or stdin.
19+
20+
URLs in the source file should be newline separated. Invalid URLs are simply
21+
logged and ignored.`,
2022
Example: `$ gowitness file -f ~/Desktop/urls
2123
$ gowitness file -f urls.txt --threads 2
2224
$ cat urls.txt | gowitness file -f -
@@ -86,17 +88,6 @@ func init() {
8688
cobra.MarkFlagRequired(fileCmd.Flags(), "file")
8789
}
8890

89-
// getInput determines what the file input should be
90-
// without any file argument we will assume stdin with -
91-
func getInput(a []string) (input string) {
92-
if len(a) <= 0 {
93-
input = "-"
94-
} else {
95-
input = a[0]
96-
}
97-
return
98-
}
99-
10091
// getScanner prepares a bufio.Scanner to read from either
10192
// stdin, or a file.
10293
// the size attribute > 0 will be returned if a file was the input

cmd/nmap.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,12 @@ func getNmapURLs() (urls []string, err error) {
170170
// add the hostnames if the option has been set
171171
if options.NmapScanHostanmes {
172172
for _, hn := range host.Hostnames {
173-
for _, r := range buildURI(hn.Name, port.PortId) {
174-
urls = append(urls, r)
175-
}
173+
urls = append(urls, buildURI(hn.Name, port.PortId)...)
176174
}
177175
}
178176

179177
// process the port successfully
180-
for _, r := range buildURI(address.Addr, port.PortId) {
181-
urls = append(urls, r)
182-
}
178+
urls = append(urls, buildURI(address.Addr, port.PortId)...)
183179
}
184180
}
185181
}

cmd/report_serve.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func submitHandler(w http.ResponseWriter, r *http.Request) {
9595
if err != nil {
9696
panic(err)
9797
}
98-
break
9998
case "POST":
10099
// prepare target
101100
url, err := url.Parse(strings.TrimSpace(r.FormValue("url")))
@@ -140,12 +139,11 @@ func submitHandler(w http.ResponseWriter, r *http.Request) {
140139
}
141140

142141
if rid > 0 {
143-
http.Redirect(w, r, "/details?id="+strconv.Itoa(int(rid)), 301)
142+
http.Redirect(w, r, "/details?id="+strconv.Itoa(int(rid)), http.StatusMovedPermanently)
144143
return
145144
}
146145

147-
http.Redirect(w, r, "/submit", 301)
148-
break
146+
http.Redirect(w, r, "/submit", http.StatusMovedPermanently)
149147
}
150148
}
151149

@@ -154,7 +152,7 @@ func detailHandler(w http.ResponseWriter, r *http.Request) {
154152

155153
d := strings.TrimSpace(r.URL.Query().Get("id"))
156154
if d == "" {
157-
http.Redirect(w, r, "/", 301)
155+
http.Redirect(w, r, "/", http.StatusMovedPermanently)
158156
return
159157
}
160158
id, err := strconv.Atoi(d)

cmd/scan.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var scanCmd = &cobra.Command{
1919
Use: "scan",
2020
Short: "Scan a CIDR range and take screenshots along the way",
2121
Long: `Scans a CIDR range and takes screenshots along the way.
22+
2223
This command takes a CIDR, ports and flag arguments to specify wether
2324
it is nessesary to connect via HTTP and or HTTPS to urls. The
2425
combination of these flags are used to generate permutations that
@@ -157,9 +158,7 @@ func getScanPorts() ([]int, error) {
157158
func getScanCidrIps() (ips []string, err error) {
158159

159160
var cidrs []string
160-
for _, cidr := range options.ScanCidr {
161-
cidrs = append(cidrs, cidr)
162-
}
161+
cidrs = append(cidrs, options.ScanCidr...)
163162

164163
if options.ScanCidrFile != "" {
165164
file, err := os.Open(options.ScanCidrFile)

cmd/single.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var singleCmd = &cobra.Command{
1313
Short: "Take a screenshot of a single URL",
1414
Args: cobra.ExactArgs(1),
1515
Long: `Takes a screenshot of a single given URL and saves it to a file.
16+
1617
If no --output is provided, a filename for the screenshot will
1718
be automatically generated based on the given URL. If an absolute
1819
output file path is given, the --destination parameter will be

0 commit comments

Comments
 (0)