1+ name : Suspicious Comment Detection
2+
3+ on :
4+ issue_comment :
5+ types : [created]
6+ pull_request_review_comment :
7+ types : [created]
8+
9+ jobs :
10+ check_comment :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Check for suspicious patterns
14+ uses : actions/github-script@v6
15+ with :
16+ github-token : ${{ secrets.GITHUB_TOKEN }}
17+ script : |
18+ const comment = context.payload.comment;
19+ const body = comment.body.toLowerCase();
20+ const author = comment.user.login;
21+
22+ // Suspicious patterns
23+ const suspiciousPatterns = [
24+ 'support team',
25+ 'customer service',
26+ 'telegram',
27+ 'whatsapp',
28+ 'contact us',
29+ 'click here',
30+ 'support group',
31+ 't.me/',
32+ 'wa.me/',
33+ 'support chat',
34+ 'live chat',
35+ 'support ticket',
36+ 'ticket id',
37+ 'live support',
38+ 'support line',
39+ 'support agent',
40+ 'support network',
41+ 'dedicated support',
42+ 'personalized assistance',
43+ 'opened for you',
44+ 'kindly talk to',
45+ 'we apologize',
46+ 'live chat with an agent',
47+ 'chat button',
48+ 'dapp portal',
49+ 'decentralized dapp',
50+ 'access the portal',
51+ 'report your request',
52+ 'start a conversation',
53+ 'click the chat',
54+ 'for assistance',
55+ 'reach out to',
56+ 'through the chat',
57+ 'portal',
58+ ];
59+
60+ // Check for external links (excluding common legitimate domains)
61+ const hasExternalLinks = body.includes('http') || body.includes('www');
62+ const hasGithubLinks = body.includes('github.com');
63+ const suspiciousLinks = hasExternalLinks && !hasGithubLinks;
64+
65+ // Check for suspicious patterns
66+ const foundPatterns = suspiciousPatterns.filter(pattern =>
67+ body.includes(pattern)
68+ );
69+
70+ if (foundPatterns.length > 0 || suspiciousLinks) {
71+ // Create a warning comment
72+ const warningMessage = `⚠️ Potential scam detected in comment by ${author}:
73+ - Suspicious patterns found: ${foundPatterns.join(', ')}
74+ ${suspiciousLinks ? '- Contains external links' : ''}
75+
76+ @${context.repo.owner} Please review this comment.`;
77+
78+ await github.rest.issues.createComment({
79+ owner: context.repo.owner,
80+ repo: context.repo.repo,
81+ issue_number: context.payload.issue ? context.payload.issue.number : context.payload.pull_request.number,
82+ body: warningMessage
83+ });
84+
85+ // Add 'potential-scam' label
86+ await github.rest.issues.addLabels({
87+ owner: context.repo.owner,
88+ repo: context.repo.repo,
89+ issue_number: context.payload.issue ? context.payload.issue.number : context.payload.pull_request.number,
90+ labels: ['potential-scam']
91+ });
92+ }
0 commit comments