sansec / magento2-module-shield

sansec/magento2-module-shield

magento2-module Compatibility: 2.4.7-2.4.9 Code Quality: Fail Tests: N/A Security: Pass MIT

Sansec Shield

Requires Magento 2.3+, PHP 7.2+ and an eComscan account (Advanced or up).

Installation

composer require sansec/magento2-module-shield
bin/magento setup:upgrade
bin/magento config:set sansec_shield/general/license_key <your license key>
bin/magento sansec:shield:sync-rules

Configuration

You can configure your license key and other settings via System → Configuration → Security → Sansec Shield.

Whitelisted IP addresses

IPs listed under Whitelisted IP Addresses bypass all Shield checks. Matching is performed against the connecting peer (REMOTE_ADDR) only; proxy-forwarded headers such as X-Forwarded-For and CF-Connecting-IP are intentionally ignored because they are client-controlled and can be spoofed.

If your store sits behind a reverse proxy or CDN, configure your webserver to rewrite the trusted proxy header into REMOTE_ADDR (ngx_http_realip_module on nginx, mod_remoteip on Apache). Once REMOTE_ADDR reflects the real client IP, the whitelist will match it correctly.

Testing & live reports

Test it by visiting your store and add ?SANSEC-SHIELD-TEST to your URL, it should give you "permission denied". You'll see your first blocked attack appear instantly on your Shield Dashboard. If you do not want reports, you can disable it with:

bin/magento config:set sansec_shield/general/report_enabled 0

You can always view detailed logs in var/log/sansec_shield.log.

See for FAQs our Shield guide.

Cron

Shield rules update automatically through the standard Magento cron mechanism. If you are running a standard cron setup (bin/magento cron:run), no further action is required.

If you only run specific cron groups (bin/magento cron:run --group <group name>), make sure to include a cron for the sansec group as well.

You can verify Shield rules sync every 5 minutes in var/log/sansec_shield.log.

Upgrading

The Sansec Shield module is deliberately kept stable and there is no need to monitor for updates. If an essential new version is released, we will notify you via email.

To check your current version:

composer show sansec/magento2-module-shield

To upgrade to the latest version:

composer require sansec/magento2-module-shield:^1.0
bin/magento setup:upgrade

Troubleshooting

"Please enable the module and configure the license key"

If you get this error when running bin/magento sansec:shield:sync-rules, even though the license key is already configured, flush the Magento cache:

bin/magento cache:flush

Then retry the sync command.

"There are no commands defined in the sansec:shield namespace"

Run the Magento dependency injection compiler:

bin/magento setup:di:compile

Composer upgrades unrelated packages during installation

Shield's only dependency is magento/framework, so it will not pull in or force any additional upgrades. If you see many packages being upgraded, your vendor/ directory was out of sync with composer.lock. Running composer require synced your vendor directory to match.

To avoid this, revert composer.lock to a version that matches your current vendor directory before installing Shield:

git checkout composer.lock
composer require sansec/magento2-module-shield

If installing via Composer is not an option, you can copy the source files directly into app/code/Sansec/Shield, though you will need to handle updates manually from that point on.

Cron job not running on symlink-based deployments

Magento's cron:install resolves symlinks to their real path, so after a new deployment the crontab still points to the old release directory. Ensure that the crontab uses your stable symlink (e.g. /data/web/current/bin/magento) instead.

License

Sansec Shield is published under the liberal MIT license.

No changelog yet

The vendor hasn't published a changelog. Tagged releases appear in the Versions tab.

Versions
Version Stability QA Status Compatibility Released
1.0.25 stable Fail Magento 2.4.7-2.4.9 Details 2026-05-21 09:38:57
1.0.24 stable Not tested Not yet tested Details 2026-04-23 08:50:31
1.0.23 stable Not tested Not yet tested Details 2026-04-11 13:47:43
1.0.22 stable Not tested Not yet tested Details 2026-03-29 08:58:29
1.0.21 stable Not tested Not yet tested Details 2026-02-12 09:06:51
1.0.20 stable Not tested Not yet tested Details 2025-11-14 09:26:54
1.0.19 stable Not tested Not yet tested Details 2025-10-27 12:47:46
1.0.17 stable Not tested Not yet tested Details 2025-09-16 12:10:52
1.0.18 stable Not tested Not yet tested Details 2025-09-16 12:10:52
1.0.16 stable Not tested Not yet tested Details 2025-08-22 10:03:35
1.0.15 stable Not tested Not yet tested Details 2025-08-22 09:45:05
1.0.14 stable Not tested Not yet tested Details 2025-08-22 09:23:25
1.0.13 stable Not tested Not yet tested Details 2025-08-14 11:37:38
1.0.12 stable Not tested Not yet tested Details 2025-07-24 13:18:49
1.0.11 stable Not tested Not yet tested Details 2025-07-22 18:47:01
1.0.10 stable Not tested Not yet tested Details 2025-07-10 11:58:15
1.0.9 stable Not tested Not yet tested Details 2025-06-30 07:27:17
1.0.8 stable Not tested Not yet tested Details 2025-06-11 19:32:58
1.0.7 stable Not tested Not yet tested Details 2025-05-20 14:22:20
1.0.6 stable Not tested Not yet tested Details 2025-05-05 21:28:21
1.0.5 stable Not tested Not yet tested Details 2025-04-10 13:25:15
1.0.4 stable Not tested Not yet tested Details 2025-04-03 11:51:47
1.0.3 stable Not tested Not yet tested Details 2025-03-31 12:14:46
1.0.2 stable Not tested Not yet tested Details 2025-03-21 09:07:24
1.0.1 stable Not tested Not yet tested Details 2025-03-21 07:51:17
1.0.0 stable Not tested Not yet tested Details 2025-03-20 12:26:42
0.1.19 stable Not tested Not yet tested Details 2025-02-27 09:01:58
0.1.18 stable Not tested Not yet tested Details 2025-02-23 11:41:09
0.1.17 stable Not tested Not yet tested Details 2025-02-20 19:46:17
0.1.16 stable Not tested Not yet tested Details 2025-02-20 13:32:01
0.1.15 stable Not tested Not yet tested Details 2025-02-19 19:52:33
0.1.14 stable Not tested Not yet tested Details 2025-02-15 13:33:14
0.1.13 stable Not tested Not yet tested Details 2025-02-13 20:28:23
0.1.12 stable Not tested Not yet tested Details 2025-02-13 10:14:09
0.1.11 stable Not tested Not yet tested Details 2025-02-10 19:53:12
0.1.10 stable Not tested Not yet tested Details 2025-02-10 19:34:08
0.1.9 stable Not tested Not yet tested Details 2025-02-09 19:00:53
0.1.8 stable Not tested Not yet tested Details 2025-02-09 18:46:44
0.1.7 stable Not tested Not yet tested Details 2025-02-08 13:39:34
0.1.6 stable Not tested Not yet tested Details 2025-02-08 13:17:36
0.1.5 stable Not tested Not yet tested Details 2025-02-07 21:03:05
0.1.4 stable Not tested Not yet tested Details 2025-02-07 20:19:27
0.1.3 stable Not tested Not yet tested Details 2025-02-07 19:06:52
0.1.2 stable Not tested Not yet tested Details 2025-02-07 15:10:46
0.1.0 stable Not tested Not yet tested Details 2025-02-07 14:18:33
0.1.1 stable Not tested Not yet tested Details 2025-02-07 14:18:33

Requires 3

Package Constraint
php >=7.2
magento/framework *
ext-openssl *

Requires-dev 1

Package Constraint
phpunit/phpunit ^8

Compatibility

Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.

Compatibility matrix (Magento × PHP)
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 Pass Pass
2.4.8 Pass Pass
2.4.9 Pass Pass

Code Quality

Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge — a phpcs finding can't make a module incompatible.

Static analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

Static analysis results
Tool Status Findings Summary
PHPCS Fail 93 14 errors, 79 warnings (ruleset: Magento2) — 7 auto-fixable with phpcbf
PHPMD Warning 25 25 rule violations (MissingImport:18, UnusedFormalParameter:6, CyclomaticComplexity:1)
Cpd Warning 2 2 duplicated chunks spanning 52 total lines (min-lines=5, min-tokens=70)
Composer validate Info 3 valid; 3 advisory notes (composer validate --strict)

PHPStan

Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases. Cell → details modal.

PHPStan results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 18 18
2.4.8 18 18
2.4.9 18 18

Tests

Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.

Unit tests

Unit tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Integration tests

Integration tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Security

Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.

Security results
Tool Status Findings Summary
Composer audit Pass 0
Malware scan Pass 0
License
MIT
Make it pay

Turn an existing module into recurring revenue.

If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.