Skip to content

Commit a94d152

Browse files
authored
added token_revoke status condition in slack api detector (#3831)
1 parent 6a4856c commit a94d152

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

pkg/detectors/slack/slack.go

+4
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
102102
// https://api.slack.com/methods/auth.test) (Per
103103
// https://slack.com/help/articles/360000446446-Manage-deactivated-members-apps-and-integrations,
104104
// reactivating a bot regenerates its tokens, so this candidate is determinately unverified.)
105+
} else if authResponse.Error == "token_revoked" {
106+
// "Authentication token is for a deleted user or workspace, or the app has been removed when using a user token."
107+
// This indicates the token is no longer valid and determinately unverified.
108+
// https://api.slack.com/methods/auth.test
105109
} else {
106110
err = fmt.Errorf("unexpected error auth response %+v", authResponse.Error)
107111
s1.SetVerificationError(err, token)

pkg/detectors/slack/slack_integration_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,27 @@ func TestSlack_FromChunk(t *testing.T) {
102102
wantErr: false,
103103
wantVerificationErr: false,
104104
},
105+
{
106+
name: "token_revoked",
107+
s: Scanner{client: common.ConstantResponseHttpClient(200, `{"ok": false, "error": "token_revoked"}`)},
108+
args: args{
109+
ctx: context.Background(),
110+
data: []byte(fmt.Sprintf("You can find a slack secret %s within", secret)),
111+
verify: true,
112+
},
113+
wantResults: []detectors.Result{
114+
{
115+
DetectorType: detectorspb.DetectorType_Slack,
116+
Verified: false,
117+
ExtraData: map[string]string{
118+
"rotation_guide": "https://howtorotate.com/docs/tutorials/slack/",
119+
"token_type": "Slack User Token",
120+
},
121+
},
122+
},
123+
wantErr: false,
124+
wantVerificationErr: false,
125+
},
105126
{
106127
name: "found, would be verified if not for timeout",
107128
s: Scanner{client: common.SaneHttpClientTimeOut(1 * time.Microsecond)},

0 commit comments

Comments
 (0)