Skip to content

Commit 8962307

Browse files
committed
Add second good go file to tests
1 parent 0000c72 commit 8962307

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

go/ql/src/Security/CWE-020/IncompleteHostnameRegexpGood2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"regexp"
77
)
88

9-
func checkRedirectGood(req *http.Request, via []*http.Request) error {
9+
func checkRedirectGood2(req *http.Request, via []*http.Request) error {
1010
// GOOD: the host of `req.URL` must be `example.com`, `www.example.com` or `beta.example.com`
1111
re := `^((www|beta)\.)?example\.com/`
1212
if matched, _ := regexp.MatchString(re, req.URL.Host); matched {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package main
2+
3+
import (
4+
"errors"
5+
"net/http"
6+
"regexp"
7+
)
8+
9+
func checkRedirectGood2(req *http.Request, via []*http.Request) error {
10+
// GOOD: the host of `req.URL` must be `example.com`, `www.example.com` or `beta.example.com`
11+
re := `^((www|beta)\.)?example\.com/`
12+
if matched, _ := regexp.MatchString(re, req.URL.Host); matched {
13+
return nil
14+
}
15+
return errors.New("Invalid redirect")
16+
}

0 commit comments

Comments
 (0)