From c38064d9f071d5517b574c153e9f8b6595f523a2 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Sun, 17 Nov 2024 01:10:12 +0200 Subject: [PATCH] chore: fix typos in comments and tests; enable misspell (#3573) --- .github/workflows/lint.yml | 2 +- Makefile | 2 +- pkg/analyzer/analyzers/mysql/mysql.go | 6 +++--- pkg/analyzer/analyzers/postgres/postgres.go | 4 ++-- pkg/analyzer/analyzers/sourcegraph/sourcegraph.go | 2 +- pkg/common/patterns_test.go | 2 +- pkg/detectors/agora/agora_test.go | 2 +- pkg/detectors/alchemy/alchemy_test.go | 2 +- pkg/detectors/apimatic/apimatic.go | 2 +- pkg/detectors/appfollow/appfollow_test.go | 4 ++-- pkg/detectors/appointedd/appointedd_test.go | 4 ++-- pkg/detectors/appoptics/appoptics_test.go | 4 ++-- pkg/detectors/appsynergy/appsynergy_test.go | 4 ++-- .../auth0managementapitoken_test.go | 2 +- pkg/detectors/boxoauth/boxoauth.go | 2 +- pkg/detectors/sentrytoken/sentrytoken_test.go | 8 ++++---- pkg/detectors/sumologickey/sumologickey_test.go | 2 +- pkg/detectors/weightsandbiases/weightsandbiases_test.go | 2 +- pkg/sanitizer/utf8_test.go | 4 ++-- pkg/sources/git/git_test.go | 2 +- pkg/sources/github_experimental/object_discovery.go | 2 +- 21 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 215c1bfc6..07e4f9b56 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,7 +28,7 @@ jobs: # working-directory: somedir # Optional: golangci-lint command line arguments. - args: --enable bodyclose --enable copyloopvar --timeout 10m + args: --enable bodyclose --enable copyloopvar --enable misspell --timeout 10m # Optional: if set to true then the action don't cache or restore ~/go/pkg. # skip-pkg-cache: true diff --git a/Makefile b/Makefile index a74a4f7f7..35f161ee5 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ check: go vet $(shell go list ./... | grep -v /vendor/) lint: - golangci-lint run --enable bodyclose --enable copyloopvar --out-format=colored-line-number --timeout 10m + golangci-lint run --enable bodyclose --enable copyloopvar --enable misspell --out-format=colored-line-number --timeout 10m test-failing: CGO_ENABLED=0 go test -timeout=5m $(shell go list ./... | grep -v /vendor/) | grep FAIL diff --git a/pkg/analyzer/analyzers/mysql/mysql.go b/pkg/analyzer/analyzers/mysql/mysql.go index 173cb4305..c44a2a14d 100644 --- a/pkg/analyzer/analyzers/mysql/mysql.go +++ b/pkg/analyzer/analyzers/mysql/mysql.go @@ -52,11 +52,11 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { Bindings: []analyzers.Binding{}, } - // add user priviliges to bindings + // add user privileges to bindings userBindings, userResource := bakeUserBindings(info) result.Bindings = append(result.Bindings, userBindings...) - // add user's database priviliges to bindings + // add user's database privileges to bindings databaseBindings := bakeDatabaseBindings(userResource, info) result.Bindings = append(result.Bindings, databaseBindings...) @@ -67,7 +67,7 @@ func bakeUserBindings(info *SecretInfo) ([]analyzers.Binding, *analyzers.Resourc var userBindings []analyzers.Binding - // add user and their priviliges to bindings + // add user and their privileges to bindings userResource := analyzers.Resource{ Name: info.User, FullyQualifiedName: info.Host + "/" + info.User, diff --git a/pkg/analyzer/analyzers/postgres/postgres.go b/pkg/analyzer/analyzers/postgres/postgres.go index ca4a74e20..2d69d61d0 100644 --- a/pkg/analyzer/analyzers/postgres/postgres.go +++ b/pkg/analyzer/analyzers/postgres/postgres.go @@ -54,11 +54,11 @@ func secretInfoToAnalyzerResult(info *SecretInfo) *analyzers.AnalyzerResult { userResource, userBindings := bakeUserBindings(info) result.Bindings = append(result.Bindings, userBindings...) - // add user's database priviliges to bindings + // add user's database privileges to bindings dbNameToResourceMap, dbBindings := bakeDatabaseBindings(userResource, info) result.Bindings = append(result.Bindings, dbBindings...) - // add user's table priviliges to bindings + // add user's table privileges to bindings tableBindings := bakeTableBindings(dbNameToResourceMap, info) result.Bindings = append(result.Bindings, tableBindings...) diff --git a/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go b/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go index d9e4f95b7..989dde52e 100644 --- a/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go +++ b/pkg/analyzer/analyzers/sourcegraph/sourcegraph.go @@ -1,7 +1,7 @@ //go:generate generate_permissions permissions.yaml permissions.go sourcegraph package sourcegraph -// ToDo: Add suport for custom domain +// ToDo: Add support for custom domain import ( "encoding/json" diff --git a/pkg/common/patterns_test.go b/pkg/common/patterns_test.go index 329f4c7f8..5303fe97c 100644 --- a/pkg/common/patterns_test.go +++ b/pkg/common/patterns_test.go @@ -25,7 +25,7 @@ func TestEmailRegexCheck(t *testing.T) { hyphen domain = info@my-site.net service email = contact@web-service.io underscore email = example_user@domain.info - departement email = first.last@department.company.edu + department email = first.last@department.company.edu alphanumeric email = user1234@domain.co local server email = admin@local-server.local dot email = test.email@my-email-service.xyz diff --git a/pkg/detectors/agora/agora_test.go b/pkg/detectors/agora/agora_test.go index d515b8d0d..bf050034c 100644 --- a/pkg/detectors/agora/agora_test.go +++ b/pkg/detectors/agora/agora_test.go @@ -15,7 +15,7 @@ var ( validKeyPattern = "asdf0987mnbv1234qsxojb6ygb2wsx0o" validSecretPattern = "beqr7215fr4g6bfjkmnvxrtygb2wsxap" complexPattern = `agora credentials - these are some example credentails for login. + these are some example credentials for login. use these to login. key: asdf0987mnbv1234qsxojb6ygb2wsx0o secret: beqr7215fr4g6bfjkmnvxrtygb2wsxap diff --git a/pkg/detectors/alchemy/alchemy_test.go b/pkg/detectors/alchemy/alchemy_test.go index 83af610b3..38a7ba726 100644 --- a/pkg/detectors/alchemy/alchemy_test.go +++ b/pkg/detectors/alchemy/alchemy_test.go @@ -28,7 +28,7 @@ alchemy_token2 = '3aDcDFE56789012245678a0_1a2b3c2d'`, want: []string{"3aBcDFE5678901234567890_1a2b3c4d", "3aDcDFE56789012245678a0_1a2b3c2d"}, }, { - name: "invald pattern", + name: "invalid pattern", input: "alchemy_token = '1a2b3c4d'", want: []string{}, }, diff --git a/pkg/detectors/apimatic/apimatic.go b/pkg/detectors/apimatic/apimatic.go index 1198e6707..0edd4d43a 100644 --- a/pkg/detectors/apimatic/apimatic.go +++ b/pkg/detectors/apimatic/apimatic.go @@ -66,7 +66,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result s1.Verified = true } } else { - // if any error happens during api request capture that as verificaiton error + // if any error happens during api request capture that as verification error s1.SetVerificationError(err, apiKey) } } diff --git a/pkg/detectors/appfollow/appfollow_test.go b/pkg/detectors/appfollow/appfollow_test.go index dbae86cdf..7427ccde3 100644 --- a/pkg/detectors/appfollow/appfollow_test.go +++ b/pkg/detectors/appfollow/appfollow_test.go @@ -27,12 +27,12 @@ func TestAppFollow_Pattern(t *testing.T) { }{ { name: "valid pattern", - input: fmt.Sprintf("appfollow credentail: %s", validPattern), + input: fmt.Sprintf("appfollow credential: %s", validPattern), want: []string{"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.333HbjEo1oxVUFcASR0sQ8cMuIJRLcMd5H9iJWDbovCw6ESjNtuoEMQQGPN9aSoxponxrTPvn1.btADhgNetsaUBuwoyHo5ip0Jab6N6MEBnSaT6CHiO6z"}, }, { name: "invalid pattern", - input: fmt.Sprintf("appfollow credentail: %s", invalidPattern), + input: fmt.Sprintf("appfollow credential: %s", invalidPattern), want: nil, }, } diff --git a/pkg/detectors/appointedd/appointedd_test.go b/pkg/detectors/appointedd/appointedd_test.go index 08c498c3c..462854b56 100644 --- a/pkg/detectors/appointedd/appointedd_test.go +++ b/pkg/detectors/appointedd/appointedd_test.go @@ -27,12 +27,12 @@ func TestAppFollow_Pattern(t *testing.T) { }{ { name: "valid pattern", - input: fmt.Sprintf("appointedd credentail: %s", validPattern), + input: fmt.Sprintf("appointedd credential: %s", validPattern), want: []string{"Ci0a2bSpRyFcZyEXBEr9RHzf3xXllqO=XVoh+t0L0s8T2s3MFntfWhBlovqLaqEadtuJ9=Jy6yCOXmhbpEZPfY7Y"}, }, { name: "invalid pattern", - input: fmt.Sprintf("appointedd credentail: %s", invalidPattern), + input: fmt.Sprintf("appointedd credential: %s", invalidPattern), want: nil, }, } diff --git a/pkg/detectors/appoptics/appoptics_test.go b/pkg/detectors/appoptics/appoptics_test.go index f4c9bd448..41920ae59 100644 --- a/pkg/detectors/appoptics/appoptics_test.go +++ b/pkg/detectors/appoptics/appoptics_test.go @@ -27,12 +27,12 @@ func TestAppOptics_Pattern(t *testing.T) { }{ { name: "valid pattern", - input: fmt.Sprintf("appoptics credentail: %s", validPattern), + input: fmt.Sprintf("appoptics credential: %s", validPattern), want: []string{"IABJPR08RmvsGrebJhr1TUdo27-KtTn0mLCKkJJqj5lyba-otXPklygO9DK62o3QSPoIJ4E"}, }, { name: "invalid pattern", - input: fmt.Sprintf("appoptics credentail: %s", invalidPattern), + input: fmt.Sprintf("appoptics credential: %s", invalidPattern), want: nil, }, } diff --git a/pkg/detectors/appsynergy/appsynergy_test.go b/pkg/detectors/appsynergy/appsynergy_test.go index 5ca3017f1..975115c1e 100644 --- a/pkg/detectors/appsynergy/appsynergy_test.go +++ b/pkg/detectors/appsynergy/appsynergy_test.go @@ -27,12 +27,12 @@ func TestAppSynergy_Pattern(t *testing.T) { }{ { name: "valid pattern", - input: fmt.Sprintf("appsynergy credentail: %s", validPattern), + input: fmt.Sprintf("appsynergy credential: %s", validPattern), want: []string{"mg1pgwlndtq7rbk8i3kum344aso8ggp02ximdhsp8nsqasd3btxf84lz9ekfdpwo"}, }, { name: "invalid pattern", - input: fmt.Sprintf("appsynergy credentail: %s", invalidPattern), + input: fmt.Sprintf("appsynergy credential: %s", invalidPattern), want: nil, }, } diff --git a/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go b/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go index 7e098d664..0077e52cb 100644 --- a/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go +++ b/pkg/detectors/auth0managementapitoken/auth0managementapitoken_test.go @@ -19,7 +19,7 @@ var ( validPattern = generateRandomString() // this has the exact token string only which can be used in want too validDomain = "QHHPu7VPj.sI.auth0.com" invalidPattern = ` - auth0_credentails: + auth0_credentials: apiToken: eywT2nGMZwOcbsUVBwfiRPEl8P_wnmo6XfdUoGVwxDfOSjNyqhYqFdi.KojZZOM8Ox domain: QHHPu7VPj.sI.auth0.com ` diff --git a/pkg/detectors/boxoauth/boxoauth.go b/pkg/detectors/boxoauth/boxoauth.go index dee8050f7..af5f80c94 100644 --- a/pkg/detectors/boxoauth/boxoauth.go +++ b/pkg/detectors/boxoauth/boxoauth.go @@ -80,7 +80,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result results = append(results, s1) - // box client supportes only one client id and secret pair + // box client supports only one client id and secret pair if s1.Verified { break } diff --git a/pkg/detectors/sentrytoken/sentrytoken_test.go b/pkg/detectors/sentrytoken/sentrytoken_test.go index 44a9324f2..5c64febff 100644 --- a/pkg/detectors/sentrytoken/sentrytoken_test.go +++ b/pkg/detectors/sentrytoken/sentrytoken_test.go @@ -125,7 +125,7 @@ func TestSentryToken_FromChunk(t *testing.T) { }, { name: "found, account deactivated", - s: Scanner{client: common.ConstantResponseHttpClient(200, reponseAccountDeactivated)}, + s: Scanner{client: common.ConstantResponseHttpClient(200, responseAccountDeactivated)}, args: args{ ctx: context.Background(), data: []byte(fmt.Sprintf("You can find a sentry super secret %s within", secret)), @@ -142,7 +142,7 @@ func TestSentryToken_FromChunk(t *testing.T) { }, { name: "found, account deactivated", - s: Scanner{client: common.ConstantResponseHttpClient(200, responseEnmpty)}, + s: Scanner{client: common.ConstantResponseHttpClient(200, responseEmpty)}, args: args{ ctx: context.Background(), data: []byte(fmt.Sprintf("You can find a sentry super secret %s within", secret)), @@ -209,8 +209,8 @@ const ( } ] ` - reponseAccountDeactivated = `{"detail": "Authentication credentials were not provided"}` - responseEnmpty = `[]` + responseAccountDeactivated = `{"detail": "Authentication credentials were not provided"}` + responseEmpty = `[]` ) func BenchmarkFromData(benchmark *testing.B) { diff --git a/pkg/detectors/sumologickey/sumologickey_test.go b/pkg/detectors/sumologickey/sumologickey_test.go index 3fe250ee9..2e0c8f1d8 100644 --- a/pkg/detectors/sumologickey/sumologickey_test.go +++ b/pkg/detectors/sumologickey/sumologickey_test.go @@ -44,7 +44,7 @@ sumoKey2 = 'Khk3i2ugMxMgkb8bIA2auj4I8juZ3HiimDNssjzYdGqfizPZcxHK21a0LckgRSCL'`, want: []string{"CzrMhR8zzy1eH1F0XlY1tu5ywqa2yaSFoWGg2cqE43XkfnUVCytnPQfv1enUYrzv", "Khk3i2ugMxMgkb8bIA2auj4I8juZ3HiimDNssjzYdGqfizPZcxHK21a0LckgRSCL"}, }, { - name: "invald pattern", + name: "invalid pattern", input: "sumoId = 'doDkVYKjXZAwsz'", want: []string{}, }, diff --git a/pkg/detectors/weightsandbiases/weightsandbiases_test.go b/pkg/detectors/weightsandbiases/weightsandbiases_test.go index bae59b5a5..28adaf9a1 100644 --- a/pkg/detectors/weightsandbiases/weightsandbiases_test.go +++ b/pkg/detectors/weightsandbiases/weightsandbiases_test.go @@ -30,7 +30,7 @@ WANDB_API_KEY= 'eedf1c984f6b995ec40ecc6658356044847ffb32'`, want: []string{"eedf1c984f6b995ec40ecc6658356044847ffb31", "eedf1c984f6b995ec40ecc6658356044847ffb32"}, }, { - name: "invald pattern", + name: "invalid pattern", input: "WANDB_API_KEY = 'e84f6b995ec40ecc6658356044847ffb31'", want: []string{}, }, diff --git a/pkg/sanitizer/utf8_test.go b/pkg/sanitizer/utf8_test.go index 04878ff22..ecb48672a 100644 --- a/pkg/sanitizer/utf8_test.go +++ b/pkg/sanitizer/utf8_test.go @@ -19,14 +19,14 @@ func TestUTF8(t *testing.T) { want: "hello123", }, { - name: "santized", + name: "sanitized", args: args{ in: "Gr\351gory Smith", }, want: "Grâť—gory Smith", }, { - name: "santized", + name: "sanitized", args: args{ in: "no \x00 nulls because postgres does not support it in text fields", }, diff --git a/pkg/sources/git/git_test.go b/pkg/sources/git/git_test.go index 7b0991fd0..e4273c32b 100644 --- a/pkg/sources/git/git_test.go +++ b/pkg/sources/git/git_test.go @@ -201,7 +201,7 @@ func TestSource_Chunks_Integration(t *testing.T) { "27fbead3bf883cdb7de9d7825ed401f28f9398f1-slack": {B: []byte("\n\n\nyup, just did that\n\ngithub_lol: \"ffc7e0f9400fb6300167009e42d2f842cd7956e2\"\n\noh, goodness. there's another one!\n")}, "8afb0ecd4998b1179e428db5ebbcdc8221214432-": {B: []byte("Dustin \nDustin \nadd slack token\n")}, "8afb0ecd4998b1179e428db5ebbcdc8221214432-slack": {B: []byte("oops might drop a slack token here\n\ngithub_secret=\"369963c1434c377428ca8531fbc46c0c43d037a0\"\n\nyup, just did that\n"), Multi: true}, - "8fe6f04ef1839e3fc54b5147e3d0e0b7ab971bd5-": {B: []byte("Dustin \nDustin \noops, accidently commited AWS token...\n")}, + "8fe6f04ef1839e3fc54b5147e3d0e0b7ab971bd5-": {B: []byte("Dustin \nDustin \noops, accidently commited AWS token...\n")}, //nolint:misspell "8fe6f04ef1839e3fc54b5147e3d0e0b7ab971bd5-aws": {B: []byte("blah blaj\n\nthis is the secret: AKIA2E0A8F3B244C9986\n\nokay thank you bye\n"), Multi: true}, "84e9c75e388ae3e866e121087ea2dd45a71068f2-": {B: []byte("Dylan Ayrey \nGitHub \nUpdate aws\n")}, "84e9c75e388ae3e866e121087ea2dd45a71068f2-aws": {B: []byte("\n\nthis is the secret: [Default]\nAccess key Id: AKIAILE3JG6KMS3HZGCA\nSecret Access Key: 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\n\nokay thank you bye\n"), Multi: false}, diff --git a/pkg/sources/github_experimental/object_discovery.go b/pkg/sources/github_experimental/object_discovery.go index db2c72ad6..968491274 100644 --- a/pkg/sources/github_experimental/object_discovery.go +++ b/pkg/sources/github_experimental/object_discovery.go @@ -39,7 +39,7 @@ const startingCharLen = 4 // Max character length (6 is the default maximum) // 6 chars == 16M possibilities --> which will take 18k-55k queries. // that's really the max that's tolerable since it will take a long time to run. -// If you increase this to accomdate a MASSIVE repository, it will take a long time to run. +// If you increase this to accommodate a MASSIVE repository, it will take a long time to run. const maxCharLen = 6 // Starting GraphQL query chunk size.