Commit 7837c6e
authored
feat(scanner-container): exposed-port surface as new sub-scanner (#149)
* feat(scanner-container): exposed-port surface as new sub-scanner
Implements the "Container image exposed ports" item from
docs/developer/SDK-ROADMAP.md → "Attack Surface Visibility — Port
& Service Exposure". Reports what network endpoints a container
image declares via Dockerfile EXPOSE — separate from whether those
endpoints have known CVEs. "Image exposes 6379/tcp" is a different
question from "image has a vulnerable Redis package" and most
security reviewers want both.
No new scanner module; extends the existing container scanner's
sub-scanner orchestration alongside trivy/grype/syft. Default
sub-scanner list becomes "trivy,grype,syft,exposure" — opt out by
dropping the name from scanners.container.scanners.
How it works:
- _scan_exposed_ports(image_ref, config) ensures the image is
present locally (via container_runtime.pull_image with
if-not-present, which is a fast cache hit when trivy/grype/syft
already pulled it), runs <runtime> image inspect <ref>, parses
Config.ExposedPorts, and emits one Finding per port.
- Severity defaults to INFO for ordinary application ports and
MEDIUM for ports on the built-in RISKY_PORTS dict:
21/tcp (FTP), 22/tcp (SSH), 23/tcp (Telnet), 25/tcp (SMTP),
110/tcp (POP3), 143/tcp (IMAP), 161/udp (SNMP), 389/tcp (LDAP),
445/tcp (SMB), 3306/tcp (MySQL), 3389/tcp (RDP),
5432/tcp (PostgreSQL), 6379/tcp (Redis), 9200/tcp (Elasticsearch),
11211/tcp (Memcached), 27017/tcp (MongoDB). Each entry cites a
"why" in the scanner module docstring (CIS Docker Benchmark §5.8,
Shodan unauthorized-database-access reports, CVE-1999-0517 for
SNMPv1/v2 community strings, etc.) so future contributors don't
tune the list blindly.
Config knobs (argus.yml):
- scanners.container.expose_warn_ports: list[str] — replaces the
built-in WARN list. Empty list demotes every declared port to
INFO.
- scanners.container.expose_ignore_ports: list[str] — suppress
findings entirely. Use for ports the team has explicitly
accepted (the app's known 8080/tcp, etc.).
Both lists accept "PORT/PROTO" strings; bare "PORT" defaults to
tcp; protocol is case-insensitive. Validator rejects malformed
entries at config-load time so authoring mistakes surface during
argus validate, not at scan time.
Finding shape — flows through the existing reporter pipeline
(terminal, markdown, sarif, json, github, gitlab, junit), --
severity-threshold filtering, audit trail, and the view-terminal /
view-browser UIs without per-reporter custom code:
id: EXPOSE-<port>-<proto>
severity: INFO or MEDIUM
metadata: {port, protocol, common_service, risky, image_ref}
Test coverage (29 new tests):
- TestParsePortProto: canonical form, bare-port-defaults-tcp,
case+whitespace tolerated, 9-case invalid parametrize.
- TestScanExposedPorts: single non-risky → INFO, single risky →
MEDIUM with service name, multi-port sort+classification,
ignore-list suppresses, warn-override replaces defaults,
empty-warn-override demotes all to INFO, no exposed ports,
no Config block, empty inspect array, no runtime → skipped
metadata, pull failure → error metadata, unparseable port
logged + skipped (subprocess + container_runtime mocked).
- TestExposureSchemaValidation: valid lists accepted, non-list
errors, malformed entries error, non-string entries error,
"exposure" valid in container sub-scanner list.
Out of scope (deferred):
- Runtime port enumeration (actually start the container, probe
with nmap/ss). Static EXPOSE data is the bulk of the value at
a fraction of the operational cost. A runtime variant becomes
a separate roadmap item if demand surfaces.
Docs + .ai/:
- docs/config-reference.md: container scanner description,
scanner-specific properties table (new rows for expose_warn_ports
and expose_ignore_ports), worked example for attack-surface
tuning.
- argus.example.yml: commented example showing default sub-scanner
set + the two new knobs.
- .ai/architecture.yaml: scanners/ description in both SDK blocks
updated to mention the four sub-scanners and the RISKY_PORTS
watchlist.
- docs/developer/SDK-ROADMAP.md: roadmap entry flipped from
actionable to shipped with implementation summary.
Full suite: 3155 passed (+29 new), 2 skipped.
* style: codespell unparseable -> unparsable
---------
Co-authored-by: eFAILution <eFAILution@users.noreply.github.com>1 parent 6dc1ba3 commit 7837c6e
7 files changed
Lines changed: 638 additions & 88 deletions
File tree
- .ai
- argus
- core
- scanners
- tests/scanners
- docs
- developer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
| 483 | + | |
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
84 | | - | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
218 | 254 | | |
219 | 255 | | |
220 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
17 | 101 | | |
18 | 102 | | |
19 | 103 | | |
| |||
98 | 182 | | |
99 | 183 | | |
100 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
101 | 192 | | |
102 | 193 | | |
103 | 194 | | |
| |||
157 | 248 | | |
158 | 249 | | |
159 | 250 | | |
160 | | - | |
161 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
162 | 259 | | |
163 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
164 | 392 | | |
165 | 393 | | |
166 | 394 | | |
| |||
0 commit comments