attackmap-analyzer-php-laminas 0.1.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.

Potentially problematic release.


This version of attackmap-analyzer-php-laminas might be problematic. Click here for more details.

@@ -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,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: attackmap-analyzer-php-laminas
3
+ Version: 0.1.0
4
+ Summary: Framework-aware Laminas analyzer plugin for AttackMap
5
+ Author: AttackMap Contributors
6
+ Author-email: Matthew Davis <matthewd@matthewd.xyz>
7
+ Maintainer-email: Matthew Davis <matthewd@matthewd.xyz>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/mlaify/attackmap-analyzer-php-laminas
10
+ Project-URL: Repository, https://github.com/mlaify/attackmap-analyzer-php-laminas
11
+ Project-URL: Issues, https://github.com/mlaify/attackmap-analyzer-php-laminas/issues
12
+ Project-URL: Changelog, https://github.com/mlaify/attackmap-analyzer-php-laminas/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: License :: OSI Approved :: MIT License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3 :: Only
26
+ Classifier: Topic :: Security
27
+ Classifier: Topic :: Software Development :: Quality Assurance
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.11
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: pydantic>=2.7.0
33
+ Provides-Extra: core
34
+ Requires-Dist: attackmap>=0.1.0; extra == "core"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
37
+ Requires-Dist: build>=1.2.0; extra == "dev"
38
+ Requires-Dist: attackmap>=0.1.0; extra == "dev"
39
+ Dynamic: license-file
40
+
41
+ # attackmap-analyzer-php-laminas
42
+
43
+ Framework-aware Laminas analyzer for [AttackMap](https://github.com/mlaify/AttackMap).
44
+
45
+ This module focuses on structured signal extraction for Laminas/Zend MVC projects:
46
+
47
+ - route paths from config arrays
48
+ - controller mapping hints
49
+ - service-manager mapping hints
50
+ - broad PHP security signals (outbound calls, datastore, auth, secret hints)
51
+
52
+ ## Analyzer identity
53
+
54
+ - `name`: `php-laminas`
55
+ - `display_name`: `PHP Laminas Analyzer`
56
+ - `version`: `0.1.0`
57
+ - `experimental`: `true`
58
+ - `enabled_by_default`: `false`
59
+
60
+ ## Detection
61
+
62
+ `detect(repo_path)` returns true when one or more Laminas indicators exist:
63
+
64
+ - composer dependencies beginning with `laminas/` or `zendframework/`
65
+ - `config/application.config.php`
66
+ - any `module.config.php`
67
+ - `module/` directory
68
+
69
+ ## Notes
70
+
71
+ This analyzer is heuristic and intentionally avoids AST parsing in this first iteration.
@@ -0,0 +1,31 @@
1
+ # attackmap-analyzer-php-laminas
2
+
3
+ Framework-aware Laminas analyzer for [AttackMap](https://github.com/mlaify/AttackMap).
4
+
5
+ This module focuses on structured signal extraction for Laminas/Zend MVC projects:
6
+
7
+ - route paths from config arrays
8
+ - controller mapping hints
9
+ - service-manager mapping hints
10
+ - broad PHP security signals (outbound calls, datastore, auth, secret hints)
11
+
12
+ ## Analyzer identity
13
+
14
+ - `name`: `php-laminas`
15
+ - `display_name`: `PHP Laminas Analyzer`
16
+ - `version`: `0.1.0`
17
+ - `experimental`: `true`
18
+ - `enabled_by_default`: `false`
19
+
20
+ ## Detection
21
+
22
+ `detect(repo_path)` returns true when one or more Laminas indicators exist:
23
+
24
+ - composer dependencies beginning with `laminas/` or `zendframework/`
25
+ - `config/application.config.php`
26
+ - any `module.config.php`
27
+ - `module/` directory
28
+
29
+ ## Notes
30
+
31
+ This analyzer is heuristic and intentionally avoids AST parsing in this first iteration.
@@ -0,0 +1,74 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "attackmap-analyzer-php-laminas"
7
+ version = "0.1.0"
8
+ description = "Framework-aware Laminas analyzer plugin for AttackMap"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Matthew Davis", email = "matthewd@matthewd.xyz"},
14
+ {name = "AttackMap Contributors"},
15
+ ]
16
+ maintainers = [
17
+ {name = "Matthew Davis", email = "matthewd@matthewd.xyz"},
18
+ ]
19
+ keywords = [
20
+ "security",
21
+ "static-analysis",
22
+ "appsec",
23
+ "defensive-security",
24
+ "attackmap",
25
+ "attackmap-plugin",
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 4 - Beta",
29
+ "Intended Audience :: Developers",
30
+ "Intended Audience :: Information Technology",
31
+ "Intended Audience :: System Administrators",
32
+ "License :: OSI Approved :: MIT License",
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.1.0",
50
+ ]
51
+ dev = [
52
+ "pytest>=8.0.0",
53
+ "build>=1.2.0",
54
+ "attackmap>=0.1.0",
55
+ ]
56
+
57
+ [project.urls]
58
+ Homepage = "https://github.com/mlaify/attackmap-analyzer-php-laminas"
59
+ Repository = "https://github.com/mlaify/attackmap-analyzer-php-laminas"
60
+ Issues = "https://github.com/mlaify/attackmap-analyzer-php-laminas/issues"
61
+ Changelog = "https://github.com/mlaify/attackmap-analyzer-php-laminas/blob/main/CHANGELOG.md"
62
+ "AttackMap core" = "https://github.com/mlaify/AttackMap"
63
+
64
+ [project.entry-points."attackmap.analyzers"]
65
+ php_laminas = "attackmap_analyzer_php_laminas:PhpLaminasAnalyzer"
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,4 @@
1
+ from .analyzer import PhpLaminasAnalyzer
2
+ from .contracts import AnalyzerMetadata
3
+
4
+ __all__ = ["AnalyzerMetadata", "PhpLaminasAnalyzer"]
@@ -0,0 +1,236 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import re
5
+ from pathlib import Path
6
+
7
+ from .contracts import AnalyzerMetadata, AuthHint, DatabaseHint, ExternalCall, Route, ScanResult, SecretHint
8
+
9
+ LAMINAS_ROUTE_PATTERN = re.compile(r"['\"]route['\"]\s*=>\s*['\"]([^'\"]+)['\"]", re.IGNORECASE)
10
+ LAMINAS_CONTROLLER_PATTERN = re.compile(
11
+ r"([A-Za-z_\\][A-Za-z0-9_\\]*Controller[A-Za-z0-9_\\]*)::class",
12
+ re.IGNORECASE,
13
+ )
14
+ LAMINAS_SERVICE_PATTERN = re.compile(
15
+ r"([A-Za-z_\\][A-Za-z0-9_\\]*(?:Service|Manager|Repository|TableGateway|Adapter)[A-Za-z0-9_\\]*)::class",
16
+ re.IGNORECASE,
17
+ )
18
+
19
+ OUTBOUND_PATTERNS = [
20
+ re.compile(r"curl_init\s*\(\s*['\"](https?://[^'\"]+)['\"]", re.IGNORECASE),
21
+ re.compile(r"file_get_contents\s*\(\s*['\"](https?://[^'\"]+)['\"]", re.IGNORECASE),
22
+ re.compile(r"->request\s*\(\s*['\"](?:GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)['\"]\s*,\s*['\"](https?://[^'\"]+)['\"]", re.IGNORECASE),
23
+ re.compile(r"->(?:get|post|put|patch|delete)\s*\(\s*['\"](https?://[^'\"]+)['\"]", re.IGNORECASE),
24
+ ]
25
+
26
+ DATABASE_PATTERNS = [
27
+ (re.compile(r"\bnew\s+PDO\s*\(", re.IGNORECASE), "sql"),
28
+ (re.compile(r"Doctrine\\DBAL|Doctrine\\ORM|EntityManager", re.IGNORECASE), "sql"),
29
+ (re.compile(r"\bmysqli_connect\s*\(", re.IGNORECASE), "mysql"),
30
+ (re.compile(r"\bnew\s+mysqli\s*\(", re.IGNORECASE), "mysql"),
31
+ (re.compile(r"\bpg_connect\s*\(", re.IGNORECASE), "postgresql"),
32
+ (re.compile(r"\bRedis\s*::|\bnew\s+Redis\s*\(", re.IGNORECASE), "redis"),
33
+ ]
34
+
35
+ AUTH_PATTERNS = [
36
+ (re.compile(r"\bsession_start\s*\(", re.IGNORECASE), "session"),
37
+ (re.compile(r"\$_SESSION\b", re.IGNORECASE), "session"),
38
+ (re.compile(r"JWT|firebase\\jwt", re.IGNORECASE), "jwt"),
39
+ (re.compile(r"\bAuth::|\bauth\s*\(", re.IGNORECASE), "auth"),
40
+ ]
41
+
42
+ SECRET_PATTERNS = [
43
+ re.compile(r"getenv\s*\(\s*['\"]([A-Z0-9_]*(SECRET|TOKEN|KEY|PASSWORD|API|DB)[A-Z0-9_]*)['\"]", re.IGNORECASE),
44
+ re.compile(r"\$_ENV\s*\[\s*['\"]([A-Z0-9_]*(SECRET|TOKEN|KEY|PASSWORD|API|DB)[A-Z0-9_]*)['\"]\s*\]", re.IGNORECASE),
45
+ re.compile(r"\$_SERVER\s*\[\s*['\"]([A-Z0-9_]*(SECRET|TOKEN|KEY|PASSWORD|API|DB)[A-Z0-9_]*)['\"]\s*\]", re.IGNORECASE),
46
+ ]
47
+
48
+
49
+ class PhpLaminasAnalyzer:
50
+ metadata = AnalyzerMetadata(
51
+ name="php-laminas",
52
+ display_name="PHP Laminas Analyzer",
53
+ version="0.1.0",
54
+ description="Framework-aware Laminas analyzer for route, controller, and service mapping hints.",
55
+ scope="Laminas and Zend Framework MVC projects using module and application config arrays.",
56
+ targets=["php-laminas", "laminas", "zendframework"],
57
+ languages=["php"],
58
+ priority=30,
59
+ experimental=True,
60
+ enabled_by_default=False,
61
+ )
62
+
63
+ @property
64
+ def name(self) -> str:
65
+ return self.metadata.name
66
+
67
+ def detect(self, repo_path: str | Path) -> bool:
68
+ root = Path(repo_path).resolve()
69
+ if not root.exists() or not root.is_dir():
70
+ return False
71
+
72
+ if self._has_laminas_composer_dependencies(root / "composer.json"):
73
+ return True
74
+
75
+ if (root / "module").is_dir() and (root / "config" / "application.config.php").exists():
76
+ return True
77
+
78
+ if any(root.rglob("module.config.php")):
79
+ return True
80
+
81
+ return False
82
+
83
+ def analyze(self, repo_path: str | Path) -> ScanResult:
84
+ root = Path(repo_path).resolve()
85
+ result = ScanResult(root=str(root))
86
+
87
+ if not root.exists() or not root.is_dir():
88
+ return result
89
+
90
+ composer_path = root / "composer.json"
91
+ if composer_path.exists():
92
+ self._extract_composer_signals(composer_path, result)
93
+
94
+ for file_path in root.rglob("*.php"):
95
+ if not file_path.is_file():
96
+ continue
97
+ if any(part in {"vendor", ".git", "node_modules"} for part in file_path.parts):
98
+ continue
99
+
100
+ result.files_scanned += 1
101
+ if "php" not in result.languages:
102
+ result.languages.append("php")
103
+
104
+ content = self._read_text(file_path)
105
+ if content is None:
106
+ continue
107
+
108
+ relative = str(file_path.relative_to(root))
109
+ self._extract_routes(content, relative, result)
110
+ self._extract_laminas_controllers(content, relative, result)
111
+ self._extract_laminas_services(content, relative, result)
112
+ self._extract_external_calls(content, relative, result)
113
+ self._extract_datastores(content, relative, result)
114
+ self._extract_auth_hints(content, relative, result)
115
+ self._extract_secret_hints(content, relative, result)
116
+
117
+ result.languages.sort()
118
+ return result
119
+
120
+ def _has_laminas_composer_dependencies(self, composer_path: Path) -> bool:
121
+ if not composer_path.exists():
122
+ return False
123
+ try:
124
+ data = json.loads(composer_path.read_text(encoding="utf-8"))
125
+ except (UnicodeDecodeError, json.JSONDecodeError):
126
+ return False
127
+
128
+ requirements = {
129
+ **(data.get("require", {}) if isinstance(data.get("require", {}), dict) else {}),
130
+ **(data.get("require-dev", {}) if isinstance(data.get("require-dev", {}), dict) else {}),
131
+ }
132
+ for package in requirements:
133
+ lowered = package.lower()
134
+ if lowered.startswith("laminas/") or lowered.startswith("zendframework/"):
135
+ return True
136
+ return False
137
+
138
+ def _extract_composer_signals(self, composer_path: Path, result: ScanResult) -> None:
139
+ try:
140
+ data = json.loads(composer_path.read_text(encoding="utf-8"))
141
+ except (UnicodeDecodeError, json.JSONDecodeError):
142
+ return
143
+
144
+ requirements = {
145
+ **(data.get("require", {}) if isinstance(data.get("require", {}), dict) else {}),
146
+ **(data.get("require-dev", {}) if isinstance(data.get("require-dev", {}), dict) else {}),
147
+ }
148
+
149
+ for package in requirements:
150
+ lowered = package.lower()
151
+ if lowered.startswith("laminas/") or lowered.startswith("zendframework/"):
152
+ self._append_unique_auth(result, "laminas_dependency", "composer.json")
153
+ if "doctrine" in lowered:
154
+ self._append_unique_database(result, "sql", "composer.json")
155
+
156
+ def _extract_routes(self, content: str, relative: str, result: ScanResult) -> None:
157
+ for match in LAMINAS_ROUTE_PATTERN.finditer(content):
158
+ self._append_unique_route(result, match.group(1), "ANY", relative)
159
+
160
+ def _extract_laminas_controllers(self, content: str, relative: str, result: ScanResult) -> None:
161
+ found = False
162
+ for match in LAMINAS_CONTROLLER_PATTERN.finditer(content):
163
+ found = True
164
+ self._append_unique_auth(result, f"controller:{match.group(1)}", relative)
165
+ if found:
166
+ self._append_unique_auth(result, "laminas_controller_mapping", relative)
167
+
168
+ def _extract_laminas_services(self, content: str, relative: str, result: ScanResult) -> None:
169
+ found = False
170
+ for match in LAMINAS_SERVICE_PATTERN.finditer(content):
171
+ found = True
172
+ self._append_unique_auth(result, f"service:{match.group(1)}", relative)
173
+ if found or "'service_manager'" in content or '"service_manager"' in content:
174
+ self._append_unique_auth(result, "laminas_service_manager", relative)
175
+
176
+ def _extract_external_calls(self, content: str, relative: str, result: ScanResult) -> None:
177
+ for pattern in OUTBOUND_PATTERNS:
178
+ for match in pattern.finditer(content):
179
+ self._append_unique_external(result, match.group(1), relative)
180
+
181
+ def _extract_datastores(self, content: str, relative: str, result: ScanResult) -> None:
182
+ for pattern, kind in DATABASE_PATTERNS:
183
+ if pattern.search(content):
184
+ self._append_unique_database(result, kind, relative)
185
+
186
+ def _extract_auth_hints(self, content: str, relative: str, result: ScanResult) -> None:
187
+ for pattern, hint in AUTH_PATTERNS:
188
+ if pattern.search(content):
189
+ self._append_unique_auth(result, hint, relative)
190
+
191
+ def _extract_secret_hints(self, content: str, relative: str, result: ScanResult) -> None:
192
+ for pattern in SECRET_PATTERNS:
193
+ for match in pattern.finditer(content):
194
+ self._append_unique_secret(result, match.group(1), relative)
195
+
196
+ @staticmethod
197
+ def _read_text(path: Path) -> str | None:
198
+ try:
199
+ return path.read_text(encoding="utf-8")
200
+ except UnicodeDecodeError:
201
+ return None
202
+
203
+ @staticmethod
204
+ def _append_unique_route(result: ScanResult, path: str, method: str, file: str) -> None:
205
+ key = (path, method, file)
206
+ if any((item.path, item.method, item.file) == key for item in result.routes):
207
+ return
208
+ result.routes.append(Route(path=path, method=method, file=file))
209
+
210
+ @staticmethod
211
+ def _append_unique_external(result: ScanResult, target: str, file: str) -> None:
212
+ key = (target, file)
213
+ if any((item.target, item.file) == key for item in result.external_calls):
214
+ return
215
+ result.external_calls.append(ExternalCall(target=target, file=file))
216
+
217
+ @staticmethod
218
+ def _append_unique_database(result: ScanResult, kind: str, file: str) -> None:
219
+ key = (kind, file)
220
+ if any((item.kind, item.file) == key for item in result.databases):
221
+ return
222
+ result.databases.append(DatabaseHint(kind=kind, file=file))
223
+
224
+ @staticmethod
225
+ def _append_unique_auth(result: ScanResult, hint: str, file: str) -> None:
226
+ key = (hint, file)
227
+ if any((item.hint, item.file) == key for item in result.auth_hints):
228
+ return
229
+ result.auth_hints.append(AuthHint(hint=hint, file=file))
230
+
231
+ @staticmethod
232
+ def _append_unique_secret(result: ScanResult, name: str, file: str) -> None:
233
+ key = (name, file)
234
+ if any((item.name, item.file) == key for item in result.secret_hints):
235
+ return
236
+ result.secret_hints.append(SecretHint(name=name, file=file))
@@ -0,0 +1,18 @@
1
+ from __future__ import annotations
2
+
3
+ from attackmap.sdk.contracts import AnalyzerMetadata, AnalyzerProtocol
4
+ from attackmap.sdk.models import AuthHint, DatabaseHint, ExternalCall, Route, ScanResult, SecretHint
5
+
6
+ # Compatibility alias used by existing analyzer implementations.
7
+ AttackMapAnalyzerProtocol = AnalyzerProtocol
8
+
9
+ __all__ = [
10
+ "AnalyzerMetadata",
11
+ "AttackMapAnalyzerProtocol",
12
+ "Route",
13
+ "ExternalCall",
14
+ "DatabaseHint",
15
+ "AuthHint",
16
+ "SecretHint",
17
+ "ScanResult",
18
+ ]
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: attackmap-analyzer-php-laminas
3
+ Version: 0.1.0
4
+ Summary: Framework-aware Laminas analyzer plugin for AttackMap
5
+ Author: AttackMap Contributors
6
+ Author-email: Matthew Davis <matthewd@matthewd.xyz>
7
+ Maintainer-email: Matthew Davis <matthewd@matthewd.xyz>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/mlaify/attackmap-analyzer-php-laminas
10
+ Project-URL: Repository, https://github.com/mlaify/attackmap-analyzer-php-laminas
11
+ Project-URL: Issues, https://github.com/mlaify/attackmap-analyzer-php-laminas/issues
12
+ Project-URL: Changelog, https://github.com/mlaify/attackmap-analyzer-php-laminas/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: License :: OSI Approved :: MIT License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3 :: Only
26
+ Classifier: Topic :: Security
27
+ Classifier: Topic :: Software Development :: Quality Assurance
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.11
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: pydantic>=2.7.0
33
+ Provides-Extra: core
34
+ Requires-Dist: attackmap>=0.1.0; extra == "core"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
37
+ Requires-Dist: build>=1.2.0; extra == "dev"
38
+ Requires-Dist: attackmap>=0.1.0; extra == "dev"
39
+ Dynamic: license-file
40
+
41
+ # attackmap-analyzer-php-laminas
42
+
43
+ Framework-aware Laminas analyzer for [AttackMap](https://github.com/mlaify/AttackMap).
44
+
45
+ This module focuses on structured signal extraction for Laminas/Zend MVC projects:
46
+
47
+ - route paths from config arrays
48
+ - controller mapping hints
49
+ - service-manager mapping hints
50
+ - broad PHP security signals (outbound calls, datastore, auth, secret hints)
51
+
52
+ ## Analyzer identity
53
+
54
+ - `name`: `php-laminas`
55
+ - `display_name`: `PHP Laminas Analyzer`
56
+ - `version`: `0.1.0`
57
+ - `experimental`: `true`
58
+ - `enabled_by_default`: `false`
59
+
60
+ ## Detection
61
+
62
+ `detect(repo_path)` returns true when one or more Laminas indicators exist:
63
+
64
+ - composer dependencies beginning with `laminas/` or `zendframework/`
65
+ - `config/application.config.php`
66
+ - any `module.config.php`
67
+ - `module/` directory
68
+
69
+ ## Notes
70
+
71
+ This analyzer is heuristic and intentionally avoids AST parsing in this first iteration.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/attackmap_analyzer_php_laminas/__init__.py
5
+ src/attackmap_analyzer_php_laminas/analyzer.py
6
+ src/attackmap_analyzer_php_laminas/contracts.py
7
+ src/attackmap_analyzer_php_laminas.egg-info/PKG-INFO
8
+ src/attackmap_analyzer_php_laminas.egg-info/SOURCES.txt
9
+ src/attackmap_analyzer_php_laminas.egg-info/dependency_links.txt
10
+ src/attackmap_analyzer_php_laminas.egg-info/entry_points.txt
11
+ src/attackmap_analyzer_php_laminas.egg-info/requires.txt
12
+ src/attackmap_analyzer_php_laminas.egg-info/top_level.txt
13
+ tests/test_php_laminas_analyzer.py
@@ -0,0 +1,2 @@
1
+ [attackmap.analyzers]
2
+ php_laminas = attackmap_analyzer_php_laminas:PhpLaminasAnalyzer
@@ -0,0 +1,9 @@
1
+ pydantic>=2.7.0
2
+
3
+ [core]
4
+ attackmap>=0.1.0
5
+
6
+ [dev]
7
+ pytest>=8.0.0
8
+ build>=1.2.0
9
+ attackmap>=0.1.0
@@ -0,0 +1,64 @@
1
+ from pathlib import Path
2
+
3
+ from attackmap.sdk.contracts import AnalyzerMetadata as SharedAnalyzerMetadata
4
+ from attackmap.sdk.models import ScanResult as SharedScanResult
5
+ from attackmap_analyzer_php_laminas.contracts import AnalyzerMetadata, ScanResult
6
+ from attackmap_analyzer_php_laminas import PhpLaminasAnalyzer
7
+
8
+ FIXTURES = Path(__file__).parent / "fixtures"
9
+
10
+
11
+ def test_contracts_use_shared_sdk_types() -> None:
12
+ assert AnalyzerMetadata is SharedAnalyzerMetadata
13
+ assert ScanResult is SharedScanResult
14
+
15
+
16
+ def test_metadata_contains_required_fields() -> None:
17
+ analyzer = PhpLaminasAnalyzer()
18
+ metadata = analyzer.metadata
19
+
20
+ assert metadata.name == "php-laminas"
21
+ assert metadata.display_name == "PHP Laminas Analyzer"
22
+ assert metadata.version == "0.1.0"
23
+ assert metadata.description
24
+ assert metadata.scope
25
+ assert metadata.targets
26
+ assert metadata.languages == ["php"]
27
+ assert metadata.experimental is True
28
+
29
+
30
+ def test_detect_identifies_laminas_project() -> None:
31
+ analyzer = PhpLaminasAnalyzer()
32
+
33
+ assert analyzer.detect(FIXTURES / "laminas_app") is True
34
+
35
+
36
+ def test_analyze_extracts_routes_controllers_and_services() -> None:
37
+ analyzer = PhpLaminasAnalyzer()
38
+ result = analyzer.analyze(FIXTURES / "laminas_app")
39
+
40
+ route_keys = {(route.path, route.method) for route in result.routes}
41
+ auth_hints = {hint.hint for hint in result.auth_hints}
42
+
43
+ assert ("/", "ANY") in route_keys
44
+ assert ("/admin", "ANY") in route_keys
45
+ assert ("/api[/:id]", "ANY") in route_keys
46
+
47
+ assert any(hint.startswith("controller:Application\\Controller\\") for hint in auth_hints)
48
+ assert any(hint.startswith("service:Application\\Service\\") for hint in auth_hints)
49
+ assert "laminas_controller_mapping" in auth_hints
50
+ assert "laminas_service_manager" in auth_hints
51
+
52
+
53
+ def test_analyze_returns_core_compatible_scan_shape() -> None:
54
+ analyzer = PhpLaminasAnalyzer()
55
+ result = analyzer.analyze(FIXTURES / "laminas_app")
56
+
57
+ assert isinstance(result.root, str)
58
+ assert isinstance(result.files_scanned, int)
59
+ assert isinstance(result.languages, list)
60
+ assert hasattr(result, "routes")
61
+ assert hasattr(result, "external_calls")
62
+ assert hasattr(result, "databases")
63
+ assert hasattr(result, "auth_hints")
64
+ assert hasattr(result, "secret_hints")