Skip to content

Commit ea494e4

Browse files
committed
fix golint and gosimple issues
1 parent eabaf26 commit ea494e4

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

cmd/webseclab/main.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type indexHandler func(http.ResponseWriter, *http.Request) error
2121

2222
func (fn indexHandler) ServerHTTP(w http.ResponseWriter, r *http.Request) {
2323
fn(w, r)
24-
return
2524
}
2625

2726
const notice = `Attention: Webseclab is purposedly INSECURE software intended for testing and education. Use it at your own risk and be careful! Hit Ctrl-C now if you don't understand the risks invovled.
@@ -63,7 +62,6 @@ func main() {
6362
http.HandleFunc("/index.html", webseclab.MakeIndexFunc("/index.html"))
6463
}
6564
http.HandleFunc("favicon.ico", func(w http.ResponseWriter, r *http.Request) {
66-
return
6765
})
6866
http.Handle("/", webseclab.MakeMainHandler(*noindex))
6967
http.HandleFunc("/exit", webseclab.MakeExitFunc(ln))

common_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ func (r mockResponseWriter) Write([]byte) (int, error) {
2626
}
2727

2828
func (r mockResponseWriter) WriteHeader(int) {
29-
return
3029
}

custom.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ func XSSFullCookies(w http.ResponseWriter, r *http.Request) *LabResp {
125125
return DoLabTestStandard(w, r)
126126
}
127127
}
128-
return &LabResp{Err: errors.New("Sorry your cookies are no good - please put the word awesome into a cookie value and try again."),
128+
return &LabResp{Err: errors.New("sorry your cookies are no good - please put the word awesome into a cookie value and try again"),
129129
Code: http.StatusForbidden}
130130
}
131131

132132
// XSSFullHeaders is a wrapper around standard handler (non-filtered output echo)
133133
// but requires the presence of HTTP Header X-Letmein with the value 1.
134134
func XSSFullHeaders(w http.ResponseWriter, r *http.Request) *LabResp {
135135
if r.Header.Get("X-Letmein") != "1" {
136-
return &LabResp{Err: errors.New("Missing or invalid value of the X-Letmein HTTP Header - please set to 1 and try again."),
136+
return &LabResp{Err: errors.New("missing or invalid value of the X-Letmein HTTP Header - please set to 1 and try again"),
137137
Code: http.StatusForbidden}
138138
}
139139
return DoLabTestStandard(w, r)
@@ -144,7 +144,7 @@ func XSSFullHeaders(w http.ResponseWriter, r *http.Request) *LabResp {
144144
func XSSFullUseragent(w http.ResponseWriter, r *http.Request) *LabResp {
145145
ua := r.Header.Get("User-Agent")
146146
if !strings.Contains(ua, "Mobile") {
147-
return &LabResp{Err: errors.New("Access requires forward-looking thinking - please add Mobile to the User-Agent header and try again."),
147+
return &LabResp{Err: errors.New("access requires forward-looking thinking - please add Mobile to the User-Agent header and try again"),
148148
Code: http.StatusForbidden}
149149
}
150150
return DoLabTestStandard(w, r)

handler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ func MakeIndexFunc(page string) func(http.ResponseWriter, *http.Request) {
151151
w.Write([]byte(`Internal Server Error`))
152152
return
153153
}
154-
return
155154
}
156155
}
157156

input.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99
"strings"
1010
)
1111

12-
// ParseRawQuery copied from net/url parseQuery but without unescaping keys/values
12+
// ParseRawQuery is copied from net/url parseQuery
13+
// but without unescaping keys/values.
1314
func ParseRawQuery(m map[string][]string, query string) {
1415
for query != "" {
1516
key := query
@@ -27,7 +28,6 @@ func ParseRawQuery(m map[string][]string, query string) {
2728
}
2829
m[key] = append(m[key], value)
2930
}
30-
return
3131
}
3232

3333
// Input extracts the escaped and "raw" values of in parameters

transform.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ import (
1616
// The second part are the functions that do transformations
1717
// beyond simple string substitution (regexp etc.)
1818

19-
// Transformer transforms a string by escaping, filtering or other modification
19+
// Transformer transforms a string by escaping, filtering or other modification.
2020
type Transformer interface {
2121
Transform(s string) string
2222
}
2323

24-
// StringsReplacer implements Transformer using embedded strings.Replacer
24+
// StringsReplacer implements Transformer using embedded strings.Replacer.
2525
type StringsReplacer struct {
2626
strings.Replacer
2727
}
2828

2929
// NewStringsReplacer creates a new StringsReplacer
30-
// using the list of old/new strings (as in strings.NewReplacer)
30+
// using the list of old/new strings (as in strings.NewReplacer).
3131
func NewStringsReplacer(oldnew ...string) *StringsReplacer {
3232
r := strings.NewReplacer(oldnew...)
3333
return &StringsReplacer{*r}
@@ -212,7 +212,7 @@ func RemoveTagsExceptTextareaClose(src string) (out string) {
212212
// fmt.Printf("%d %s\n", i, src[m[i][0]:m[i][1]])
213213
}
214214
if last < len(src) {
215-
out += src[last:len(src)]
215+
out += src[last:]
216216
}
217217
// leave for debugging
218218
// fmt.Printf("RemoveTagsUntilTextareaClose Out: %s\n", out)
@@ -238,7 +238,7 @@ func RemoveTagsUntilTextareaClose(src string) (out string) {
238238
// fmt.Printf("%d %s\n", i, src[m[i][0]:m[i][1]])
239239
}
240240
if last < len(src) {
241-
out += src[last:len(src)]
241+
out += src[last:]
242242
}
243243
// leave for debugging
244244
// fmt.Printf("RemoveTagsUntilTextareaClose Out: %s\n", out)
@@ -268,7 +268,7 @@ func ReplaceTextareaSafe(src string) (out string) {
268268
// fmt.Printf("%d %s\n", i, src[m[i][0]:m[i][1]])
269269
}
270270
if last < len(src) {
271-
out += src[last:len(src)]
271+
out += src[last:]
272272
}
273273
// leave for debugging
274274
// fmt.Printf("TextareaSafe Out: %s\n", out)

0 commit comments

Comments
 (0)