tommykivits / statamic-spam-sentry
Spam Sentry adds a smart validator to form fields in your Statamic site.
Package info
github.com/tommykivits/statamic-spam-sentry
pkg:composer/tommykivits/statamic-spam-sentry
Requires
- php: ^8.3
- statamic/cms: ^6.0
Requires (Dev)
- finetic/coding-standard: ^4.0
README
Spam Sentry adds a smart validator to form fields in your Statamic site. Input is automatically checked against a comprehensive, up-to-date list of known spam terms. Easily extend it with your own blacklist or whitelist entries via simple configuration. Includes per-IP reputation checks via AbuseIPDB and logging of detected spam.
Features
- Text Spam Checking: Automatically validates form input against a large list of known spam words.
- Custom Blacklist/Whitelist: Add your own words or regex patterns to the blacklist, or allow specific words via the whitelist.
- IP Reputation: Check the submitter's IP address against the AbuseIPDB database.
- Logging: All detected spam (both words and IP matches) are logged to your Laravel logs and a dedicated Spam Log in the Statamic Control Panel.
- Spam Log Utility: Easily view and manage blocked submissions directly from the Statamic Control Panel.
- Caching: IP reputation checks are cached for 28 days to minimize API calls.
Installation
Install the addon via Composer:
composer require tommykivits/statamic-spam-sentry
The addon will automatically publish its assets and configuration upon installation.
Features & Usage
Text Spam Checking
To use the spam validator on a form field, add the NoKnowSpam rule to your field's validation rules in the blueprint:
# In your blueprint YAML sections: main: display: Main fields: - handle: message field: type: textarea display: Message validate: - required - 'new \Tommykivits\SpamSentry\Rules\NoKnowSpam()'
IP Reputation
Spam Sentry can check the submitter's IP address against the AbuseIPDB database. If an IP is found to be abusive, the submission will be blocked automatically.
Add your AbuseIPDB API Key to your .env file:
ABUSEIPDB_API_KEY=your_api_key_here
Spam Log
All detected spam is recorded in a dedicated log. You can access this log in the Statamic Control Panel under Utilities > Spam Sentry. It provides a clear overview of:
- Time: When the spam was detected.
- Type: Whether it was a word match or an IP match.
- Message: The reason for blocking.
- IP Address: The sender's IP.
- Path: The URL where the submission occurred.
Configuration
Settings
You can manage the following settings in the Statamic Control Panel under Settings > Spam Sentry:
- Blocked Words: Add additional words or regular expressions (prefixed with
regex:) to the blacklist. - Allowed Words: Specify words that should always be permitted (whitelist).
- Enable AbuseIPDB: Toggle IP reputation checks on or off.
- Minimum Confidence Score: Set the threshold (0-100) for considering an IP address as abusive.
Advanced Configuration
Optionally, override how long a checked IP's verdict is cached (defaults to 28 days) in your .env:
SPAM_SENTRY_ABUSEIP_CACHE_DAYS=28
The default list of spam words can be found and modified in storage/spamsentry/spam-words.php after installation.