Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 843dd7f056 |
@@ -97,6 +97,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||||||
s1.ExtraData["site_admin"] = fmt.Sprintf("%t", userResponse.SiteAdmin)
|
s1.ExtraData["site_admin"] = fmt.Sprintf("%t", userResponse.SiteAdmin)
|
||||||
s1.ExtraData["name"] = userResponse.Name
|
s1.ExtraData["name"] = userResponse.Name
|
||||||
s1.ExtraData["company"] = userResponse.Company
|
s1.ExtraData["company"] = userResponse.Company
|
||||||
|
s1.ExtraData["scopes"] = res.Header.Get("X-OAuth-Scopes")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
unverifiedGhu := testSecrets.MustGetField("GITHUB_UNVERIFIED_GHU")
|
unverifiedGhu := testSecrets.MustGetField("GITHUB_UNVERIFIED_GHU")
|
||||||
unverifiedGhs := testSecrets.MustGetField("GITHUB_UNVERIFIED_GHS")
|
unverifiedGhs := testSecrets.MustGetField("GITHUB_UNVERIFIED_GHS")
|
||||||
unverifiedGhr := testSecrets.MustGetField("GITHUB_UNVERIFIED_GHR")
|
unverifiedGhr := testSecrets.MustGetField("GITHUB_UNVERIFIED_GHR")
|
||||||
|
verifiedGhp := testSecrets.MustGetField("GITHUB_VERIFIED_GHP")
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
@@ -41,6 +42,32 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
want []detectors.Result
|
want []detectors.Result
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
name: "found, verified ghp",
|
||||||
|
s: Scanner{},
|
||||||
|
args: args{
|
||||||
|
ctx: context.Background(),
|
||||||
|
data: []byte(fmt.Sprintf("You can find a github secret %s within", verifiedGhp)),
|
||||||
|
verify: true,
|
||||||
|
},
|
||||||
|
want: []detectors.Result{
|
||||||
|
{
|
||||||
|
DetectorType: detectorspb.DetectorType_Github,
|
||||||
|
Verified: true,
|
||||||
|
ExtraData: map[string]string{
|
||||||
|
"account_type": "User",
|
||||||
|
"company": "",
|
||||||
|
"name": "",
|
||||||
|
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||||
|
"scopes": "notifications",
|
||||||
|
"site_admin": "false",
|
||||||
|
"url": "https://github.com/truffle-sandbox",
|
||||||
|
"username": "truffle-sandbox",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "found, unverified ghp",
|
name: "found, unverified ghp",
|
||||||
s: Scanner{},
|
s: Scanner{},
|
||||||
@@ -53,6 +80,9 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
{
|
{
|
||||||
DetectorType: detectorspb.DetectorType_Github,
|
DetectorType: detectorspb.DetectorType_Github,
|
||||||
Verified: false,
|
Verified: false,
|
||||||
|
ExtraData: map[string]string{
|
||||||
|
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@@ -69,6 +99,9 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
{
|
{
|
||||||
DetectorType: detectorspb.DetectorType_Github,
|
DetectorType: detectorspb.DetectorType_Github,
|
||||||
Verified: false,
|
Verified: false,
|
||||||
|
ExtraData: map[string]string{
|
||||||
|
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@@ -85,6 +118,9 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
{
|
{
|
||||||
DetectorType: detectorspb.DetectorType_Github,
|
DetectorType: detectorspb.DetectorType_Github,
|
||||||
Verified: false,
|
Verified: false,
|
||||||
|
ExtraData: map[string]string{
|
||||||
|
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@@ -101,6 +137,9 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
{
|
{
|
||||||
DetectorType: detectorspb.DetectorType_Github,
|
DetectorType: detectorspb.DetectorType_Github,
|
||||||
Verified: false,
|
Verified: false,
|
||||||
|
ExtraData: map[string]string{
|
||||||
|
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@@ -117,6 +156,9 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
{
|
{
|
||||||
DetectorType: detectorspb.DetectorType_Github,
|
DetectorType: detectorspb.DetectorType_Github,
|
||||||
Verified: false,
|
Verified: false,
|
||||||
|
ExtraData: map[string]string{
|
||||||
|
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
@@ -133,6 +175,9 @@ func TestGitHub_FromChunk(t *testing.T) {
|
|||||||
{
|
{
|
||||||
DetectorType: detectorspb.DetectorType_Github,
|
DetectorType: detectorspb.DetectorType_Github,
|
||||||
Verified: false,
|
Verified: false,
|
||||||
|
ExtraData: map[string]string{
|
||||||
|
"rotation_guide": "https://howtorotate.com/docs/tutorials/github/",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ type userRes struct {
|
|||||||
SiteAdmin bool `json:"site_admin"`
|
SiteAdmin bool `json:"site_admin"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Company string `json:"company"`
|
Company string `json:"company"`
|
||||||
|
UserURL string `json:"html_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keywords are used for efficiently pre-filtering chunks.
|
// Keywords are used for efficiently pre-filtering chunks.
|
||||||
@@ -91,6 +92,17 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
|
|||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
s1.Verified = true
|
s1.Verified = true
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
s1.Verified = true
|
||||||
|
s1.ExtraData["username"] = userResponse.Login
|
||||||
|
s1.ExtraData["url"] = userResponse.UserURL
|
||||||
|
s1.ExtraData["account_type"] = userResponse.Type
|
||||||
|
s1.ExtraData["site_admin"] = fmt.Sprintf("%t", userResponse.SiteAdmin)
|
||||||
|
s1.ExtraData["name"] = userResponse.Name
|
||||||
|
s1.ExtraData["company"] = userResponse.Company
|
||||||
|
s1.ExtraData["scopes"] = res.Header.Get("X-OAuth-Scopes")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user