From cacf21f3c0f90fb16fb73b15477104d4bff0a4d2 Mon Sep 17 00:00:00 2001 From: Grant Murphy Date: Wed, 26 Apr 2017 08:08:46 -0700 Subject: [PATCH] Restructure to focus on lib rather than cli --- core/analyzer.go => analyzer.go | 2 +- core/call_list.go => call_list.go | 2 +- core/call_list_test.go => call_list_test.go | 2 +- filelist.go => cmd/filelist.go | 0 filelist_test.go => cmd/filelist_test.go | 0 main.go => cmd/main.go | 2 +- main_test.go => cmd/main_test.go | 0 rulelist.go => cmd/rulelist.go | 2 +- tools.go => cmd/tools.go | 0 core/helpers.go => helpers.go | 2 +- core/helpers_test.go => helpers_test.go | 2 +- core/issue.go => issue.go | 2 +- output/formatter.go | 2 +- core/resolve.go => resolve.go | 2 +- rules/big.go | 2 +- rules/big_test.go | 2 +- rules/bind.go | 2 +- rules/bind_test.go | 2 +- rules/blacklist.go | 2 +- rules/blacklist_test.go | 3 ++- rules/errors.go | 3 ++- rules/errors_test.go | 2 +- rules/fileperms.go | 2 +- rules/fileperms_test.go | 2 +- rules/hardcoded_credentials.go | 6 +++--- rules/hardcoded_credentials_test.go | 2 +- rules/httpoxy_test.go | 2 +- rules/nosec_test.go | 4 ++-- rules/rand.go | 2 +- rules/rand_test.go | 6 +++--- rules/rsa.go | 2 +- rules/rsa_test.go | 2 +- rules/sql.go | 2 +- rules/sql_test.go | 2 +- rules/subproc.go | 2 +- rules/subproc_test.go | 2 +- rules/tempfiles.go | 2 +- rules/tempfiles_test.go | 2 +- rules/templates.go | 2 +- rules/templates_test.go | 2 +- rules/tls.go | 2 +- rules/tls_test.go | 2 +- rules/unsafe.go | 3 ++- rules/unsafe_test.go | 2 +- rules/utils_test.go | 2 +- rules/weakcrypto.go | 2 +- rules/weakcrypto_test.go | 2 +- core/select.go => select.go | 2 +- 48 files changed, 52 insertions(+), 49 deletions(-) rename core/analyzer.go => analyzer.go (99%) rename core/call_list.go => call_list.go (99%) rename core/call_list_test.go => call_list_test.go (98%) rename filelist.go => cmd/filelist.go (100%) rename filelist_test.go => cmd/filelist_test.go (100%) rename main.go => cmd/main.go (99%) rename main_test.go => cmd/main_test.go (100%) rename rulelist.go => cmd/rulelist.go (98%) rename tools.go => cmd/tools.go (100%) rename core/helpers.go => helpers.go (99%) rename core/helpers_test.go => helpers_test.go (99%) rename core/issue.go => issue.go (99%) rename core/resolve.go => resolve.go (99%) rename core/select.go => select.go (99%) diff --git a/core/analyzer.go b/analyzer.go similarity index 99% rename from core/analyzer.go rename to analyzer.go index 2362e95..b360945 100644 --- a/core/analyzer.go +++ b/analyzer.go @@ -13,7 +13,7 @@ // limitations under the License. // Package core holds the central scanning logic used by GAS -package core +package gas import ( "go/ast" diff --git a/core/call_list.go b/call_list.go similarity index 99% rename from core/call_list.go rename to call_list.go index 2002024..3de5b04 100644 --- a/core/call_list.go +++ b/call_list.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package core +package gas import ( "go/ast" diff --git a/core/call_list_test.go b/call_list_test.go similarity index 98% rename from core/call_list_test.go rename to call_list_test.go index ef58293..d77199f 100644 --- a/core/call_list_test.go +++ b/call_list_test.go @@ -1,4 +1,4 @@ -package core +package gas import ( "go/ast" diff --git a/filelist.go b/cmd/filelist.go similarity index 100% rename from filelist.go rename to cmd/filelist.go diff --git a/filelist_test.go b/cmd/filelist_test.go similarity index 100% rename from filelist_test.go rename to cmd/filelist_test.go diff --git a/main.go b/cmd/main.go similarity index 99% rename from main.go rename to cmd/main.go index ff8db95..7ecda5a 100644 --- a/main.go +++ b/cmd/main.go @@ -27,7 +27,7 @@ import ( "sort" "strings" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" "github.com/GoASTScanner/gas/output" "golang.org/x/tools/go/loader" ) diff --git a/main_test.go b/cmd/main_test.go similarity index 100% rename from main_test.go rename to cmd/main_test.go diff --git a/rulelist.go b/cmd/rulelist.go similarity index 98% rename from rulelist.go rename to cmd/rulelist.go index 285c1a1..807a1df 100644 --- a/rulelist.go +++ b/cmd/rulelist.go @@ -17,7 +17,7 @@ package main import ( "go/ast" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" "github.com/GoASTScanner/gas/rules" ) diff --git a/tools.go b/cmd/tools.go similarity index 100% rename from tools.go rename to cmd/tools.go diff --git a/core/helpers.go b/helpers.go similarity index 99% rename from core/helpers.go rename to helpers.go index 8ccfbbf..14a0d7d 100644 --- a/core/helpers.go +++ b/helpers.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package core +package gas import ( "fmt" diff --git a/core/helpers_test.go b/helpers_test.go similarity index 99% rename from core/helpers_test.go rename to helpers_test.go index 1a7bcda..18fa63d 100644 --- a/core/helpers_test.go +++ b/helpers_test.go @@ -1,4 +1,4 @@ -package core +package gas import ( "go/ast" diff --git a/core/issue.go b/issue.go similarity index 99% rename from core/issue.go rename to issue.go index 22c5044..8f6b6ef 100644 --- a/core/issue.go +++ b/issue.go @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -package core +package gas import ( "encoding/json" diff --git a/output/formatter.go b/output/formatter.go index fbda520..1bdd95f 100644 --- a/output/formatter.go +++ b/output/formatter.go @@ -22,7 +22,7 @@ import ( "strconv" plainTemplate "text/template" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) // The output format for reported issues diff --git a/core/resolve.go b/resolve.go similarity index 99% rename from core/resolve.go rename to resolve.go index 185df7a..93680b5 100644 --- a/core/resolve.go +++ b/resolve.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package core +package gas import "go/ast" diff --git a/rules/big.go b/rules/big.go index 8ac0d42..9268b0f 100644 --- a/rules/big.go +++ b/rules/big.go @@ -15,7 +15,7 @@ package rules import ( - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" "go/ast" ) diff --git a/rules/big_test.go b/rules/big_test.go index b533e66..da96ca1 100644 --- a/rules/big_test.go +++ b/rules/big_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestBigExp(t *testing.T) { diff --git a/rules/bind.go b/rules/bind.go index ba91ba6..b1f126e 100644 --- a/rules/bind.go +++ b/rules/bind.go @@ -18,7 +18,7 @@ import ( "go/ast" "regexp" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) // Looks for net.Listen("0.0.0.0") or net.Listen(":8080") diff --git a/rules/bind_test.go b/rules/bind_test.go index 16bc389..69206f0 100644 --- a/rules/bind_test.go +++ b/rules/bind_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestBind0000(t *testing.T) { diff --git a/rules/blacklist.go b/rules/blacklist.go index 747eb4b..cff1af1 100644 --- a/rules/blacklist.go +++ b/rules/blacklist.go @@ -17,7 +17,7 @@ package rules import ( "go/ast" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type BlacklistImport struct { diff --git a/rules/blacklist_test.go b/rules/blacklist_test.go index 110afd4..a706ca8 100644 --- a/rules/blacklist_test.go +++ b/rules/blacklist_test.go @@ -13,8 +13,9 @@ package rules import ( - gas "github.com/GoASTScanner/gas/core" "testing" + + "github.com/GoASTScanner/gas" ) const initOnlyImportSrc = ` diff --git a/rules/errors.go b/rules/errors.go index 2bf61c9..46bd3d4 100644 --- a/rules/errors.go +++ b/rules/errors.go @@ -15,9 +15,10 @@ package rules import ( - gas "github.com/GoASTScanner/gas/core" "go/ast" "go/types" + + "github.com/GoASTScanner/gas" ) type NoErrorCheck struct { diff --git a/rules/errors_test.go b/rules/errors_test.go index a0d82c9..2b2fcd4 100644 --- a/rules/errors_test.go +++ b/rules/errors_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestErrorsMulti(t *testing.T) { diff --git a/rules/fileperms.go b/rules/fileperms.go index 101c7e2..2ee5ec8 100644 --- a/rules/fileperms.go +++ b/rules/fileperms.go @@ -19,7 +19,7 @@ import ( "go/ast" "strconv" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type FilePermissions struct { diff --git a/rules/fileperms_test.go b/rules/fileperms_test.go index 278c29e..31cf48a 100644 --- a/rules/fileperms_test.go +++ b/rules/fileperms_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestChmod(t *testing.T) { diff --git a/rules/hardcoded_credentials.go b/rules/hardcoded_credentials.go index 1b4b85a..9c1d278 100644 --- a/rules/hardcoded_credentials.go +++ b/rules/hardcoded_credentials.go @@ -15,13 +15,13 @@ package rules import ( - gas "github.com/GoASTScanner/gas/core" "go/ast" "go/token" "regexp" - - "github.com/nbutton23/zxcvbn-go" "strconv" + + "github.com/GoASTScanner/gas" + "github.com/nbutton23/zxcvbn-go" ) type Credentials struct { diff --git a/rules/hardcoded_credentials_test.go b/rules/hardcoded_credentials_test.go index 63f3db1..34380c5 100644 --- a/rules/hardcoded_credentials_test.go +++ b/rules/hardcoded_credentials_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestHardcoded(t *testing.T) { diff --git a/rules/httpoxy_test.go b/rules/httpoxy_test.go index b666fdf..61b4a87 100644 --- a/rules/httpoxy_test.go +++ b/rules/httpoxy_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestHttpoxy(t *testing.T) { diff --git a/rules/nosec_test.go b/rules/nosec_test.go index dbbc107..45b4b3b 100644 --- a/rules/nosec_test.go +++ b/rules/nosec_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestNosec(t *testing.T) { @@ -48,7 +48,7 @@ func TestNosecBlock(t *testing.T) { issues := gasTestRunner( `package main import ( - "os" + "os" "os/exec" ) diff --git a/rules/rand.go b/rules/rand.go index 9cc99e4..dae12f1 100644 --- a/rules/rand.go +++ b/rules/rand.go @@ -17,7 +17,7 @@ package rules import ( "go/ast" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type WeakRand struct { diff --git a/rules/rand_test.go b/rules/rand_test.go index d6de104..1a166c0 100644 --- a/rules/rand_test.go +++ b/rules/rand_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestRandOk(t *testing.T) { @@ -27,7 +27,7 @@ func TestRandOk(t *testing.T) { issues := gasTestRunner( ` - package main + package main import "crypto/rand" @@ -66,7 +66,7 @@ func TestRandRenamed(t *testing.T) { issues := gasTestRunner( ` - package main + package main import ( "crypto/rand" diff --git a/rules/rsa.go b/rules/rsa.go index 510ca78..a24c986 100644 --- a/rules/rsa.go +++ b/rules/rsa.go @@ -19,7 +19,7 @@ import ( "go/ast" "regexp" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type WeakKeyStrength struct { diff --git a/rules/rsa_test.go b/rules/rsa_test.go index 9b0b47b..33aefdd 100644 --- a/rules/rsa_test.go +++ b/rules/rsa_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestRSAKeys(t *testing.T) { diff --git a/rules/sql.go b/rules/sql.go index 9b8b79f..fd04b34 100644 --- a/rules/sql.go +++ b/rules/sql.go @@ -18,7 +18,7 @@ import ( "go/ast" "regexp" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type SqlStatement struct { diff --git a/rules/sql_test.go b/rules/sql_test.go index 8919f7a..4df6b1f 100644 --- a/rules/sql_test.go +++ b/rules/sql_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestSQLInjectionViaConcatenation(t *testing.T) { diff --git a/rules/subproc.go b/rules/subproc.go index b5a6fa2..b16b3af 100644 --- a/rules/subproc.go +++ b/rules/subproc.go @@ -19,7 +19,7 @@ import ( "regexp" "strings" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type Subprocess struct { diff --git a/rules/subproc_test.go b/rules/subproc_test.go index 13c79df..c333f44 100644 --- a/rules/subproc_test.go +++ b/rules/subproc_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestSubprocess(t *testing.T) { diff --git a/rules/tempfiles.go b/rules/tempfiles.go index 8cbd55a..964db27 100644 --- a/rules/tempfiles.go +++ b/rules/tempfiles.go @@ -18,7 +18,7 @@ import ( "go/ast" "regexp" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type BadTempFile struct { diff --git a/rules/tempfiles_test.go b/rules/tempfiles_test.go index 51709e8..34cf2b9 100644 --- a/rules/tempfiles_test.go +++ b/rules/tempfiles_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestTempfiles(t *testing.T) { diff --git a/rules/templates.go b/rules/templates.go index 0f1dc24..e83f24e 100644 --- a/rules/templates.go +++ b/rules/templates.go @@ -18,7 +18,7 @@ import ( "go/ast" "regexp" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type TemplateCheck struct { diff --git a/rules/templates_test.go b/rules/templates_test.go index 83dccf1..e794625 100644 --- a/rules/templates_test.go +++ b/rules/templates_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestTemplateCheckSafe(t *testing.T) { diff --git a/rules/tls.go b/rules/tls.go index cbcca56..a2410b5 100644 --- a/rules/tls.go +++ b/rules/tls.go @@ -20,7 +20,7 @@ import ( "reflect" "regexp" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type InsecureConfigTLS struct { diff --git a/rules/tls_test.go b/rules/tls_test.go index 9b215a3..c5d7124 100644 --- a/rules/tls_test.go +++ b/rules/tls_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestInsecureSkipVerify(t *testing.T) { diff --git a/rules/unsafe.go b/rules/unsafe.go index 861f77c..611ef0c 100644 --- a/rules/unsafe.go +++ b/rules/unsafe.go @@ -15,8 +15,9 @@ package rules import ( - gas "github.com/GoASTScanner/gas/core" "go/ast" + + "github.com/GoASTScanner/gas" ) type UsingUnsafe struct { diff --git a/rules/unsafe_test.go b/rules/unsafe_test.go index f8d7787..920024c 100644 --- a/rules/unsafe_test.go +++ b/rules/unsafe_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestUnsafe(t *testing.T) { diff --git a/rules/utils_test.go b/rules/utils_test.go index 48fa36f..c8062cc 100644 --- a/rules/utils_test.go +++ b/rules/utils_test.go @@ -18,7 +18,7 @@ import ( "strings" "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func gasTestRunner(source string, analyzer gas.Analyzer) []*gas.Issue { diff --git a/rules/weakcrypto.go b/rules/weakcrypto.go index 1c859e9..ac2b55f 100644 --- a/rules/weakcrypto.go +++ b/rules/weakcrypto.go @@ -17,7 +17,7 @@ package rules import ( "go/ast" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) type UsesWeakCryptography struct { diff --git a/rules/weakcrypto_test.go b/rules/weakcrypto_test.go index 1305c33..59d5a5f 100644 --- a/rules/weakcrypto_test.go +++ b/rules/weakcrypto_test.go @@ -17,7 +17,7 @@ package rules import ( "testing" - gas "github.com/GoASTScanner/gas/core" + "github.com/GoASTScanner/gas" ) func TestMD5(t *testing.T) { diff --git a/core/select.go b/select.go similarity index 99% rename from core/select.go rename to select.go index e11c946..b4b928c 100644 --- a/core/select.go +++ b/select.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package core +package gas import ( "fmt"