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

Commit 6b3053d

Browse files
author
Martin Vrachev
committed
Add one more example to g107
It will be useful if there is one more example in the docs for rule G107. An example which demonstrates a more likely mistake. Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
1 parent c85b17a commit 6b3053d

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

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)