Skip to content

Commit

Permalink
Merge branch 'master' into commandcontext
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Jul 26, 2018
2 parents d7ec2fc + 2785f7a commit 6a156e2
Show file tree
Hide file tree
Showing 54 changed files with 632 additions and 451 deletions.
2 changes: 1 addition & 1 deletion .github/issue_template.md
Expand Up @@ -2,7 +2,7 @@

### Steps to reproduce the behavior

### Gas version
### gosec version

### Go version (output of 'go version')

Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
@@ -1,7 +1,6 @@
language: go

go:
- 1.8
- 1.9
- "1.10"
- tip
Expand All @@ -12,7 +11,7 @@ install:
- go get -u github.com/onsi/ginkgo/ginkgo
- go get -u github.com/onsi/gomega
- go get -u golang.org/x/crypto/ssh
- go get -u github.com/GoASTScanner/gas/cmd/gas/...
- go get -u github.com/securego/gosec/cmd/gosec/...
- go get -v -t ./...
- export PATH=$PATH:$HOME/gopath/bin

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,6 +1,6 @@
FROM golang:1.9.4-alpine3.7

ENV BIN=gas
ENV BIN=gosec

COPY build/*-linux-amd64 /go/bin/$BIN
COPY docker-entrypoint.sh /usr/local/bin
Expand Down
8 changes: 4 additions & 4 deletions Makefile
@@ -1,7 +1,7 @@
GIT_TAG?= $(shell git describe --always --tags)
BUILD_DATE = $(shell date +%Y-%m-%d)
BIN = gas
BUILD_CMD = go build -ldflags "-X main.Version=${VERSION} -X main.GitTag=${GIT_TAG} -X main.BuildDate=${BUILD_DATE}" -o build/$(BIN)-$(VERSION)-$${GOOS}-$${GOARCH} ./cmd/gas/ &
BIN = gosec
BUILD_CMD = go build -ldflags "-X main.Version=${VERSION} -X main.GitTag=${GIT_TAG} -X main.BuildDate=${BUILD_DATE}" -o build/$(BIN)-$(VERSION)-$${GOOS}-$${GOARCH} ./cmd/gosec/ &
FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr)
IMAGE_REPO = docker.io

Expand All @@ -13,12 +13,12 @@ test: bootstrap
test -z '$(FMT_CMD)'
go vet $(go list ./... | grep -v /vendor/)
golint -set_exit_status $(shell go list ./... | grep -v vendor)
gas ./...
gosec ./...
ginkgo -r -v
bootstrap:
dep ensure
build:
go build -o $(BIN) ./cmd/gas/
go build -o $(BIN) ./cmd/gosec/
clean:
rm -rf build vendor
rm -f release image bootstrap $(BIN)
Expand Down
50 changes: 25 additions & 25 deletions README.md
@@ -1,6 +1,6 @@


## GAS - Go AST Scanner
## gosec -Golang Security Checker

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

Expand All @@ -12,26 +12,25 @@ You may obtain a copy of the License [here](http://www.apache.org/licenses/LICEN

### Project status

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

Gas is still in alpha and accepting feedback from early adopters. We do
not consider it production ready at this time.

### Install

`$ go get github.com/GoASTScanner/gas/cmd/gas/...`
`$ go get github.com/securego/gosec/cmd/gosec/...`

### Usage

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

#### Selecting rules

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

##### Available rules
Expand All @@ -50,6 +49,7 @@ or to specify a set of rules to explicitly exclude using the '-exclude=' flag.
- G302: Poor file permisions used with chmod
- G303: Creating tempfile using a predictable path
- G304: File path provided as taint input
- G305: File traversal when extracting zip archive
- G401: Detect the usage of DES, RC4, or MD5
- G402: Look for bad TLS connection settings
- G403: Ensure minimum RSA key length of 2048 bits
Expand All @@ -62,22 +62,22 @@ or to specify a set of rules to explicitly exclude using the '-exclude=' flag.

```
# Run a specific set of rules
$ gas -include=G101,G203,G401 ./...
$ gosec -include=G101,G203,G401 ./...
# Run everything except for rule G303
$ gas -exclude=G303 ./...
$ gosec -exclude=G303 ./...
```

#### Excluding files:

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

#### Annotating code

As with all automated detection tools there will be cases of false positives. In cases where Gas reports a failure that has been manually verified as being safe it is possible to annotate the code with a '#nosec' comment.
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.

The annotation causes Gas to stop processing any further nodes within the
The annotation causes gosec to stop processing any further nodes within the
AST so can apply to a whole block or more granularly to a single expression.

```go
Expand All @@ -101,26 +101,26 @@ have been used. To run the scanner and ignore any #nosec annotations you
can do the following:

```
$ gas -nosec=true ./...
$ gosec -nosec=true ./...
```
#### Build tags

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

```
$ gas -tag debug,ignore ./...
$ gosec -tag debug,ignore ./...
```

### Output formats

Gas currently supports text, json, yaml, csv and JUnit XML output formats. By default
gosec currently supports text, json, yaml, csv and JUnit XML output formats. By default
results will be reported to stdout, but can also be written to an output
file. The output format is controlled by the '-fmt' flag, and the output file is controlled by the '-out' flag as follows:

```
# Write output in json format to results.json
$ gas -fmt=json -out=results.json *.go
$ gosec -fmt=json -out=results.json *.go
```
### Development

Expand All @@ -143,7 +143,7 @@ make test

#### Release Build

Gas can be released as follows:
gosec can be released as follows:

```bash
make release VERSION=2.0.0
Expand All @@ -152,11 +152,11 @@ make release VERSION=2.0.0
The released version of the tool is available in the `build` folder. The build information should be displayed in the usage text.

```
./build/gas-2.0.0-linux-amd64 -h
./build/gosec-2.0.0-linux-amd64 -h
GAS - Go AST Scanner
gosec - Golang security checker
Gas analyzes Go source code to look for common programming mistakes that
gosec analyzes Go source code to look for common programming mistakes that
can lead to security problems.
VERSION: 2.0.0
Expand All @@ -173,10 +173,10 @@ You can execute a release and build the docker image as follows:
make image VERSION=2.0.0
```

Now you can run the gas tool in a container against your local workspace:
Now you can run the gosec tool in a container against your local workspace:

```
docker run -it -v <YOUR LOCAL WORKSPACE>:/workspace gas /workspace
docker run -it -v <YOUR LOCAL WORKSPACE>:/workspace gosec /workspace
```

#### Generate TLS rule
Expand All @@ -187,7 +187,7 @@ The configuration of TLS rule can be generated from [Mozilla's TLS ciphers recom
First you need to install the generator tool:

```
go get github.com/GoASTScanner/gas/cmd/tlsconfig/...
go get github.com/securego/gosec/cmd/tlsconfig/...
```

You can invoke now the `go generate` in the root of the project:
Expand Down

0 comments on commit 6a156e2

Please sign in to comment.