You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $GOPATH/bin vX.Y.Z
22
27
23
-
### Install
28
+
# or install it into ./bin/
29
+
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s vX.Y.Z
30
+
31
+
# In alpine linux (as it does not come with curl by default)
32
+
wget -O - -q https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s vX.Y.Z
33
+
34
+
gosec --help
35
+
```
36
+
37
+
### Local Installation
24
38
25
39
`$ go get github.com/securego/gosec/cmd/gosec/...`
26
40
27
-
###Usage
41
+
## Usage
28
42
29
43
Gosec can be configured to only run a subset of rules, to exclude certain file
30
44
paths, and produce reports in different formats. By default all rules will be
31
45
run against the supplied input files. To recursively scan from the current
32
46
directory you can supply './...' as the input argument.
33
47
34
-
####Selecting rules
48
+
### Selecting rules
35
49
36
50
By default gosec will run all rules against the supplied file paths. It is however possible to select a subset of rules to run via the '-include=' flag,
37
51
or to specify a set of rules to explicitly exclude using the '-exclude=' flag.
38
52
39
-
##### Available rules
40
-
41
-
- G101: Look for hardcoded credentials
42
-
- G102: Bind to all interfaces
43
-
- G103: Audit the use of unsafe block
44
-
- G104: Audit errors not checked
45
-
- G105: Audit the use of math/big.Int.Exp
46
-
- G106: Audit the use of ssh.InsecureIgnoreHostKey
47
-
- G107: Url provided to HTTP request as taint input
48
-
- G201: SQL query construction using format string
49
-
- G202: SQL query construction using string concatenation
50
-
- G203: Use of unescaped data in HTML templates
51
-
- G204: Audit use of command execution
52
-
- G301: Poor file permissions used when creating a directory
53
-
- G302: Poor file permissions used with chmod
54
-
- G303: Creating tempfile using a predictable path
55
-
- G304: File path provided as taint input
56
-
- G305: File traversal when extracting zip archive
57
-
- G401: Detect the usage of DES, RC4, MD5 or SHA1
58
-
- G402: Look for bad TLS connection settings
59
-
- G403: Ensure minimum RSA key length of 2048 bits
60
-
- G404: Insecure random number source (rand)
61
-
- G501: Import blacklist: crypto/md5
62
-
- G502: Import blacklist: crypto/des
63
-
- G503: Import blacklist: crypto/rc4
64
-
- G504: Import blacklist: net/http/cgi
65
-
- G505: Import blacklist: crypto/sha1
66
-
67
-
68
-
```
53
+
### Available rules
54
+
55
+
- G101: Look for hard coded credentials
56
+
- G102: Bind to all interfaces
57
+
- G103: Audit the use of unsafe block
58
+
- G104: Audit errors not checked
59
+
- G105: Audit the use of math/big.Int.Exp
60
+
- G106: Audit the use of ssh.InsecureIgnoreHostKey
61
+
- G107: Url provided to HTTP request as taint input
62
+
- G201: SQL query construction using format string
63
+
- G202: SQL query construction using string concatenation
64
+
- G203: Use of unescaped data in HTML templates
65
+
- G204: Audit use of command execution
66
+
- G301: Poor file permissions used when creating a directory
67
+
- G302: Poor file permissions used with chmod
68
+
- G303: Creating tempfile using a predictable path
69
+
- G304: File path provided as taint input
70
+
- G305: File traversal when extracting zip archive
71
+
- G401: Detect the usage of DES, RC4, MD5 or SHA1
72
+
- G402: Look for bad TLS connection settings
73
+
- G403: Ensure minimum RSA key length of 2048 bits
74
+
- G404: Insecure random number source (rand)
75
+
- G501: Import blacklist: crypto/md5
76
+
- G502: Import blacklist: crypto/des
77
+
- G503: Import blacklist: crypto/rc4
78
+
- G504: Import blacklist: net/http/cgi
79
+
- G505: Import blacklist: crypto/sha1
80
+
81
+
```bash
69
82
# Run a specific set of rules
70
83
$ gosec -include=G101,G203,G401 ./...
71
84
72
85
# Run everything except for rule G303
73
86
$ gosec -exclude=G303 ./...
74
87
```
75
88
76
-
####Excluding files:
89
+
### Excluding files
77
90
78
91
gosec will ignore dependencies in your vendor directory any files
79
92
that are not considered build artifacts by the compiler (so test files).
80
93
81
-
####Annotating code
94
+
### Annotating code
82
95
83
96
As with all automated detection tools there will be cases of false positives. In cases where gosec reports a failure that has been manually verified as being safe it is possible to annotate the code with a '#nosec' comment.
84
97
@@ -107,16 +120,17 @@ In some cases you may also want to revisit places where #nosec annotations
107
120
have been used. To run the scanner and ignore any #nosec annotations you
108
121
can do the following:
109
122
123
+
```bash
124
+
gosec -nosec=true ./...
110
125
```
111
-
$ gosec -nosec=true ./...
112
-
```
113
-
#### Build tags
126
+
127
+
### Build tags
114
128
115
129
gosec is able to pass your [Go build tags](https://golang.org/pkg/go/build/) to the analyzer.
116
130
They can be provided as a comma separated list as follows:
117
131
118
-
```
119
-
$ gosec -tag debug,ignore ./...
132
+
```bash
133
+
gosec -tag debug,ignore ./...
120
134
```
121
135
122
136
### Output formats
@@ -125,42 +139,43 @@ gosec currently supports text, json, yaml, csv and JUnit XML output formats. By
125
139
results will be reported to stdout, but can also be written to an output
126
140
file. The output format is controlled by the '-fmt' flag, and the output file is controlled by the '-out' flag as follows:
127
141
128
-
```
142
+
```bash
129
143
# Write output in json format to results.json
130
144
$ gosec -fmt=json -out=results.json *.go
131
145
```
132
-
### Development
133
146
134
-
#### Prerequisites
147
+
## Development
148
+
149
+
### Prerequisites
135
150
136
151
Install dep according to the instructions here: https://github.com/golang/dep
137
152
Install the latest version of golint: https://github.com/golang/lint
138
153
139
-
####Build
154
+
### Build
140
155
141
-
```
156
+
```bash
142
157
make
143
158
```
144
159
145
-
####Tests
160
+
### Tests
146
161
147
-
```
162
+
```bash
148
163
make test
149
164
```
150
165
151
-
####Release Build
166
+
### Release Build
152
167
153
168
Make sure you have installed the [goreleaser](https://github.com/goreleaser/goreleaser) tool and then you can release gosec as follows:
154
169
155
-
```
170
+
```bash
156
171
git tag 1.0.0
157
172
export GITHUB_TOKEN=<YOUR GITHUB TOKEN>
158
173
make release
159
174
```
160
175
161
176
The released version of the tool is available in the `dist` folder. The build information should be displayed in the usage text.
The configuration of TLS rule can be generated from [Mozilla's TLS ciphers recommendation](https://statics.tls.security.mozilla.org/server-side-tls-conf.json).
195
210
196
-
197
211
First you need to install the generator tool:
198
212
199
-
```
213
+
```bash
200
214
go get github.com/securego/gosec/cmd/tlsconfig/...
201
215
```
202
216
203
217
You can invoke now the `go generate` in the root of the project:
0 commit comments