Commit 267e4be
authored
fix(container): parse_container_config accepts unwrapped inner-mapping shape (#113)
Regression in 0.7.2.dev83 (introduced when ``_load_container_config``
was added to support config-only invocation): the CLI now extracts
the inner ``containers:`` mapping from argus.yml before passing it to
``ContainerEngine``, but ``parse_container_config`` still required the
wrapped form (``config["containers"]["images"]``). The shape mismatch
silently dropped every config-defined target — ``argus scan container
--config argus.yml`` would enter the lifecycle, then immediately
report "No container targets found" despite a valid config.
Why the engine and the parser disagreed
- ContainerEngine accesses other config keys at the top level
(``self.config.get("images")``, ``self.config.get("search_paths")``,
``self.config.get("scanners")``). The CLI returns the unwrapped
inner mapping to match those — that's been the contract for
everything except this one parser.
- ``parse_container_config`` was the only outlier — strict on
wrapped shape — so it became the lone failure point on the
config-driven path.
Fix
- Make ``parse_container_config`` accept BOTH shapes:
- Wrapped: ``{"containers": {"images": [...], ...}}`` (full
argus.yml mapping, the historical contract)
- Unwrapped: ``{"images": [...], ...}`` (inner-mapping shape, the
CLI's actual hand-off)
- Wrapped shape takes precedence when both are present, preserving
the historical contract for any direct programmatic callers.
Tests (+5)
- New ``TestParseContainerConfigUnwrappedShape`` class:
- ``test_unwrapped_shape_resolves_explicit_images`` — the user's
exact repro (top-level ``containers.images`` with image,
dockerfile, context).
- ``test_unwrapped_shape_with_discover`` — same path with
``discover: true`` + ``search_paths``.
- ``test_wrapped_shape_takes_precedence_when_both_keys_present``
— defensive guard for the historical contract.
- ``test_unwrapped_with_digest_pin_preserved`` — round-trip the
recommended ``@sha256:...`` form.
Validation
- Full SDK suite: 1438 passed (+5), 8 skipped.
- Manual end-to-end against the user's exact repro shape: now
resolves the ``docker:argus-scan`` target with dockerfile and
context preserved.
Co-authored-by: eFAILution <eFAILution@users.noreply.github.com>1 parent f4e39fd commit 267e4be
2 files changed
Lines changed: 104 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
73 | 82 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
77 | 89 | | |
78 | 90 | | |
79 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 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 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
0 commit comments