Skip to content

Commit 4f40c7c

Browse files
authored
Merge pull request #66 from Onboardbase/post-sdk-updates
feat: 3.0.17
2 parents 681f0a9 + fd3bdf7 commit 4f40c7c

File tree

6 files changed

+219
-1
lines changed

6 files changed

+219
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "securelog-scan",
3-
"version": "3.0.16",
3+
"version": "3.0.17",
44
"description": "A CLI tool to scan codebases for potential secrets.",
55
"main": "dist/index.js",
66
"author": {

src/detectors/detectors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { DiscordWebhookDetector } from "./discordwebhook";
2626
import { DisqusDetector } from "./disqus";
2727
import { DocusignDetector } from "./docusign";
2828
import { DropboxDetector } from "./dropbox";
29+
import { FacebookOAuthDetector } from "./facebookoauth";
2930
import { FlickrDetector } from "./flickr";
3031
import { FlutterwaveDetector } from "./flutterwave";
3132
import { FormBucketDetector } from "./formbucket";
@@ -55,10 +56,13 @@ import { PostgreSQLDetector } from "./postgres";
5556
import { PostmanDetector } from "./postman";
5657
import { RedisDetector } from "./redis";
5758
import { SendgridDetector } from "./sendgrid";
59+
import { SentryDetector } from "./sentry";
60+
import { ShopifyDetector } from "./shopify";
5861
import { SlackDetector } from "./slack";
5962
import { SlackWebhooksDetector } from "./slackwebhook";
6063
import { StripeDetector } from "./stripe";
6164
import { TelegramBotTokenDetector } from "./telegrambottoken";
65+
import { VercelDetector } from "./vercel";
6266

6367
export const detectors: Detector[] = [
6468
AgoraDetector,
@@ -121,4 +125,8 @@ export const detectors: Detector[] = [
121125
DatadogTokenDetector,
122126
TelegramBotTokenDetector,
123127
CreditCardDetector,
128+
VercelDetector,
129+
FacebookOAuthDetector,
130+
ShopifyDetector,
131+
SentryDetector,
124132
];
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import Re2 from "re2";
2+
import { surroundWithGroups } from "../../regexHandler";
3+
import { Detector, ScanResult } from "../../types/detector";
4+
import { httpClient } from "../../util";
5+
6+
const keywords: string[] = ["facebook", "meta"];
7+
const regexGroup: string = surroundWithGroups(keywords);
8+
const secretPattern: Re2 = new Re2(
9+
`${regexGroup}\\b([A-Za-z0-9]{32})\\b`,
10+
"gi"
11+
);
12+
const idPattern: Re2 = new Re2(`${regexGroup}\\b([0-9]{15,18})\\b`, "gi");
13+
14+
const scan = async (
15+
verify: boolean | undefined,
16+
data: string
17+
): Promise<ScanResult | null> => {
18+
const secretPatternMatches = data.matchAll(secretPattern);
19+
const idPatternMatches = data.matchAll(idPattern);
20+
let result: ScanResult = { detectorType: "Facebook OAuth", verified: false };
21+
22+
for (const match of idPatternMatches) {
23+
if (match.length !== 2) continue;
24+
const idMatch = match[1].trim();
25+
26+
result.rawValue = idMatch;
27+
result.position = match.index;
28+
29+
for (const secretMatch of secretPatternMatches) {
30+
if (secretMatch.length !== 2) continue;
31+
32+
const secretMatchValue = secretMatch[1].trim();
33+
if (verify) {
34+
try {
35+
await httpClient.get(
36+
`https://graph.facebook.com/me?access_token=${idMatch}|${secretMatchValue}`
37+
);
38+
39+
result.verified = true;
40+
} catch (error) {}
41+
}
42+
return result;
43+
}
44+
}
45+
46+
return null;
47+
};
48+
49+
const detectorType = "FACEBOOK_OAUTH_DETECTOR";
50+
51+
export const FacebookOAuthDetector: Detector = {
52+
scan,
53+
keywords,
54+
detectorType,
55+
};

src/detectors/sentry/index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import Re2 from "re2";
2+
import { Detector, ScanResult } from "../../types/detector";
3+
import { surroundWithGroups } from "../../regexHandler";
4+
import { httpClient } from "../../util";
5+
6+
const keywords: string[] = ["sentry"];
7+
const keyPattern: Re2 = new Re2(
8+
`${surroundWithGroups(keywords)}\\b([a-f0-9]{64})\\b`,
9+
"gi"
10+
);
11+
12+
const scan = async (
13+
verify: boolean | undefined,
14+
data: string
15+
): Promise<ScanResult | null> => {
16+
const keyPatternMatches = data.matchAll(keyPattern);
17+
18+
const result: ScanResult = { detectorType: "Sentry", verified: false };
19+
20+
for (const match of keyPatternMatches) {
21+
if (match.length !== 2) continue;
22+
23+
const resMatch: string = match[1].trim();
24+
result.rawValue = resMatch;
25+
result.position = match.index;
26+
27+
if (verify) {
28+
try {
29+
await httpClient.get("https://api.vercel.com/www/user", {
30+
headers: {
31+
Authorization: `Bearer ${resMatch}`,
32+
},
33+
});
34+
35+
result.verified = true;
36+
} catch (error) {}
37+
}
38+
39+
return result;
40+
}
41+
42+
return null;
43+
};
44+
45+
const detectorType = "SENTRY_DETECTOR";
46+
47+
export const SentryDetector: Detector = {
48+
scan,
49+
keywords,
50+
detectorType,
51+
};

src/detectors/shopify/index.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Re2 from "re2";
2+
import { Detector, ScanResult } from "../../types/detector";
3+
import { httpClient } from "../../util";
4+
5+
const keywords: string[] = ["shppa_", "shpat_"];
6+
const keyPattern: Re2 = new Re2("\\b(shppa_|shpat_)([0-9A-Fa-f]{32})\\b", "gi");
7+
const domainPattern = new Re2(/^[a-zA-Z0-9-]+\.myshopify\.com$/, "gi");
8+
9+
const scan = async (
10+
verify: boolean | undefined,
11+
data: string
12+
): Promise<ScanResult | null> => {
13+
const keyPatternMatches = data.matchAll(keyPattern);
14+
const domainPatternMatches = data.matchAll(domainPattern);
15+
let result: ScanResult = { detectorType: "Shopify", verified: false };
16+
17+
for (const match of keyPatternMatches) {
18+
const shopifyKey = match?.[0]?.trim();
19+
20+
result.rawValue = shopifyKey;
21+
result.position = match.index;
22+
23+
for (const domainMatch of domainPatternMatches) {
24+
const domainMatchValue = domainMatch?.[0]?.trim();
25+
26+
if (verify) {
27+
try {
28+
await httpClient.get(
29+
`https://${domainMatchValue}/admin/oauth/access_scopes.json`,
30+
{
31+
headers: {
32+
"X-Shopify-Access-Token": shopifyKey,
33+
},
34+
}
35+
);
36+
37+
result.verified = true;
38+
} catch (error) {}
39+
}
40+
return result;
41+
}
42+
}
43+
44+
return null;
45+
};
46+
47+
const detectorType = "SHOPIFY_DETECTOR";
48+
49+
export const ShopifyDetector: Detector = {
50+
scan,
51+
keywords,
52+
detectorType,
53+
};

src/detectors/vercel/index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import Re2 from "re2";
2+
import { Detector, ScanResult } from "../../types/detector";
3+
import { surroundWithGroups } from "../../regexHandler";
4+
import { httpClient } from "../../util";
5+
6+
const keywords: string[] = ["vercel"];
7+
const keyPattern: Re2 = new Re2(
8+
`${surroundWithGroups(keywords)}\\b([a-zA-Z0-9]{24})\\b`,
9+
"gi"
10+
);
11+
12+
const scan = async (
13+
verify: boolean | undefined,
14+
data: string
15+
): Promise<ScanResult | null> => {
16+
const keyPatternMatches = data.matchAll(keyPattern);
17+
18+
const result: ScanResult = { detectorType: "Vercel", verified: false };
19+
20+
for (const match of keyPatternMatches) {
21+
if (match.length !== 2) continue;
22+
23+
const resMatch: string = match[1].trim();
24+
result.rawValue = resMatch;
25+
result.position = match.index;
26+
27+
if (verify) {
28+
try {
29+
await httpClient.get("https://api.vercel.com/www/user", {
30+
headers: {
31+
Authorization: `Bearer ${resMatch}`,
32+
},
33+
});
34+
35+
result.verified = true;
36+
} catch (error) {}
37+
}
38+
39+
return result;
40+
}
41+
42+
return null;
43+
};
44+
45+
const detectorType = "VERCEL_DETECTOR";
46+
47+
export const VercelDetector: Detector = {
48+
scan,
49+
keywords,
50+
detectorType,
51+
};

0 commit comments

Comments
 (0)