Skip to content

all: account for language package overwrites#1275

Merged
github-actions[bot] merged 1 commit intoquay:mainfrom
RTann:language-pkg-overwrite
May 13, 2025
Merged

all: account for language package overwrites#1275
github-actions[bot] merged 1 commit intoquay:mainfrom
RTann:language-pkg-overwrite

Conversation

@RTann
Copy link
Copy Markdown
Contributor

@RTann RTann commented Feb 27, 2024

This was originally discovered in StackRox Scanner V2: stackrox/stackrox#7033

StackRox now offers a Scanner based on ClairCore, which also has this same problem. The issue is that ClairCore does not consider the fact that the image build system may decide to overwrite the language package instead of deleting and recreating it.

This was demonstrated in the OCI image namloc2001/nodesem:a.

Each language's package scanner implements DefaultRepoScanner, which means there is only a single (related) repository per layer, and it only exists if the layer has (related) packages. Each language's coalescer is also more-or-less the same (Go's was unique, but the unique parts of it are unnecessary, as those checks will definitely hold true based on how to Ecosystem is set up), so I decided to make a single, shared coalescer for the languages.

@RTann RTann requested review from crozzy and hdonnay February 27, 2024 01:21
@RTann RTann requested a review from a team as a code owner February 27, 2024 01:21
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 27, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.

Project coverage is 55.73%. Comparing base (7088f7b) to head (221025b).

Files with missing lines Patch % Lines
language/coalescer.go 93.33% 2 Missing ⚠️
gobin/ecosystem.go 0.00% 1 Missing ⚠️
java/ecosystem.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1275      +/-   ##
==========================================
+ Coverage   55.41%   55.73%   +0.32%     
==========================================
  Files         282      278       -4     
  Lines       17890    17806      -84     
==========================================
+ Hits         9914     9925      +11     
+ Misses       6934     6839      -95     
  Partials     1042     1042              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RTann
Copy link
Copy Markdown
Contributor Author

RTann commented May 31, 2024

Though this does not explicitly touch package scanners, this still may merit a reindex. Thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be copy-pasted; why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest were definite copy/pastes of each other. This one is slightly unique, so I copied over the related change, but kept the fact this is still mildly different from the rest. Do you think this coalescer should just match the rest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it to also move this into the language-agnostic coalescer. The parts of this which were unique were not very necessary (I think)

Comment on lines +26 to +31
// For langauge packages, it is possible the
// packageDB is overwritten.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this package needs to document this assumption, and we need to check that the uses actually work that way.

  • gobin
  • java
  • nodejs
  • python
  • ruby

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious why gobin is already checked

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read through it to see what it did.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RTann was this checked?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd need more clarity on the exact ask. Depending on the image builder, the file may either be updated or deleted and recreated. The changes I made attempts to account for both. Not sure if that's what the question is asking about or something else

@hdonnay
Copy link
Copy Markdown
Member

hdonnay commented May 31, 2024

Though this does not explicitly touch package scanners, this still may merit a reindex. Thoughts?

Yeah, needs the version changed in every indexer that's moving to it.

@RTann RTann requested a review from hdonnay June 3, 2024 18:26
Copy link
Copy Markdown
Contributor

@crozzy crozzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's in good shape, a few comments.

@RTann RTann requested a review from crozzy October 16, 2024 00:10
@RTann
Copy link
Copy Markdown
Contributor Author

RTann commented Apr 7, 2025

@hdonnay @crozzy can you take a look at this when you get the chance? Thanks

BradLugo
BradLugo previously approved these changes Apr 23, 2025
Copy link
Copy Markdown
Contributor

@BradLugo BradLugo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think there are improvements we can make to the code we're moving over (clarify comments, add obvious error in test), but we can save it for a future cleanup. lmk if you want to post those reviews (I ended up deleting them after realizing I was commenting on code that was being moved)

@RTann
Copy link
Copy Markdown
Contributor Author

RTann commented May 9, 2025

LGTM. I think there are improvements we can make to the code we're moving over (clarify comments, add obvious error in test), but we can save it for a future cleanup. lmk if you want to post those reviews (I ended up deleting them after realizing I was commenting on code that was being moved)

@BradLugo please leave any comments you have!

Copy link
Copy Markdown
Contributor

@crozzy crozzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: RTann <rtannenb@redhat.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
Copy link
Copy Markdown
Member

@hdonnay hdonnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@RTann
Copy link
Copy Markdown
Contributor Author

RTann commented May 13, 2025

/fast-forward

@github-actions github-actions bot merged commit ff0aeab into quay:main May 13, 2025
6 checks passed
@RTann RTann deleted the language-pkg-overwrite branch May 13, 2025 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants