Skip to content

[Feature Request] Add isMalicious.com as a data source #2

[Feature Request] Add isMalicious.com as a data source

[Feature Request] Add isMalicious.com as a data source #2

Workflow file for this run

name: Triage Issues
on:
issues:
types: [opened, edited]
permissions:
issues: write
contents: read
jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Extract domain from issue
id: extract
uses: actions/github-script@v7
with:
script: |
const body = context.payload.issue.body || '';
const title = context.payload.issue.title || '';
// Try to extract domain from form field or free text
const domainRegex = /(?:Domain to (?:add|remove)|URL)[:\s]*([a-zA-Z0-9][-a-zA-Z0-9]*(?:\.[a-zA-Z0-9][-a-zA-Z0-9]*)+)/i;
const match = body.match(domainRegex) || title.match(/\[(?:Add|Remove)\]\s*(.+)/i);
if (match) {
const domain = match[1].trim().toLowerCase();
core.setOutput('domain', domain);
core.setOutput('found', 'true');
} else {
core.setOutput('found', 'false');
}
- name: Check domain in lists
if: steps.extract.outputs.found == 'true'
id: check
run: |
DOMAIN="${{ steps.extract.outputs.domain }}"
echo "Checking for domain: $DOMAIN"
# Search for the domain in all .txt files
FOUND_IN=""
for file in *.txt; do
if [ -f "$file" ] && grep -qi "^0\.0\.0\.0 $DOMAIN$\|^$DOMAIN$" "$file" 2>/dev/null; then
LIST_NAME=$(basename "$file" .txt)
if [ -z "$FOUND_IN" ]; then
FOUND_IN="$LIST_NAME"
else
FOUND_IN="$FOUND_IN, $LIST_NAME"
fi
fi
done
if [ -n "$FOUND_IN" ]; then
echo "found_in=$FOUND_IN" >> $GITHUB_OUTPUT
echo "is_present=true" >> $GITHUB_OUTPUT
else
echo "is_present=false" >> $GITHUB_OUTPUT
fi
- name: Add labels and comment
uses: actions/github-script@v7
with:
script: |
const domain = '${{ steps.extract.outputs.domain }}';
const isPresent = '${{ steps.check.outputs.is_present }}' === 'true';
const foundIn = '${{ steps.check.outputs.found_in }}';
const isAddRequest = context.payload.issue.title.toLowerCase().includes('[add]');
const isRemoveRequest = context.payload.issue.title.toLowerCase().includes('[remove]');
let labels = [];
let comment = '';
if (isAddRequest) {
if (isPresent) {
labels.push('duplicate');
comment = `## 🔍 Domain Check Result
The domain \`${domain}\` is **already present** in the following list(s):
- ${foundIn}
This request may be a duplicate. Please verify the domain is not already blocked before proceeding.
If you believe this is a different domain or subdomain, please clarify in a comment.`;
} else {
labels.push('verified-new');
comment = `## ✅ Domain Check Result
The domain \`${domain}\` is **not currently blocked** in any list.
This domain is eligible to be added. A maintainer will review this request.`;
}
labels.push('add-request');
} else if (isRemoveRequest) {
if (isPresent) {
labels.push('verified-exists');
comment = `## 🔍 Domain Check Result
The domain \`${domain}\` was found in the following list(s):
- ${foundIn}
A maintainer will review this removal request.`;
} else {
labels.push('not-found');
comment = `## ❓ Domain Check Result
The domain \`${domain}\` was **not found** in any blocklist.
Please verify the domain spelling or check if it has already been removed.`;
}
labels.push('remove-request');
}
// Add labels
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
}
// Add comment
if (comment) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}