attackmap-analyzer-php-web
Broad PHP web analyzer for AttackMap.
This repository is intentionally separate from AttackMap core. It focuses only on extracting structured signals from PHP repositories:
- routes
- outbound HTTP calls
- datastore hints
- auth hints
- secret and env usage
It does not render reports and does not own global severity policy.
Analyzer identity
name:php-webdisplay_name:PHP Web Analyzerversion:0.1.0experimental:trueenabled_by_default:false
Scope
This analyzer is broad and heuristic. It is meant to map common PHP web application surfaces before framework-specific analyzers (for example php-laminas or omeka-s) are added.
Detection strategy
detect(repo_path) uses lightweight signals:
composer.jsonpresent, or- at least one
.phpfile outsidevendor/(and the other shared skip dirs)
A src/, app/ or config/ directory on its own is not enough, since Python, Go and Java repos have those too.
Extraction strategy
analyze(repo_path) scans .php files and emits structured signals using regular-expression heuristics.
Route extraction currently includes patterns such as:
- Laravel
Route::get|post|put|patch|delete|options|head|any(...), array-firstRoute::match(['get', 'post'], ...), and a scope chained before the verb (Route::middleware('auth')->get(...)).Route::resource/apiResource/resources/apiResourcesexpand to their REST routes (7 / 5 actions;updateisPUTandPATCH), honouring->only()/->except()/->shallow(), an['only' => ...]options array and nestedphotos.commentsnames. - Laravel groups:
Route::prefix('admin')->middleware(...)->group(function () { ... })andRoute::group(['prefix' => ..., 'middleware' => ...], fn)join their prefixes onto the routes inside, at any nesting depth up to 32.Route::controller(C::class)->group(...)dispatches bare method names toC. - Laravel route files take the prefix and middleware of the group that loads them:
->group(base_path('routes/admin.php')),require base_path(...)/$this->loadRoutesFrom(__DIR__.'/...')inside a group, andwithRouting(api: ... | [...], apiPrefix: ...)inbootstrap/app.php.routes/api.phpdefaults to/apiwhen nothing outside test code mounts it. Arequire_oncethat loops back to a file already being loaded is a no-op. Aconfig('file.key')prefix is read fromconfig/file.php(a literal or anenv()default), and any other non-literal prefix becomes a{prefix}segment. $app->get('/path', ...)/$app->map(['GET', 'POST'], '/path', ...)Slim calls. The path must start with/, and the receiver must be$app,$router,$route,$groupor$r, a variable assigned fromAppFactory::create()/new RouteCollector/new App, or a parameter typedRouteCollectorProxy/RouteCollector/App. This keeps$request->get('id')and$cache->get('k')out. Slim$app->group('/v1', ...)and Lumen$router->group(['prefix' => 'api'], ...)prefixes are joined.- Symfony
#[Route('/path', methods: ['GET'])](orpath:) attributes, joined onto the class-level#[Route('/prefix')](whosemethodsmerge in). A class-level route is a route of its own only on a controller with no routed actions (__invoke). - Symfony route config, loaded in the kernel's order (
config/routes/*.yamlsorted, thenconfig/routes.yaml; plus Symfony 2/3'sapp/config/routing.yml; other files only when imported):path/methodsentries, andresourceimports with aprefix, applied to attribute controllers under the imported directory (orrouting.controllers, i.e.src/) or to an imported local route file. A later import of the same controllers or route file with the samename_prefixreplaces the earlier one (Symfony keys routes by name), so each route is reported once per distinct name prefix, under the last import's prefix. A localized prefix map becomes a{prefix}segment. Localized path maps andwhen@dev/when@testblocks are skipped. - config-style
"path" => "/...", only in files that also declare a'routes'/'router'key (so Laravel'sconfig/logging.phppaths aren't routes)
Brackets are matched in one string-, comment- and heredoc-aware pass per file, so a commented-out Route::get(...) is not a route and a } inside a string doesn't end a group.
Each route carries auth, guards and guard_evidence (AttackMap#256):
| State | When |
|---|---|
required |
Laravel ->middleware('auth'…) on the route, an enclosing Route::middleware([...])->group(...) / Route::group(['middleware' => ...], ...), or the controller's $this->middleware('auth') (honouring ->only() / ->except()); Slim ->add($authMiddleware) / ->add(new JwtAuthentication(...)) on the route or an enclosing ->group(...); Symfony #[IsGranted] / #[Security] on the action or its class, or a matching security.yaml access_control rule |
anonymous |
Laravel ->withoutMiddleware('auth') on the route or a group, or a controller ->except([...]) naming the action; Symfony #[IsGranted('PUBLIC_ACCESS')] or an access_control rule granting PUBLIC_ACCESS — when nothing else requires auth |
unknown |
anything else |
access_control is only applied to rules with literal ^/prefix paths. A rule with ips, host, allow_if or a regex path stops resolution for the routes after it. Rules are matched against the full path (class and import prefixes joined); attribute routes under an import prefix that can't be read (a localized prefix map) are skipped. Laravel 11 HasMiddleware::middleware() controllers, Slim app-wide $app->add(...) and can: middleware aren't resolved.
Outbound calls currently include patterns such as:
curl_init("https://...")file_get_contents("https://...")- common HTTP client calls such as
->request(...),->get(...),->post(...)
Datastore/auth/secret hints are similarly heuristic and intended as first-pass signals. Secret hints are env var names (getenv, $_ENV, $_SERVER) containing SECRET, TOKEN, KEY, PASSWORD or PASSWD. DB_HOST-style connection settings are not secrets. jwt needs a JWT library (Firebase\JWT\JWT, JWT::decode/encode, Lcobucci\JWT, tymon/jwt-auth), and auth needs the Auth:: facade or a chained auth()->… helper.
Installation
uv tool install attackmap --with attackmap-analyzer-php-web \
--index mlaify=https://pkg.mlaify.io/pypi/simple/ --index-strategy first-index
# or from source:
pip install git+https://github.com/mlaify/attackmap-analyzer-php-web.git
For local development:
pip install -e .[dev]
Contract alignment with AttackMap core
This package targets the current AttackMap analyzer contract:
- analyzer exposes metadata via
metadata - analyzer implements
detect(repo_path)andanalyze(repo_path) analyzereturns AttackMap-style structured scan data (ScanResultshape)
The package includes a small compatibility layer so tests can run even if AttackMap core is not installed.
Future core discovery (documented, not implemented here)
AttackMap core can discover this analyzer later via one of these options:
- entry points (preferred long-term)
- explicit configured analyzer list
- namespace/package scanning in
github.com/mlaify
This repository does not implement core-side discovery logic.
Limitations
- regex-based extraction (not AST)
- limited config route parsing; the Symfony YAML/XML readers cover the shapes Symfony's docs and recipes use, not full YAML/XML
- Laravel route names (
->name()/'as'),Route::view/Route::redirect/Route::singleton, and resource->parameters([...])renames aren't modelled - no framework-specific deep parsing yet
- no dataflow or reachability modeling inside this analyzer
These are deliberate to keep this first external analyzer incremental and maintainable.
Metadata
Release files for attackmap-analyzer-php-web 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| attackmap_analyzer_php_web-0.2.0.tar.gz | 53.3 kB | With provenance | Details for attackmap_analyzer_php_web-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| attackmap_analyzer_php_web-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for attackmap_analyzer_php_web-0.2.0-py3-none-any.whl |
Total release size: 91.9 kB
Release files / attackmap_analyzer_php_web-0.2.0.tar.gz
| Download URL | attackmap_analyzer_php_web-0.2.0.tar.gz |
|---|---|
| Size | 53.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68519574c4e224afc42f583f2a5a861720258f676559d8662ad04f70eb2d21c8
|
|
BLAKE2b-256 checksum How to use checksums |
329fa38cb2c7e41f3e3abef8db99fcb7e089190c458555acbbf9a378609ec85f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / attackmap_analyzer_php_web-0.2.0-py3-none-any.whl
| Download URL | attackmap_analyzer_php_web-0.2.0-py3-none-any.whl |
|---|---|
| Size | 38.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
23efd3a583855b5303d0e386fb2042e6f5a5bdd705399072c28367609d8e02d5
|
|
BLAKE2b-256 checksum How to use checksums |
9ceee02fcd427d9666da53dc8ccc1edc42c2a16a977f4319dc24c2ad98d921fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for attackmap-analyzer-php-web 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for attackmap_analyzer_php_web-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.