Skip to content

Commit d48668e

Browse files
authored
Merge pull request #170 from cosmincojocar/build_more_checks
Update the build file with more checks
2 parents 777b706 + 7355f0a commit d48668e

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

.travis.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
language: go
2-
before_script:
3-
- go vet $(go list ./... | grep -v /vendor/)
2+
43
go:
54
- 1.7
65
- 1.8
76
- 1.9
87
- tip
8+
99
install:
10+
- go get -u github.com/golang/lint/golint
1011
- go get -v github.com/onsi/ginkgo/ginkgo
1112
- go get -v github.com/onsi/gomega
1213
- go get -v golang.org/x/crypto/ssh
14+
- go get github.com/GoASTScanner/gas/cmd/gas/...
1315
- go get -v -t ./...
1416
- export PATH=$PATH:$HOME/gopath/bin
1517

18+
before_script:
19+
- test -z "$(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr)"
20+
- test -z "$(golint . | tee /dev/stderr)"
21+
- go vet $(go list ./... | grep -v /vendor/)
22+
- gas ./...
23+
1624
script: ginkgo -r
1725

analyzer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ func (gas *Analyzer) Process(packagePaths ...string) error {
102102
AllowErrors: true,
103103
}
104104
for _, packagePath := range packagePaths {
105-
abspath, _ := filepath.Abs(packagePath)
105+
abspath, err := filepath.Abs(packagePath)
106+
if err != nil {
107+
return err
108+
}
106109
gas.logger.Println("Searching directory:", abspath)
107110

108111
basePackage, err := build.Default.ImportDir(packagePath, build.ImportComment)

import_tracker_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var _ = Describe("ImportTracker", func() {
1515
})
1616
Context("when I have a valid go package", func() {
1717
It("should record all import specs", func() {
18-
Expect(source).To(Equal(source))
18+
Expect(source).To(Equal(source))
1919
Skip("Not implemented")
2020
})
2121

issue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func codeSnippet(file *os.File, start int64, end int64, n ast.Node) (string, err
7676
}
7777

7878
size := (int)(end - start) // Go bug, os.File.Read should return int64 ...
79-
file.Seek(start, 0)
79+
file.Seek(start, 0) // #nosec
8080

8181
buf := make([]byte, size)
8282
if nread, err := file.Read(buf); err != nil || nread != size {

rules/rulelist.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,35 +60,35 @@ func NewRuleFilter(action bool, ruleIDs ...string) RuleFilter {
6060
func Generate(filters ...RuleFilter) RuleList {
6161
rules := map[string]RuleDefinition{
6262
// misc
63-
"G101": RuleDefinition{"Look for hardcoded credentials", NewHardcodedCredentials},
64-
"G102": RuleDefinition{"Bind to all interfaces", NewBindsToAllNetworkInterfaces},
65-
"G103": RuleDefinition{"Audit the use of unsafe block", NewUsingUnsafe},
66-
"G104": RuleDefinition{"Audit errors not checked", NewNoErrorCheck},
67-
"G105": RuleDefinition{"Audit the use of big.Exp function", NewUsingBigExp},
68-
"G106": RuleDefinition{"Audit the use of ssh.InsecureIgnoreHostKey function", NewSSHHostKey},
63+
"G101": {"Look for hardcoded credentials", NewHardcodedCredentials},
64+
"G102": {"Bind to all interfaces", NewBindsToAllNetworkInterfaces},
65+
"G103": {"Audit the use of unsafe block", NewUsingUnsafe},
66+
"G104": {"Audit errors not checked", NewNoErrorCheck},
67+
"G105": {"Audit the use of big.Exp function", NewUsingBigExp},
68+
"G106": {"Audit the use of ssh.InsecureIgnoreHostKey function", NewSSHHostKey},
6969

7070
// injection
71-
"G201": RuleDefinition{"SQL query construction using format string", NewSQLStrFormat},
72-
"G202": RuleDefinition{"SQL query construction using string concatenation", NewSQLStrConcat},
73-
"G203": RuleDefinition{"Use of unescaped data in HTML templates", NewTemplateCheck},
74-
"G204": RuleDefinition{"Audit use of command execution", NewSubproc},
71+
"G201": {"SQL query construction using format string", NewSQLStrFormat},
72+
"G202": {"SQL query construction using string concatenation", NewSQLStrConcat},
73+
"G203": {"Use of unescaped data in HTML templates", NewTemplateCheck},
74+
"G204": {"Audit use of command execution", NewSubproc},
7575

7676
// filesystem
77-
"G301": RuleDefinition{"Poor file permissions used when creating a directory", NewMkdirPerms},
78-
"G302": RuleDefinition{"Poor file permisions used when creation file or using chmod", NewFilePerms},
79-
"G303": RuleDefinition{"Creating tempfile using a predictable path", NewBadTempFile},
77+
"G301": {"Poor file permissions used when creating a directory", NewMkdirPerms},
78+
"G302": {"Poor file permisions used when creation file or using chmod", NewFilePerms},
79+
"G303": {"Creating tempfile using a predictable path", NewBadTempFile},
8080

8181
// crypto
82-
"G401": RuleDefinition{"Detect the usage of DES, RC4, or MD5", NewUsesWeakCryptography},
83-
"G402": RuleDefinition{"Look for bad TLS connection settings", NewIntermediateTLSCheck},
84-
"G403": RuleDefinition{"Ensure minimum RSA key length of 2048 bits", NewWeakKeyStrength},
85-
"G404": RuleDefinition{"Insecure random number source (rand)", NewWeakRandCheck},
82+
"G401": {"Detect the usage of DES, RC4, or MD5", NewUsesWeakCryptography},
83+
"G402": {"Look for bad TLS connection settings", NewIntermediateTLSCheck},
84+
"G403": {"Ensure minimum RSA key length of 2048 bits", NewWeakKeyStrength},
85+
"G404": {"Insecure random number source (rand)", NewWeakRandCheck},
8686

8787
// blacklist
88-
"G501": RuleDefinition{"Import blacklist: crypto/md5", NewBlacklistedImportMD5},
89-
"G502": RuleDefinition{"Import blacklist: crypto/des", NewBlacklistedImportDES},
90-
"G503": RuleDefinition{"Import blacklist: crypto/rc4", NewBlacklistedImportRC4},
91-
"G504": RuleDefinition{"Import blacklist: net/http/cgi", NewBlacklistedImportCGI},
88+
"G501": {"Import blacklist: crypto/md5", NewBlacklistedImportMD5},
89+
"G502": {"Import blacklist: crypto/des", NewBlacklistedImportDES},
90+
"G503": {"Import blacklist: crypto/rc4", NewBlacklistedImportRC4},
91+
"G504": {"Import blacklist: net/http/cgi", NewBlacklistedImportCGI},
9292
}
9393

9494
for rule := range rules {

0 commit comments

Comments
 (0)