attackmap-analyzer-node-service 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. attackmap_analyzer_node_service-0.3.0/LICENSE +21 -0
  2. attackmap_analyzer_node_service-0.3.0/PKG-INFO +104 -0
  3. attackmap_analyzer_node_service-0.3.0/README.md +65 -0
  4. attackmap_analyzer_node_service-0.3.0/pyproject.toml +74 -0
  5. attackmap_analyzer_node_service-0.3.0/setup.cfg +4 -0
  6. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service/__init__.py +3 -0
  7. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service/analyzer.py +1149 -0
  8. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service/modules.py +366 -0
  9. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service/route_auth.py +1553 -0
  10. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service.egg-info/PKG-INFO +104 -0
  11. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service.egg-info/SOURCES.txt +16 -0
  12. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service.egg-info/dependency_links.txt +1 -0
  13. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service.egg-info/entry_points.txt +2 -0
  14. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service.egg-info/requires.txt +9 -0
  15. attackmap_analyzer_node_service-0.3.0/src/attackmap_analyzer_node_service.egg-info/top_level.txt +1 -0
  16. attackmap_analyzer_node_service-0.3.0/tests/test_mounts.py +689 -0
  17. attackmap_analyzer_node_service-0.3.0/tests/test_node_service_analyzer.py +578 -0
  18. attackmap_analyzer_node_service-0.3.0/tests/test_signal_conformance.py +92 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matthew Davis and AttackMap Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: attackmap-analyzer-node-service
3
+ Version: 0.3.0
4
+ Summary: Broad Node.js/TypeScript service analyzer plugin for AttackMap
5
+ Author: AttackMap Contributors
6
+ Author-email: Matthew Davis <mlaify@mlaify.io>
7
+ Maintainer-email: Matthew Davis <mlaify@mlaify.io>
8
+ License-Expression: MIT
9
+ Project-URL: Homepage, https://github.com/mlaify/attackmap-analyzer-node-service
10
+ Project-URL: Repository, https://github.com/mlaify/attackmap-analyzer-node-service
11
+ Project-URL: Issues, https://github.com/mlaify/attackmap-analyzer-node-service/issues
12
+ Project-URL: Changelog, https://github.com/mlaify/attackmap-analyzer-node-service/blob/main/CHANGELOG.md
13
+ Project-URL: AttackMap core, https://github.com/mlaify/AttackMap
14
+ Keywords: security,static-analysis,appsec,defensive-security,attackmap,attackmap-plugin
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Information Technology
18
+ Classifier: Intended Audience :: System Administrators
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3 :: Only
25
+ Classifier: Topic :: Security
26
+ Classifier: Topic :: Software Development :: Quality Assurance
27
+ Classifier: Typing :: Typed
28
+ Requires-Python: >=3.11
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE
31
+ Requires-Dist: pydantic>=2.7.0
32
+ Provides-Extra: core
33
+ Requires-Dist: attackmap>=0.6.0; extra == "core"
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
36
+ Requires-Dist: build>=1.2.0; extra == "dev"
37
+ Requires-Dist: attackmap>=0.6.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # AttackMap Node Service Analyzer
41
+
42
+ > [!IMPORTANT]
43
+ > **Active development, slow pace.** AttackMap is under active development, but
44
+ > progress may be slow until more contributors or co-maintainers join. Help is
45
+ > very welcome with the core engine, an analyzer, the macOS app, or the docs —
46
+ > see [CONTRIBUTING.md](CONTRIBUTING.md) or open an issue on
47
+ > [mlaify/AttackMap](https://github.com/mlaify/AttackMap/issues) to say hello.
48
+ > Security reports are still welcome at [security@mlaify.io](mailto:security@mlaify.io).
49
+
50
+ `attackmap-analyzer-node-service` is a broad Node.js/TypeScript backend analyzer module for AttackMap.
51
+
52
+ It is designed for distributed service repositories and emits structured scan signals for:
53
+ - service identity and role hints
54
+ - route and handler registration hints
55
+ - outbound HTTP and env-configured service URLs
56
+ - datastore and storage usage hints
57
+ - auth/signing/token hints
58
+ - lightweight inter-service edge hints
59
+
60
+ This analyzer is intentionally heuristic and incremental. It is not Bluesky-specific.
61
+
62
+ ### Mount paths (#4)
63
+
64
+ Routes carry the prefixes of every router mount above them, across files:
65
+
66
+ - Express / Koa `X.use('/prefix', [mw...,] router)`, Hono `X.route('/prefix', sub)` and `X.basePath('/prefix')`, Elysia `new Elysia({ prefix })` and `X.group('/prefix', (g) => ...)`, Koa `new Router({ prefix })`, and Fastify `X.register(plugin, { prefix })` (ignored for `fastify-plugin` wrapped plugins, as Fastify does);
67
+ - a router mounted at two prefixes gives one route per path, each with its own auth;
68
+ - route functions called with the app (`require('./routes/users')(app)`, `usersRoutes(app)`) register on it;
69
+ - chained calls count like separate statements: `new Hono().use(mw).get('/x', h).route('/y', sub)`;
70
+ - Fastify's full form `X.route({ method, url })` and NestJS `@Controller({ path })` are routes too.
71
+
72
+ Imports are followed through `require(...)` (including inline `app.use('/x', require('./x'))`), default / named / namespace `import`s, barrel re-exports (`export { x } from './x'`, `export * from`), `index` files, `compilerOptions.paths` / `baseUrl` from the nearest `tsconfig.json` / `jsconfig.json` (and relative `extends`), and workspace packages by their `package.json` name. Nothing outside the repo is read. Mounts made in test files are ignored. A router that no visible code mounts keeps its file-local path.
73
+
74
+ ### Route auth (AttackMap#256)
75
+
76
+ Express, Koa, Hono, Elysia, Fastify and NestJS routes carry `auth` (`required` / `anonymous` / `unknown`), `guards` and `guard_evidence`:
77
+
78
+ - **`required`**:
79
+ - route-local auth middleware: `router.post('/x', requireAuth, h)`, arrays, `router.route('/x').post(mw, h)`, and route options `{ preHandler | onRequest | beforeHandle: [...] }`; a registration made only of guards (`app.get('/x', isAuthorized())`) guards that path;
80
+ - an earlier `X.use([path,] mw)`, `X.all('*', mw)`, Fastify `addHook('onRequest' | 'preHandler', mw)` or Elysia `onBeforeHandle(mw)` / `guard({ beforeHandle }, ...)` on the route's router, or on any router that mounts it (with the mount's own middleware);
81
+ - NestJS `@UseGuards(...)` on the method or controller, or a global `useGlobalGuards(...)` / `APP_GUARD`. A metadata-driven role guard (`RolesGuard`, `PermissionsGuard`) counts only next to its `@Roles(...)` / `@Permissions(...)` metadata.
82
+ - **`anonymous`**:
83
+ - a route whose full path is listed in a guard's `.unless({ path: ['/login', ...] })`;
84
+ - a NestJS `@Public()` / `@SkipAuth()` / `@AllowAnonymous()` / `@SetMetadata('isPublic', true)` route, unless a guard is Passport's own `AuthGuard('...')`, which ignores that metadata.
85
+ - **`unknown`**: everything else. That includes `optionalAuth`-style middleware and NestJS `Optional...` guards, `.unless` lists with regexes or other keys, routers mounted somewhere the analyzer can't see, and middleware registered after the route.
86
+
87
+ Middleware counts as a guard by name: authentication (`requireAuth`, `authenticate`, `isAuthenticated`, `ensureLoggedIn`, `passport.authenticate(...)`, `expressjwt(...)`, `jwt(...)`, `verifyToken`, `bearerAuth(...)`, `fastify.authenticate`) or a role / permission check (`requireRole('admin')`, `isAdmin`, `authorize('admin')`, `checkPermissions`, `guard.check([...])`), which stays visible in `guards` for AttackMap's function-level authorization check. An inline hook that calls `request.jwtVerify()` counts too. Rate limiters, body parsers, CORS / CSRF / helmet, `optional` / `skip` / `public` variants and trackers such as `updateAuthenticatedUsers` don't.
88
+
89
+ **Not handled yet:** Next.js `middleware.ts` matchers, NestJS `RouterModule` / `setGlobalPrefix`, and dynamic mount paths (`app.use(prefix, router)` with a variable).
90
+
91
+ ## Install
92
+
93
+ ```bash
94
+ uv tool install attackmap --with attackmap-analyzer-node-service \
95
+ --index mlaify=https://pkg.mlaify.io/pypi/simple/ --index-strategy first-index
96
+ # or from source:
97
+ pip install git+https://github.com/mlaify/attackmap-analyzer-node-service.git
98
+ ```
99
+
100
+ ## Usage
101
+
102
+ ```bash
103
+ attackmap analyze /path/to/repo --module node-service
104
+ ```
@@ -0,0 +1,65 @@
1
+ # AttackMap Node Service Analyzer
2
+
3
+ > [!IMPORTANT]
4
+ > **Active development, slow pace.** AttackMap is under active development, but
5
+ > progress may be slow until more contributors or co-maintainers join. Help is
6
+ > very welcome with the core engine, an analyzer, the macOS app, or the docs —
7
+ > see [CONTRIBUTING.md](CONTRIBUTING.md) or open an issue on
8
+ > [mlaify/AttackMap](https://github.com/mlaify/AttackMap/issues) to say hello.
9
+ > Security reports are still welcome at [security@mlaify.io](mailto:security@mlaify.io).
10
+
11
+ `attackmap-analyzer-node-service` is a broad Node.js/TypeScript backend analyzer module for AttackMap.
12
+
13
+ It is designed for distributed service repositories and emits structured scan signals for:
14
+ - service identity and role hints
15
+ - route and handler registration hints
16
+ - outbound HTTP and env-configured service URLs
17
+ - datastore and storage usage hints
18
+ - auth/signing/token hints
19
+ - lightweight inter-service edge hints
20
+
21
+ This analyzer is intentionally heuristic and incremental. It is not Bluesky-specific.
22
+
23
+ ### Mount paths (#4)
24
+
25
+ Routes carry the prefixes of every router mount above them, across files:
26
+
27
+ - Express / Koa `X.use('/prefix', [mw...,] router)`, Hono `X.route('/prefix', sub)` and `X.basePath('/prefix')`, Elysia `new Elysia({ prefix })` and `X.group('/prefix', (g) => ...)`, Koa `new Router({ prefix })`, and Fastify `X.register(plugin, { prefix })` (ignored for `fastify-plugin` wrapped plugins, as Fastify does);
28
+ - a router mounted at two prefixes gives one route per path, each with its own auth;
29
+ - route functions called with the app (`require('./routes/users')(app)`, `usersRoutes(app)`) register on it;
30
+ - chained calls count like separate statements: `new Hono().use(mw).get('/x', h).route('/y', sub)`;
31
+ - Fastify's full form `X.route({ method, url })` and NestJS `@Controller({ path })` are routes too.
32
+
33
+ Imports are followed through `require(...)` (including inline `app.use('/x', require('./x'))`), default / named / namespace `import`s, barrel re-exports (`export { x } from './x'`, `export * from`), `index` files, `compilerOptions.paths` / `baseUrl` from the nearest `tsconfig.json` / `jsconfig.json` (and relative `extends`), and workspace packages by their `package.json` name. Nothing outside the repo is read. Mounts made in test files are ignored. A router that no visible code mounts keeps its file-local path.
34
+
35
+ ### Route auth (AttackMap#256)
36
+
37
+ Express, Koa, Hono, Elysia, Fastify and NestJS routes carry `auth` (`required` / `anonymous` / `unknown`), `guards` and `guard_evidence`:
38
+
39
+ - **`required`**:
40
+ - route-local auth middleware: `router.post('/x', requireAuth, h)`, arrays, `router.route('/x').post(mw, h)`, and route options `{ preHandler | onRequest | beforeHandle: [...] }`; a registration made only of guards (`app.get('/x', isAuthorized())`) guards that path;
41
+ - an earlier `X.use([path,] mw)`, `X.all('*', mw)`, Fastify `addHook('onRequest' | 'preHandler', mw)` or Elysia `onBeforeHandle(mw)` / `guard({ beforeHandle }, ...)` on the route's router, or on any router that mounts it (with the mount's own middleware);
42
+ - NestJS `@UseGuards(...)` on the method or controller, or a global `useGlobalGuards(...)` / `APP_GUARD`. A metadata-driven role guard (`RolesGuard`, `PermissionsGuard`) counts only next to its `@Roles(...)` / `@Permissions(...)` metadata.
43
+ - **`anonymous`**:
44
+ - a route whose full path is listed in a guard's `.unless({ path: ['/login', ...] })`;
45
+ - a NestJS `@Public()` / `@SkipAuth()` / `@AllowAnonymous()` / `@SetMetadata('isPublic', true)` route, unless a guard is Passport's own `AuthGuard('...')`, which ignores that metadata.
46
+ - **`unknown`**: everything else. That includes `optionalAuth`-style middleware and NestJS `Optional...` guards, `.unless` lists with regexes or other keys, routers mounted somewhere the analyzer can't see, and middleware registered after the route.
47
+
48
+ Middleware counts as a guard by name: authentication (`requireAuth`, `authenticate`, `isAuthenticated`, `ensureLoggedIn`, `passport.authenticate(...)`, `expressjwt(...)`, `jwt(...)`, `verifyToken`, `bearerAuth(...)`, `fastify.authenticate`) or a role / permission check (`requireRole('admin')`, `isAdmin`, `authorize('admin')`, `checkPermissions`, `guard.check([...])`), which stays visible in `guards` for AttackMap's function-level authorization check. An inline hook that calls `request.jwtVerify()` counts too. Rate limiters, body parsers, CORS / CSRF / helmet, `optional` / `skip` / `public` variants and trackers such as `updateAuthenticatedUsers` don't.
49
+
50
+ **Not handled yet:** Next.js `middleware.ts` matchers, NestJS `RouterModule` / `setGlobalPrefix`, and dynamic mount paths (`app.use(prefix, router)` with a variable).
51
+
52
+ ## Install
53
+
54
+ ```bash
55
+ uv tool install attackmap --with attackmap-analyzer-node-service \
56
+ --index mlaify=https://pkg.mlaify.io/pypi/simple/ --index-strategy first-index
57
+ # or from source:
58
+ pip install git+https://github.com/mlaify/attackmap-analyzer-node-service.git
59
+ ```
60
+
61
+ ## Usage
62
+
63
+ ```bash
64
+ attackmap analyze /path/to/repo --module node-service
65
+ ```
@@ -0,0 +1,74 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "attackmap-analyzer-node-service"
7
+ version = "0.3.0"
8
+ description = "Broad Node.js/TypeScript service analyzer plugin for AttackMap"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ {name = "Matthew Davis", email = "mlaify@mlaify.io"},
15
+ {name = "AttackMap Contributors"},
16
+ ]
17
+ maintainers = [
18
+ {name = "Matthew Davis", email = "mlaify@mlaify.io"},
19
+ ]
20
+ keywords = [
21
+ "security",
22
+ "static-analysis",
23
+ "appsec",
24
+ "defensive-security",
25
+ "attackmap",
26
+ "attackmap-plugin",
27
+ ]
28
+ classifiers = [
29
+ "Development Status :: 4 - Beta",
30
+ "Intended Audience :: Developers",
31
+ "Intended Audience :: Information Technology",
32
+ "Intended Audience :: System Administrators",
33
+ "Operating System :: OS Independent",
34
+ "Programming Language :: Python :: 3",
35
+ "Programming Language :: Python :: 3.11",
36
+ "Programming Language :: Python :: 3.12",
37
+ "Programming Language :: Python :: 3.13",
38
+ "Programming Language :: Python :: 3 :: Only",
39
+ "Topic :: Security",
40
+ "Topic :: Software Development :: Quality Assurance",
41
+ "Typing :: Typed",
42
+ ]
43
+ dependencies = [
44
+ "pydantic>=2.7.0",
45
+ ]
46
+
47
+ [project.optional-dependencies]
48
+ core = [
49
+ "attackmap>=0.6.0",
50
+ ]
51
+ dev = [
52
+ "pytest>=8.0.0",
53
+ "build>=1.2.0",
54
+ "attackmap>=0.6.0",
55
+ ]
56
+
57
+ [project.urls]
58
+ Homepage = "https://github.com/mlaify/attackmap-analyzer-node-service"
59
+ Repository = "https://github.com/mlaify/attackmap-analyzer-node-service"
60
+ Issues = "https://github.com/mlaify/attackmap-analyzer-node-service/issues"
61
+ Changelog = "https://github.com/mlaify/attackmap-analyzer-node-service/blob/main/CHANGELOG.md"
62
+ "AttackMap core" = "https://github.com/mlaify/AttackMap"
63
+
64
+ [project.entry-points."attackmap.analyzers"]
65
+ node_service = "attackmap_analyzer_node_service:NodeServiceAnalyzer"
66
+
67
+ [tool.setuptools]
68
+ package-dir = {"" = "src"}
69
+
70
+ [tool.setuptools.packages.find]
71
+ where = ["src"]
72
+
73
+ [tool.pytest.ini_options]
74
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from .analyzer import NodeServiceAnalyzer
2
+
3
+ __all__ = ["NodeServiceAnalyzer"]