Commit dd7743f
authored
feat: add pnpm lockfile support for container scanning (#734)
* feat: add pnpm lockfile support for container scanning
Add support for scanning Node.js applications that use pnpm as their
package manager. This enables vulnerability detection in container
images that contain pnpm-lock.yaml files.
Implementation changes:
- Add pnpm-lock.yaml to the list of extracted node app files so the
extractor picks up pnpm lockfiles from container images
- Introduce detectLockFile() helper function that finds lockfiles in a
directory with priority order: npm > yarn > pnpm. This consolidates
the lockfile detection logic and makes it easier to extend
- Refactor findManifestLockPairsInSameDirectory() and
findManifestNodeModulesFilesInSameDirectory() to use the new
detectLockFile() helper
- Add PnpmLockV5, PnpmLockV6, and PnpmLockV9 cases to buildDepGraph()
which calls lockFileParser.parsePnpmProject() to generate dependency
graphs from pnpm lockfiles
- Update shouldBuildDepTree() to include pnpm lockfile versions,
indicating they can be parsed directly without dep tree conversion
Test changes:
- Add unit tests for detectLockFile() covering all lockfile types,
null case, and priority ordering when multiple lockfiles exist
- Add pnpm v5 test case to getLockFileVersion tests
- Update shouldBuildDepTree tests to verify pnpm versions return false
(they don't need dep tree conversion)
- Update extractContent test to verify pnpm-lock.yaml files are
extracted alongside package.json, package-lock.json, and yarn.lock
- Add integration test for scanning container images with pnpm v6 and
v9 lockfiles, verifying the dep graph is correctly generated with
pkgManager.name set to "pnpm"
- Add test fixtures: pnpmlockv6.tar and pnpmlockv9.tar containing
Alpine-based images with pnpm projects
CN-552
* fix: pr suggestions, more unit tests1 parent 0ce2f96 commit dd7743f
7 files changed
Lines changed: 1198 additions & 28 deletions
File tree
- lib
- analyzer/applications
- inputs/node
- test
- fixtures/pnpm
- lib/save
- system/application-scans
- __snapshots__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 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 | + | |
218 | 245 | | |
219 | 246 | | |
220 | 247 | | |
| |||
231 | 258 | | |
232 | 259 | | |
233 | 260 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
241 | 264 | | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
253 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
254 | 276 | | |
255 | 277 | | |
256 | 278 | | |
| |||
269 | 291 | | |
270 | 292 | | |
271 | 293 | | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | 294 | | |
276 | 295 | | |
277 | | - | |
278 | | - | |
| 296 | + | |
279 | 297 | | |
280 | 298 | | |
281 | 299 | | |
| |||
347 | 365 | | |
348 | 366 | | |
349 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
350 | 383 | | |
351 | 384 | | |
352 | 385 | | |
| |||
401 | 434 | | |
402 | 435 | | |
403 | 436 | | |
404 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
405 | 441 | | |
406 | 442 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
7 | 12 | | |
8 | 13 | | |
| |||
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 commit comments