attackmap-analyzer-python
Comprehensive Python ecosystem analyzer for AttackMap.
This plugin is additive over AttackMap's built-in python-web analyzer. The built-in handles FastAPI / Flask routes via the core scanner; this plugin adds everything else.
- Web frameworks —
- Django routing (
path("users/", ...),path("", ...)→/,re_path(r"^api/...$", ...), legacyurl(...)/patterns(...)) gated byurlpatterns =in the file, with theinclude()graph resolved repo-wide:include("app.urls"),include(module),include((patterns, "app")),include([...])and local pattern lists join their prefix onto every child route (path("api/", include("shop.api_urls"))+orders/<int:pk>/→/api/orders/<int:pk>/) - Django REST Framework routers (
router.register(r'users', UserViewSet), any*Router()), mounted under theirinclude(router.urls)/urlpatterns = router.urlsprefix, and@api_view(['GET', 'POST'])decorators - Starlette
Route("/x", endpoint=h, methods=["GET", "POST"])andWebSocketRoute("/ws/...") - AIOHTTP
app.router.add_get/post/...,add_route("POST", ...),add_view,web.get/post/view(...)helpers andweb.RouteTableDef()decorators (@routes.get("/x"),@routes.view,@routes.route("PATCH", ...)) (gated by aiohttp import) - Sanic
@app.get("/x"),@app.post("/x"),@app.route("/x", methods=[...]),@app.websocket("/ws")(gated by sanic import) - Litestar (and legacy Starlite) handlers at any indentation (
@get(),@post(path="/x"),@route(http_method=[...]),@websocket),Controllerclasses (path = "/users"joined onto each handler) andRouter(path=..., route_handlers=[...])prefixes, including nested routers across files (decorators must be imported from litestar/starlite).guards=[...]on the handler/controller/router sets the route's auth torequired;exclude_from_auth=Truesets it toanonymous - Tornado
Application([(r"/x", Handler), url(r"/y", H)])URL specs paired with the handler class'sget/post/... methods (aWebSocketHandlerisWS);@tornado.web.authenticatedon a method sets its auth torequired - Flask
app.add_url_rule("/x", view_func=...)(additive — built-in covers@app.route)
- Django routing (
- Databases —
- SQLAlchemy
create_engine("postgresql://...")with dialect-aware kind inference (postgresql / mysql / mariadb / sqlite / oracle / sqlserver) - asyncpg / psycopg2-3 / pymysql / motor.motor_asyncio / pymongo / redis.asyncio / aioredis / sqlmodel / tortoise
- boto3 resources/clients for
dynamodbands3 - Django
DATABASESdict insettings.py—ENGINEvalue parsed for the kind
- SQLAlchemy
- Auth packages —
- passlib
CryptContext,passlib.hash.argon2/bcrypt/scrypt - bcrypt standalone (
bcrypt.hashpw,bcrypt.checkpw) - argon2-cffi (
from argon2 import PasswordHasher) - PyJWT / python-jose (
jwt.encode,jwt.decode,jose.jwt) - authlib (
OAuth(...),OAuth2Session(...)) - fastapi-users (
BearerTransport,JWTStrategy) - flask-jwt-extended (
@jwt_required,create_access_token) - django.contrib.auth (
authenticate,make_password) - casbin (
Enforcer)
- passlib
- HTTP clients (external calls) — httpx sync + async, aiohttp.ClientSession, urllib.request.urlopen
- Secrets —
os.environ.get("X")andos.environ["X"]with secret-shaped names (built-in only coversos.getenv)- pydantic-settings
BaseSettingsfield-name extraction (jwt_secret: str = ...) dotenv_values(...)accessors with secret-shaped keys
- Service hints —
[project] namefrompyproject.toml,[tool.poetry] name,name="..."fromsetup.py,[metadata] namefromsetup.cfg, presence ofmanage.py→framework:django, DjangoINSTALLED_APPSthird-party / local apps
All emissions populate AttackMap's Signal v2 fields (line numbers, evidence snippets, confidence) so downstream insights can cite path/to/module.py:NN.
Install
uv tool install attackmap --with attackmap-analyzer-python # from PyPI
# or: pip install attackmap-analyzer-python (installs attackmap too)
# or from source:
pip install git+https://github.com/mlaify/attackmap-analyzer-python.git
The analyzer is auto-discovered by AttackMap via the attackmap.analyzers entry-point group.
Usage with AttackMap
# Auto-discovered when installed:
attackmap analyze /path/to/python/repo
# Or invoke explicitly:
attackmap analyze /path/to/python/repo --module python
Detection
detect() returns true when any of the following are present, ignoring .venv/, venv/, env/, .tox/, __pycache__/, .pytest_cache/, dist/, build/, node_modules/, .git/, .mypy_cache/, .ruff_cache/, and site-packages/:
- A
pyproject.toml,setup.py,setup.cfg,manage.py, orPipfileat the root - Any
.pyfile in the tree
Coverage notes
- Framework-gated extraction: route extractors for AIOHTTP, Sanic, Litestar, and Starlette only fire when the file imports the corresponding framework. This prevents mis-attributing generic
@get(...)/web.get(...)/app.get(...)calls to a framework when they're really custom decorators or method calls. - Django routing requires
urlpatterns =to be in the file. A barepath("/x", ...)in any other context (e.g.,pathlib.Path("/x")is well-behaved, but a project that also hasfrom django.urls import path; path("/x", view)outside a urls.py won't fire — by design). - Django settings extraction: gated by presence of one of
INSTALLED_APPS,DATABASES,MIDDLEWARE, orROOT_URLCONF. Built-in Django apps (django.*) are filtered out of the INSTALLED_APPS service hints to keep signal high. - DRF
@api_view(['GET', 'POST']): emits framework hints (drf_api_view:GET,drf_api_view:POST) rather than routes — the actual path is inurls.py, which is extracted separately. - Django
include()resolution: a module reference resolves only to a URLconf inside the repo (tried from eachmanage.pydirectory, the repo root, then the including file's ancestors). A resolvedinclude()line is a prefix, not an endpoint, so it isn't a route. An include that can't be resolved (a third-party app,include(get_model_urls(...))) is still emitted as its prefix (/accounts/). A pattern list or router nothing mounts keeps the unprefixed emission. A non-literal route (path(settings.BASE_PATH, include(...))) joins as an empty prefix. Regex anchors are stripped when joining, sore_path(r"^users/$")is/users/. A pattern list is the union of everything assigned to it (reassignments, if/else and try/except branches,urlpatterns = wrap(urlpatterns)), so no branch's routes are dropped. The resolver is bounded (5k entries per list, 20k per file, 5k registrations per router, 12 include levels, 64 mounts per list, 200k steps including router registrations, 50k routes) and cycles stop. - Parsing: URLconfs, Litestar, Tornado and Sanic files are read with
ast(never executed). A fileastcan't parse (Python 2, over 1 MB) falls back to the per-file regex extractors. - Not yet: DRF nested routers' parent prefix, zulip-style custom
rest_path(...)wrappers, SanicBlueprint(url_prefix=...)joins (core doesn't join them either, so joining here would duplicate routes), and Django route auth decided at the view (@login_requiredon the view function,LoginRequiredMixin, DRFpermission_classes) — see the issue tracker. Auth wrappers applied in the URLconf itself (login_required(views.x),permission_required("p")(View.as_view()),staff_member_required,user_passes_test) do set the route's auth torequired, and Django 5.1'slogin_not_required(...)sets it toanonymous. - pydantic-settings field extraction matches any class field whose name contains
secret,token,key,password,pass, orpwd. False positives are possible (e.g., a non-secretsigning_keyconfig). Confidence is the standard 0.85.
Coexistence with the built-in python-web analyzer
AttackMap ships with a python-web built-in that handles FastAPI / Flask via the core scanner. When this plugin is installed, both analyzers run on every Python repo. AttackMap's overlay deduplication merges their output so users see a single unified set of findings — no double-counting.
This plugin runs at priority=10. AttackMap runs analyzers in (priority, name) order across built-ins and plugins and merges first-seen-wins, so this plugin runs before the built-in (priority=20) and its richer output wins where they overlap.
License
MIT
Metadata
Release files for attackmap-analyzer-python 0.2.1
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_python-0.2.1.tar.gz | 47.9 kB | With provenance | Details for attackmap_analyzer_python-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| attackmap_analyzer_python-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for attackmap_analyzer_python-0.2.1-py3-none-any.whl |
Total release size: 82.6 kB
Release files / attackmap_analyzer_python-0.2.1.tar.gz
| Download URL | attackmap_analyzer_python-0.2.1.tar.gz |
|---|---|
| Size | 47.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c646caeb9bb7444f4917f03084b6d985c75b9a67b27e61fd8f3c495ba4e5342
|
|
BLAKE2b-256 checksum How to use checksums |
fadc38df1b18823f30945b6e7c35437b98908a787c343a9374e383d56d9b38e3
|
| 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_python-0.2.1-py3-none-any.whl
| Download URL | attackmap_analyzer_python-0.2.1-py3-none-any.whl |
|---|---|
| Size | 34.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49567703ba6ca9d2e6427d1ef1b1f59dbcf72463891de7103d99aa06dc164e30
|
|
BLAKE2b-256 checksum How to use checksums |
257af70e2a0d90a12b83e74f5a5c010626e4398bf2c97e8f70802bdceab0989b
|
| 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-python 0.2.1
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_python-0.2.1.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.