Skip to content

Commit d058847

Browse files
authored
[Fix] Fix Abyssale Detector Typo (#4067)
* updated abyssale detector; fixed all typos * added back build tags in integration test
1 parent 4df1351 commit d058847

File tree

6 files changed

+41
-40
lines changed

6 files changed

+41
-40
lines changed

pkg/detectors/abbysale/abbysale.go renamed to pkg/detectors/abyssale/abyssale.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package abbysale
1+
package abyssale
22

33
import (
44
"context"
@@ -17,7 +17,7 @@ type Scanner struct {
1717
client *http.Client
1818
}
1919

20-
const abbysaleURL = "https://api.abyssale.com"
20+
const abyssaleURL = "https://api.abyssale.com"
2121

2222
var (
2323
// Ensure the Scanner satisfies the interface at compile time.
@@ -26,13 +26,13 @@ var (
2626
defaultClient = common.SaneHttpClient()
2727

2828
// Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
29-
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"abbysale"}) + `\b([a-z0-9A-Z]{40})\b`)
29+
keyPat = regexp.MustCompile(detectors.PrefixRegex([]string{"abyssale"}) + `\b([a-z0-9A-Z]{40})\b`)
3030
)
3131

3232
// Keywords are used for efficiently pre-filtering chunks.
3333
// Use identifiers in the secret preferably, or the provider name.
3434
func (s Scanner) Keywords() []string {
35-
return []string{"abbysale"}
35+
return []string{"abyssale"}
3636
}
3737

3838
func (s Scanner) getClient() *http.Client {
@@ -42,7 +42,7 @@ func (s Scanner) getClient() *http.Client {
4242
return defaultClient
4343
}
4444

45-
// FromData will find and optionally verify Abbysale secrets in a given set of bytes.
45+
// FromData will find and optionally verify Abyssale secrets in a given set of bytes.
4646
func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (results []detectors.Result, err error) {
4747
dataStr := string(data)
4848

@@ -52,13 +52,13 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
5252
resMatch := strings.TrimSpace(match[1])
5353

5454
s1 := detectors.Result{
55-
DetectorType: detectorspb.DetectorType_Abbysale,
55+
DetectorType: detectorspb.DetectorType_Abyssale,
5656
Raw: []byte(resMatch),
5757
}
5858

5959
if verify {
6060
client := s.getClient()
61-
isVerified, verificationErr := verifyAbbysale(ctx, client, resMatch)
61+
isVerified, verificationErr := verifyAbyssale(ctx, client, resMatch)
6262
s1.Verified = isVerified
6363
s1.SetVerificationError(verificationErr, resMatch)
6464
}
@@ -69,9 +69,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
6969
return results, nil
7070
}
7171

72-
func verifyAbbysale(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
72+
func verifyAbyssale(ctx context.Context, client *http.Client, resMatch string) (bool, error) {
7373
// https://developers.abyssale.com/rest-api/authentication
74-
req, err := http.NewRequestWithContext(ctx, http.MethodGet, abbysaleURL+"/ready", nil)
74+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, abyssaleURL+"/ready", nil)
7575
if err != nil {
7676
return false, err
7777
}
@@ -93,9 +93,9 @@ func verifyAbbysale(ctx context.Context, client *http.Client, resMatch string) (
9393
}
9494

9595
func (s Scanner) Type() detectorspb.DetectorType {
96-
return detectorspb.DetectorType_Abbysale
96+
return detectorspb.DetectorType_Abyssale
9797
}
9898

9999
func (s Scanner) Description() string {
100-
return "Abbysale is a service offering various API functionalities for marketing automation and services such as images and ad campaigns. Abbysale API keys can be used to access and interact with this data."
100+
return "Abyssale is a service offering various API functionalities for marketing automation and services such as images and ad campaigns. Abyssale API keys can be used to access and interact with this data."
101101
}

pkg/detectors/abbysale/abbysale_integration_test.go renamed to pkg/detectors/abyssale/abyssale_integration_test.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
//go:build detectors
22
// +build detectors
33

4-
package abbysale
4+
package abyssale
55

66
import (
77
"context"
88
"fmt"
9+
"testing"
10+
"time"
11+
912
"github.com/google/go-cmp/cmp/cmpopts"
1013
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
1114
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/detectorspb"
12-
"testing"
13-
"time"
1415

1516
"github.com/google/go-cmp/cmp"
1617

1718
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
1819
)
1920

20-
func TestAbbysale_FromChunk(t *testing.T) {
21+
func TestAbyssale_FromChunk(t *testing.T) {
2122
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
2223
defer cancel()
23-
testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors3")
24+
testSecrets, err := common.GetSecret(ctx, "trufflehog-testing", "detectors5")
2425
if err != nil {
2526
t.Fatalf("could not get test secrets from GCP: %s", err)
2627
}
27-
secret := testSecrets.MustGetField("ABBYSALE_TOKEN")
28-
inactiveSecret := testSecrets.MustGetField("ABBYSALE_INACTIVE")
28+
secret := testSecrets.MustGetField("ABYSSALE_TOKEN")
29+
inactiveSecret := testSecrets.MustGetField("ABYSSALE_INACTIVE")
2930

3031
type args struct {
3132
ctx context.Context
@@ -44,12 +45,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
4445
s: Scanner{},
4546
args: args{
4647
ctx: context.Background(),
47-
data: []byte(fmt.Sprintf("You can find a abbysale secret %s within but verified", secret)),
48+
data: []byte(fmt.Sprintf("You can find a abyssale secret %s within but verified", secret)),
4849
verify: true,
4950
},
5051
want: []detectors.Result{
5152
{
52-
DetectorType: detectorspb.DetectorType_Abbysale,
53+
DetectorType: detectorspb.DetectorType_Abyssale,
5354
Verified: true,
5455
},
5556
},
@@ -60,12 +61,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
6061
s: Scanner{client: common.SaneHttpClientTimeOut(1 * time.Microsecond)},
6162
args: args{
6263
ctx: context.Background(),
63-
data: []byte(fmt.Sprintf("You can find a abbysale secret %s within but verified", secret)),
64+
data: []byte(fmt.Sprintf("You can find a abyssale secret %s within but verified", secret)),
6465
verify: true,
6566
},
6667
want: func() []detectors.Result {
6768
r := detectors.Result{
68-
DetectorType: detectorspb.DetectorType_Abbysale,
69+
DetectorType: detectorspb.DetectorType_Abyssale,
6970
Verified: false,
7071
}
7172
r.SetVerificationError(context.DeadlineExceeded)
@@ -78,12 +79,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
7879
s: Scanner{client: common.ConstantResponseHttpClient(500, "{}")},
7980
args: args{
8081
ctx: context.Background(),
81-
data: []byte(fmt.Sprintf("You can find a abbysale secret %s within but verified", secret)),
82+
data: []byte(fmt.Sprintf("You can find a abyssale secret %s within but verified", secret)),
8283
verify: true,
8384
},
8485
want: func() []detectors.Result {
8586
r := detectors.Result{
86-
DetectorType: detectorspb.DetectorType_Abbysale,
87+
DetectorType: detectorspb.DetectorType_Abyssale,
8788
Verified: false,
8889
}
8990
r.SetVerificationError(fmt.Errorf("unexpected HTTP response status 500"))
@@ -96,12 +97,12 @@ func TestAbbysale_FromChunk(t *testing.T) {
9697
s: Scanner{},
9798
args: args{
9899
ctx: context.Background(),
99-
data: []byte(fmt.Sprintf("You can find a abbysale secret %s within but verified", inactiveSecret)), // the secret would satisfy the regex but not pass validation
100+
data: []byte(fmt.Sprintf("You can find a abyssale secret %s within but verified", inactiveSecret)), // the secret would satisfy the regex but not pass validation
100101
verify: true,
101102
},
102103
want: []detectors.Result{
103104
{
104-
DetectorType: detectorspb.DetectorType_Abbysale,
105+
DetectorType: detectorspb.DetectorType_Abyssale,
105106
Verified: false,
106107
},
107108
},
@@ -123,7 +124,7 @@ func TestAbbysale_FromChunk(t *testing.T) {
123124
t.Run(tt.name, func(t *testing.T) {
124125
got, err := tt.s.FromData(tt.args.ctx, tt.args.verify, tt.args.data)
125126
if (err != nil) != tt.wantErr {
126-
t.Errorf("Abbysale.FromData() error = %v, wantErr %v", err, tt.wantErr)
127+
t.Errorf("Abyssale.FromData() error = %v, wantErr %v", err, tt.wantErr)
127128
return
128129
}
129130
for i := range got {
@@ -145,7 +146,7 @@ func TestAbbysale_FromChunk(t *testing.T) {
145146
}
146147
ignoreOpts := cmpopts.IgnoreFields(detectors.Result{}, "Raw", "RawV2", "verificationError")
147148
if diff := cmp.Diff(got, tt.want, ignoreOpts); diff != "" {
148-
t.Errorf("Abbysale.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
149+
t.Errorf("Abyssale.FromData() %s diff: (-got +want)\n%s", tt.name, diff)
149150
}
150151
})
151152
}

pkg/detectors/abbysale/abbysale_test.go renamed to pkg/detectors/abyssale/abyssale_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package abbysale
1+
package abyssale
22

33
import (
44
"context"
@@ -16,7 +16,7 @@ var (
1616
invalidPattern = "123abcDEF456ghiJKL789mnoPQR012stuVWX"
1717
)
1818

19-
func TestAbbySale_Pattern(t *testing.T) {
19+
func TestAbyssale_Pattern(t *testing.T) {
2020
d := Scanner{}
2121
ahoCorasickCore := ahocorasick.NewAhoCorasickCore([]detectors.Detector{d})
2222

@@ -27,17 +27,17 @@ func TestAbbySale_Pattern(t *testing.T) {
2727
}{
2828
{
2929
name: "valid pattern",
30-
input: fmt.Sprintf("abbysale token = '%s'", validPattern),
30+
input: fmt.Sprintf("abyssale token = '%s'", validPattern),
3131
want: []string{validPattern},
3232
},
3333
{
3434
name: "valid pattern - out of prefix range",
35-
input: fmt.Sprintf("abbysale token keyword is not close to the real token = '%s'", validPattern),
35+
input: fmt.Sprintf("abyssale token keyword is not close to the real token = '%s'", validPattern),
3636
want: nil,
3737
},
3838
{
3939
name: "invalid pattern",
40-
input: fmt.Sprintf("abbysale = '%s'", invalidPattern),
40+
input: fmt.Sprintf("abyssale = '%s'", invalidPattern),
4141
want: nil,
4242
},
4343
}

pkg/engine/defaults/defaults.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package defaults
22

33
import (
44
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors"
5-
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/abbysale"
65
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/abuseipdb"
6+
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/abyssale"
77
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/accuweather"
88
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/adafruitio"
99
"github.com/trufflesecurity/trufflehog/v3/pkg/detectors/adzuna"
@@ -832,7 +832,7 @@ import (
832832

833833
func buildDetectorList() []detectors.Detector {
834834
return []detectors.Detector{
835-
&abbysale.Scanner{},
835+
&abyssale.Scanner{},
836836
// &abstract.Scanner{},
837837
&abuseipdb.Scanner{},
838838
&accuweather.Scanner{},

pkg/pb/detectorspb/detectors.pb.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/detectors.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ enum DetectorType {
249249
ZonkaFeedback = 236;
250250
Delighted = 237;
251251
Feedier = 238;
252-
Abbysale = 239;
252+
Abyssale = 239;
253253
Magnetic = 240;
254254
Nytimes = 241 [deprecated = true];
255255
Polygon = 242;

0 commit comments

Comments
 (0)