Skip to content

chore: consolidate archive extraction (CN-941)#782

Open
ividalATSnyk wants to merge 4 commits intomainfrom
CN-941-consolidate-archive-extraction
Open

chore: consolidate archive extraction (CN-941)#782
ividalATSnyk wants to merge 4 commits intomainfrom
CN-941-consolidate-archive-extraction

Conversation

@ividalATSnyk
Copy link
Copy Markdown
Contributor

@ividalATSnyk ividalATSnyk commented Apr 7, 2026

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team

What does this PR do?

  • wrap docker and kaniko archive extraction under a generic archive extractor to reduce duplication

Where should the reviewer start?

You can take a look at the generic extractor here.

How should this be manually tested?

You can test by running a scan via cli for a Kaniko or Docker Archive.

What are the relevant tickets?

Questions?

There may be a better method for testing manually, open to ideas!

@ividalATSnyk ividalATSnyk changed the title Cn 941 consolidate archive extraction CN-941: consolidate archive extraction Apr 7, 2026
@ividalATSnyk ividalATSnyk changed the title CN-941: consolidate archive extraction chore: consolidate archive extraction (CN-941) Apr 7, 2026
@ividalATSnyk ividalATSnyk marked this pull request as ready for review April 7, 2026 15:38
@ividalATSnyk ividalATSnyk requested a review from a team as a code owner April 7, 2026 15:38
@ividalATSnyk ividalATSnyk requested a review from bgardiner April 7, 2026 15:38
@snyk-pr-review-bot

This comment has been minimized.

@ividalATSnyk ividalATSnyk requested review from d3vco and removed request for bgardiner April 16, 2026 19:33
@ividalATSnyk ividalATSnyk requested a review from a team as a code owner April 17, 2026 15:19
@snyk-pr-review-bot

This comment has been minimized.

d3vco
d3vco previously approved these changes Apr 17, 2026
@ividalATSnyk ividalATSnyk force-pushed the CN-941-consolidate-archive-extraction branch from 75f8169 to 740c55d Compare April 17, 2026 16:58
@snyk-pr-review-bot

This comment has been minimized.

@ividalATSnyk ividalATSnyk force-pushed the CN-941-consolidate-archive-extraction branch from 740c55d to 5ca45d2 Compare April 17, 2026 17:10
@snyk-pr-review-bot

This comment has been minimized.

@snyk-pr-review-bot
Copy link
Copy Markdown

PR Reviewer Guide 🔍

🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Compression Handling 🟠 [major]

The original extractArchive implementations in docker-archive/layer.ts and kaniko-archive/layer.ts used gunzip-maybe, which handles optional gzip. The new consolidated createExtractArchive explicitly pipes createReadStream through gunzip() (line 120), which will fail or throw errors if the outer tar archive is not gzipped. While Docker and Kaniko tarballs are often compressed, uncompressed tar archives are valid and were previously supported by the 'maybe' variant.

createReadStream(archiveFilesystemPath)
  .on("error", (error) => reject(error))
  .pipe(gunzip())
  .pipe(tarExtractor);
Interface Mismatch 🟠 [major]

The consolidation of ExtractedLayersAndManifest (line 59) uses TarArchiveManifest | OciArchiveManifest. However, TarArchiveManifest uses a capitalized Config property (line 47), while OciArchiveManifest uses a lowercase config object with a digest (seen in cross-file context). The ArchiveExtractor in lib/extractor/index.ts calls getImageIdFromManifest(archiveContent.manifest), which will fail for OCI archives if it expects the TarArchiveManifest structure, or vice-versa, as the factory logic in generic-archive-extractor.ts only handles the TarArchiveManifest shape.

export interface ExtractedLayersAndManifest {
  layers: ExtractedLayers[];
  manifest: TarArchiveManifest | OciArchiveManifest;
  imageConfig: ImageConfig;
}
📚 Repository Context Analyzed

This review considered 31 relevant code sections from 13 files (average relevance: 0.91)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants