Skip to content

Commit e0a150b

Browse files
author
Cosmin Cojocar
authored
Merge pull request #254 from kishaningithub/253
Add install.sh script and update readme
2 parents d032909 + 97bc137 commit e0a150b

File tree

3 files changed

+465
-62
lines changed

3 files changed

+465
-62
lines changed

.goreleaser.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
---
2+
project_name: gosec
3+
4+
release:
5+
github:
6+
owner: securego
7+
name: gosec
8+
19
builds:
210
- main : ./cmd/gosec/
311
binary: gosec

README.md

Lines changed: 76 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,97 @@
11

2-
3-
## gosec -Golang Security Checker
2+
# gosec - Golang Security Checker
43

54
Inspects source code for security problems by scanning the Go AST.
65

76
<img src="https://securego.io/img/gosec.png" width="320">
87

9-
10-
### License
8+
## License
119

1210
Licensed under the Apache License, Version 2.0 (the "License");
1311
you may not use this file except in compliance with the License.
1412
You may obtain a copy of the License [here](http://www.apache.org/licenses/LICENSE-2.0).
1513

16-
### Project status
14+
## Project status
1715

1816
[![Build Status](https://travis-ci.org/securego/gosec.svg?branch=master)](https://travis-ci.org/securego/gosec)
1917
[![GoDoc](https://godoc.org/github.com/securego/gosec?status.svg)](https://godoc.org/github.com/securego/gosec)
2018
[![Slack](http://securego.herokuapp.com/badge.svg)](http://securego.herokuapp.com)
2119

20+
## Install
21+
22+
### CI Installation
23+
24+
```bash
25+
# binary will be $GOPATH/bin/gosec
26+
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $GOPATH/bin vX.Y.Z
2227

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
2438

2539
`$ go get github.com/securego/gosec/cmd/gosec/...`
2640

27-
### Usage
41+
## Usage
2842

2943
Gosec can be configured to only run a subset of rules, to exclude certain file
3044
paths, and produce reports in different formats. By default all rules will be
3145
run against the supplied input files. To recursively scan from the current
3246
directory you can supply './...' as the input argument.
3347

34-
#### Selecting rules
48+
### Selecting rules
3549

3650
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,
3751
or to specify a set of rules to explicitly exclude using the '-exclude=' flag.
3852

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
6982
# Run a specific set of rules
7083
$ gosec -include=G101,G203,G401 ./...
7184

7285
# Run everything except for rule G303
7386
$ gosec -exclude=G303 ./...
7487
```
7588

76-
#### Excluding files:
89+
### Excluding files
7790

7891
gosec will ignore dependencies in your vendor directory any files
7992
that are not considered build artifacts by the compiler (so test files).
8093

81-
#### Annotating code
94+
### Annotating code
8295

8396
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.
8497

@@ -107,16 +120,17 @@ In some cases you may also want to revisit places where #nosec annotations
107120
have been used. To run the scanner and ignore any #nosec annotations you
108121
can do the following:
109122

123+
```bash
124+
gosec -nosec=true ./...
110125
```
111-
$ gosec -nosec=true ./...
112-
```
113-
#### Build tags
126+
127+
### Build tags
114128

115129
gosec is able to pass your [Go build tags](https://golang.org/pkg/go/build/) to the analyzer.
116130
They can be provided as a comma separated list as follows:
117131

118-
```
119-
$ gosec -tag debug,ignore ./...
132+
```bash
133+
gosec -tag debug,ignore ./...
120134
```
121135

122136
### Output formats
@@ -125,42 +139,43 @@ gosec currently supports text, json, yaml, csv and JUnit XML output formats. By
125139
results will be reported to stdout, but can also be written to an output
126140
file. The output format is controlled by the '-fmt' flag, and the output file is controlled by the '-out' flag as follows:
127141

128-
```
142+
```bash
129143
# Write output in json format to results.json
130144
$ gosec -fmt=json -out=results.json *.go
131145
```
132-
### Development
133146

134-
#### Prerequisites
147+
## Development
148+
149+
### Prerequisites
135150

136151
Install dep according to the instructions here: https://github.com/golang/dep
137152
Install the latest version of golint: https://github.com/golang/lint
138153

139-
#### Build
154+
### Build
140155

141-
```
156+
```bash
142157
make
143158
```
144159

145-
#### Tests
160+
### Tests
146161

147-
```
162+
```bash
148163
make test
149164
```
150165

151-
#### Release Build
166+
### Release Build
152167

153168
Make sure you have installed the [goreleaser](https://github.com/goreleaser/goreleaser) tool and then you can release gosec as follows:
154169

155-
```
170+
```bash
156171
git tag 1.0.0
157172
export GITHUB_TOKEN=<YOUR GITHUB TOKEN>
158173
make release
159174
```
160175

161176
The released version of the tool is available in the `dist` folder. The build information should be displayed in the usage text.
162177

163-
```
178+
```bash
164179
./dist/darwin_amd64/gosec -h
165180
gosec - Golang security checker
166181

@@ -174,35 +189,34 @@ BUILD DATE: 2018-04-27T12:41:38Z
174189

175190
Note that all released archives are also uploaded to GitHub.
176191

177-
#### Docker image
192+
### Docker image
178193

179194
You can build the docker image as follows:
180195

181-
```
196+
```bash
182197
make image
183198
```
184199

185200
You can run the `gosec` tool in a container against your local Go project. You just have to mount the project in the
186201
`GOPATH` of the container:
187202

188-
```
203+
```bash
189204
docker run -it -v $GOPATH/src/<YOUR PROJECT PATH>:/go/src/<YOUR PROJECT PATH> securego/gosec ./...
190205
```
191206

192-
#### Generate TLS rule
207+
### Generate TLS rule
193208

194209
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).
195210

196-
197211
First you need to install the generator tool:
198212

199-
```
213+
```bash
200214
go get github.com/securego/gosec/cmd/tlsconfig/...
201215
```
202216

203217
You can invoke now the `go generate` in the root of the project:
204218

205-
```
219+
```bash
206220
go generate ./...
207221
```
208222

0 commit comments

Comments
 (0)