Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Commit db12d16

Browse files
authored
Merge pull request #18 from MVrachev/add-more-to-g107
Add one more example to g107
2 parents c85b17a + 6b3053d commit db12d16

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/rules/g107_url_arg_to_http_request_as_taint_input.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,44 @@ func main() {
3333
}
3434
```
3535

36+
```
37+
package main
38+
39+
import (
40+
"fmt"
41+
"io/ioutil"
42+
"net/http"
43+
)
44+
45+
var url string = "https://www.google.com"
46+
47+
func main() {
48+
49+
resp, err := http.Get(url)
50+
if err != nil {
51+
panic(err)
52+
}
53+
defer resp.Body.Close()
54+
body, err := ioutil.ReadAll(resp.Body)
55+
if err != nil {
56+
panic(err)
57+
}
58+
fmt.Printf("%s", body)
59+
}
60+
```
61+
3662
## Gosec command line output
3763

3864
```
3965
[examples/main.go:12] - G107: Potential HTTP request made with variable url (Confidence: MEDIUM, Severity: MEDIUM)
4066
> http.Get(url)
4167
```
4268

69+
```
70+
[/Users/mvrachev/Martins/go/src/github.com/securego/examples/main.go:17] - G107: Potential HTTP request made with variable url (Confidence: MEDIUM, Severity: MEDIUM)
71+
> http.Get(url)
72+
```
73+
4374
## The right way
4475

4576
```

0 commit comments

Comments
 (0)