Skip to content

datastore: drop non-matching vulnerabilities while scanning Get() - #2049

Open
crozzy wants to merge 1 commit into
mainfrom
stream-vulns-when-matching
Open

crozzy wants to merge 1 commit into
mainfrom
stream-vulns-when-matching

Conversation

@crozzy

@crozzy crozzy commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

This change analyses the vulnerability and record as it is streamed from the database instead of buffering all the vulnerabilities into memory and then analysing. This change reduces the memory consumption during matching significantly but it doesn't change how many vulnerabilities are return from the database.

@crozzy
crozzy force-pushed the stream-vulns-when-matching branch from 9e9e111 to 9c15c5c Compare October 1, 2026 23:16
@crozzy
crozzy marked this pull request as ready for review October 1, 2026 23:17
@crozzy
crozzy requested review from a team as code owners October 1, 2026 23:17
@crozzy
crozzy requested a review from hdonnay October 1, 2026 23:17
Comment thread datastore/postgres/get.go
// Vulnerable reports whether a scanned vulnerability affects this record.
// A nil Vulnerable retains every row. When several records share a package
// ID, the row is retained if any of them accepts it.
Vulnerable func(ctx context.Context, record *claircore.IndexRecord, vuln *claircore.Vulnerability) (bool, error)

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.

Could we document that Vulnerable runs while the database transaction and batch are open? Callback implementations should be aware of database access or other blocking steps.

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.

Yeah I can add something but probably not here as it is implementation-agnostic

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.

Comment thread datastore/postgres/get.go
Debug: true,
VersionFiltering: dbSide,
}
if !authoritative {

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.

Could we add a test asserting that Vulnerable is not called on that path?

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.

Added TestMatchAuthoritativeOmitsVulnerable

@crozzy
crozzy force-pushed the stream-vulns-when-matching branch from 9c15c5c to 063460e Compare October 9, 2026 16:21
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Triggered from #2049 by @​crozzy.

Checking if we can fast forward main (5cef92c) to stream-vulns-when-matching (063460e).

Target branch (main):

commit 5cef92c3fa36919729c603da7e8e12d1d926c2ef (HEAD -> main, tag: v1.6.1, origin/main)
Author: David Caravello <119438707+dcaravel@users.noreply.github.com>
Date:   Thu Oct 8 17:50:47 2026 -0500

    chore: v1.6.1 changelog bump
    
    Signed-off-by: David Caravello <119438707+dcaravel@users.noreply.github.com>

Pull request (stream-vulns-when-matching):

commit 063460e1122c17a94c06eddf7695b45cad92e56d (pull_request/stream-vulns-when-matching)
Author: Joseph Crosland <jcroslan@redhat.com>
Date:   Wed Sep 30 12:49:39 2026 -0700

    datastore: drop non-matching vulnerabilities while scanning Get()
    
    This change analyses the vulnerability and record as it is streamed
    from the database instead of buffering all the vulnerabilities into
    memory and then analysing. This change reduces the memory consumption
    during matching significantly but it doesn't change how many vulnerabilities
    are return from the database.
    
    Signed-off-by: crozzy <joseph.crosland@gmail.com>

Can't fast forward main (5cef92c) to stream-vulns-when-matching (063460e). main (5cef92c) is not a direct ancestor of stream-vulns-when-matching (063460e). Branches appear to have diverged at 4b16410:

* 063460e1122c17a94c06eddf7695b45cad92e56d datastore: drop non-matching vulnerabilities while scanning Get()
| * 5cef92c3fa36919729c603da7e8e12d1d926c2ef chore: v1.6.1 changelog bump
| * a3dbce3d38950a888c012a680f597128f403aa39 documentation: clarify latest release after branch releases
| * 531d0d4c986e607b9e5ed2ae44253baadf485e2f chore(deps): bump github.com/klauspost/compress from 1.20.0 to 1.20.1
|/  
* 4b16410062d2ba61ef16354984f8994f1d83d233 datastore: intern vulnerabilities by ID by pre-peeking at results

commit 4b16410062d2ba61ef16354984f8994f1d83d233
Author: Joseph Crosland <jcroslan@redhat.com>
Date:   Mon Sep 21 12:49:22 2026 -0700

    datastore: intern vulnerabilities by ID by pre-peeking at results
    
    It is fairly common for different queries to pull overlapping vulnerability results
    when they share a source package (i.e. "kernel"). This means every package with a
    common source will likely be leading to a vast majority of duplicate vulnerabilities.
    
    Signed-off-by: crozzy <joseph.crosland@gmail.com>

Rebase locally, and then force push to stream-vulns-when-matching.

@crozzy
crozzy force-pushed the stream-vulns-when-matching branch from 063460e to 90684ff Compare October 9, 2026 16:23
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Triggered from #2049 by @​crozzy.

Checking if we can fast forward main (5cef92c) to stream-vulns-when-matching (90684ff).

Target branch (main):

commit 5cef92c3fa36919729c603da7e8e12d1d926c2ef (HEAD -> main, tag: v1.6.1, origin/main)
Author: David Caravello <119438707+dcaravel@users.noreply.github.com>
Date:   Thu Oct 8 17:50:47 2026 -0500

    chore: v1.6.1 changelog bump
    
    Signed-off-by: David Caravello <119438707+dcaravel@users.noreply.github.com>

Pull request (stream-vulns-when-matching):

commit 90684ffb8f8797b1e11fc3636336d4c9c4ccd7f7 (pull_request/stream-vulns-when-matching)
Author: Joseph Crosland <jcroslan@redhat.com>
Date:   Wed Sep 30 12:49:39 2026 -0700

    datastore: drop non-matching vulnerabilities while scanning Get()
    
    This change analyses the vulnerability and record as it is streamed
    from the database instead of buffering all the vulnerabilities into
    memory and then analysing. This change reduces the memory consumption
    during matching significantly but it doesn't change how many vulnerabilities
    are return from the database.
    
    Signed-off-by: crozzy <joseph.crosland@gmail.com>

Can't fast forward main (5cef92c) to stream-vulns-when-matching (90684ff). main (5cef92c) is not a direct ancestor of stream-vulns-when-matching (90684ff). Branches appear to have diverged at 4b16410:

* 90684ffb8f8797b1e11fc3636336d4c9c4ccd7f7 datastore: drop non-matching vulnerabilities while scanning Get()
| * 5cef92c3fa36919729c603da7e8e12d1d926c2ef chore: v1.6.1 changelog bump
| * a3dbce3d38950a888c012a680f597128f403aa39 documentation: clarify latest release after branch releases
| * 531d0d4c986e607b9e5ed2ae44253baadf485e2f chore(deps): bump github.com/klauspost/compress from 1.20.0 to 1.20.1
|/  
* 4b16410062d2ba61ef16354984f8994f1d83d233 datastore: intern vulnerabilities by ID by pre-peeking at results

commit 4b16410062d2ba61ef16354984f8994f1d83d233
Author: Joseph Crosland <jcroslan@redhat.com>
Date:   Mon Sep 21 12:49:22 2026 -0700

    datastore: intern vulnerabilities by ID by pre-peeking at results
    
    It is fairly common for different queries to pull overlapping vulnerability results
    when they share a source package (i.e. "kernel"). This means every package with a
    common source will likely be leading to a vast majority of duplicate vulnerabilities.
    
    Signed-off-by: crozzy <joseph.crosland@gmail.com>

Rebase locally, and then force push to stream-vulns-when-matching.

@crozzy
crozzy force-pushed the stream-vulns-when-matching branch from 90684ff to bd9ed8d Compare October 9, 2026 16:50
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Triggered from #2049 by @​crozzy.

Checking if we can fast forward main (5cef92c) to stream-vulns-when-matching (bd9ed8d).

Target branch (main):

commit 5cef92c3fa36919729c603da7e8e12d1d926c2ef (HEAD -> main, tag: v1.6.1, origin/main)
Author: David Caravello <119438707+dcaravel@users.noreply.github.com>
Date:   Thu Oct 8 17:50:47 2026 -0500

    chore: v1.6.1 changelog bump
    
    Signed-off-by: David Caravello <119438707+dcaravel@users.noreply.github.com>

Pull request (stream-vulns-when-matching):

commit bd9ed8dc85d0184795b52260b4df5f07b0172042 (pull_request/stream-vulns-when-matching)
Author: Joseph Crosland <jcroslan@redhat.com>
Date:   Wed Sep 30 12:49:39 2026 -0700

    datastore: drop non-matching vulnerabilities while scanning Get()
    
    This change analyses the vulnerability and record as it is streamed
    from the database instead of buffering all the vulnerabilities into
    memory and then analysing. This change reduces the memory consumption
    during matching significantly but it doesn't change how many vulnerabilities
    are return from the database.
    
    Signed-off-by: crozzy <joseph.crosland@gmail.com>

Can't fast forward main (5cef92c) to stream-vulns-when-matching (bd9ed8d). main (5cef92c) is not a direct ancestor of stream-vulns-when-matching (bd9ed8d). Branches appear to have diverged at 4b16410:

* bd9ed8dc85d0184795b52260b4df5f07b0172042 datastore: drop non-matching vulnerabilities while scanning Get()
| * 5cef92c3fa36919729c603da7e8e12d1d926c2ef chore: v1.6.1 changelog bump
| * a3dbce3d38950a888c012a680f597128f403aa39 documentation: clarify latest release after branch releases
| * 531d0d4c986e607b9e5ed2ae44253baadf485e2f chore(deps): bump github.com/klauspost/compress from 1.20.0 to 1.20.1
|/  
* 4b16410062d2ba61ef16354984f8994f1d83d233 datastore: intern vulnerabilities by ID by pre-peeking at results

commit 4b16410062d2ba61ef16354984f8994f1d83d233
Author: Joseph Crosland <jcroslan@redhat.com>
Date:   Mon Sep 21 12:49:22 2026 -0700

    datastore: intern vulnerabilities by ID by pre-peeking at results
    
    It is fairly common for different queries to pull overlapping vulnerability results
    when they share a source package (i.e. "kernel"). This means every package with a
    common source will likely be leading to a vast majority of duplicate vulnerabilities.
    
    Signed-off-by: crozzy <joseph.crosland@gmail.com>

Rebase locally, and then force push to stream-vulns-when-matching.

@crozzy
crozzy force-pushed the stream-vulns-when-matching branch from bd9ed8d to b49c904 Compare October 9, 2026 17:14
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Triggered from #2049 by @​crozzy.

Checking if we can fast forward main (5cef92c) to stream-vulns-when-matching (b49c904).

Target branch (main):

commit 5cef92c3fa36919729c603da7e8e12d1d926c2ef (HEAD -> main, tag: v1.6.1, origin/main)
Author: David Caravello <119438707+dcaravel@users.noreply.github.com>
Date:   Thu Oct 8 17:50:47 2026 -0500

    chore: v1.6.1 changelog bump
    
    Signed-off-by: David Caravello <119438707+dcaravel@users.noreply.github.com>

Pull request (stream-vulns-when-matching):

commit b49c9048061853941bed6a59b78c50c6b1bdcaf8 (pull_request/stream-vulns-when-matching)
Author: Joseph Crosland <jcroslan@redhat.com>
Date:   Wed Sep 30 12:49:39 2026 -0700

    datastore: drop non-matching vulnerabilities while scanning Get()
    
    This change analyses the vulnerability and record as it is streamed
    from the database instead of buffering all the vulnerabilities into
    memory and then analysing. This change reduces the memory consumption
    during matching significantly but it doesn't change how many vulnerabilities
    are return from the database.
    
    Signed-off-by: crozzy <joseph.crosland@gmail.com>

Can't fast forward main (5cef92c) to stream-vulns-when-matching (b49c904). main (5cef92c) is not a direct ancestor of stream-vulns-when-matching (b49c904). Branches appear to have diverged at a3dbce3:

* b49c9048061853941bed6a59b78c50c6b1bdcaf8 datastore: drop non-matching vulnerabilities while scanning Get()
| * 5cef92c3fa36919729c603da7e8e12d1d926c2ef chore: v1.6.1 changelog bump
|/  
* a3dbce3d38950a888c012a680f597128f403aa39 documentation: clarify latest release after branch releases

commit a3dbce3d38950a888c012a680f597128f403aa39
Author: David Caravello <119438707+dcaravel@users.noreply.github.com>
Date:   Thu Oct 8 09:36:25 2026 -0500

    documentation: clarify latest release after branch releases
    
    Publishing a patch release from an older release branch can move
    GitHub's Latest label away from the highest stable version. Document
    how to restore the label and verify the latest release link.
    
    Signed-off-by: David Caravello <119438707+dcaravel@users.noreply.github.com>

Rebase locally, and then force push to stream-vulns-when-matching.

This change analyses the vulnerability and record as it is streamed
from the database instead of buffering all the vulnerabilities into 
memory and then analysing. This change reduces the memory consumption
during matching significantly but it doesn't change how many vulnerabilities
are return from the database.

Signed-off-by: crozzy <joseph.crosland@gmail.com>
@crozzy
crozzy force-pushed the stream-vulns-when-matching branch from b49c904 to bca75d2 Compare October 9, 2026 17:16
@crozzy
crozzy requested a review from jvdm October 9, 2026 17:30
@crozzy
crozzy requested a review from BradLugo October 9, 2026 18:37

This branch has not been deployed

No deployments
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.

3 participants