Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: Reuse matches in CPE match strings API #1082

Merged
merged 6 commits into from
Jan 9, 2025

Conversation

timopollmeier
Copy link
Member

What

When parsing the CPE match string JSON from the NVD API, the matching CPEs are cached and reused if identical ones appear in another match string.

Why

This can save memory when processing a large amount of CPE match strings with duplicate matches.

References

GEA-820

Checklist

  • Tests

@timopollmeier timopollmeier requested a review from a team as a code owner January 6, 2025 15:17
@greenbonebot greenbonebot enabled auto-merge (rebase) January 6, 2025 15:17
@timopollmeier timopollmeier force-pushed the reduce-cpe-match-mem-usage branch 2 times, most recently from 27656e9 to 3856e17 Compare January 6, 2025 15:27
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.33%. Comparing base (b172bee) to head (ced864f).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1082      +/-   ##
==========================================
+ Coverage   90.31%   90.33%   +0.01%     
==========================================
  Files         108      108              
  Lines        7188     7198      +10     
  Branches      815      817       +2     
==========================================
+ Hits         6492     6502      +10     
  Misses        491      491              
  Partials      205      205              

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

Copy link
Contributor

@bjoernricks bjoernricks left a comment

Choose a reason for hiding this comment

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

Besides my inline comments could you add some tests?

pontos/nvd/cpe_match/api.py Outdated Show resolved Hide resolved
pontos/nvd/models/cpe_match_string.py Outdated Show resolved Hide resolved
pontos/nvd/models/cpe_match_string.py Outdated Show resolved Hide resolved
pontos/nvd/models/cpe_match_string.py Outdated Show resolved Hide resolved
pontos/nvd/models/cpe_match_string.py Outdated Show resolved Hide resolved
pontos/nvd/models/cpe_match_string.py Outdated Show resolved Hide resolved
@y0urself
Copy link
Member

y0urself commented Jan 8, 2025

Besides my inline comments could you add some tests?

@bjoernricks Due to time constrains, @timopollmeier wanted to move tests to "later" ...!

@bjoernricks
Copy link
Contributor

That's not a good idea at all

@y0urself
Copy link
Member

y0urself commented Jan 8, 2025

I know.

@timopollmeier
Copy link
Member Author

I've added a test case for the caching and will add tests to the CPE match downloader in greenbone-scap if there aren't any more urgent fixes required for it.

When parsing the CPE match string JSON from the NVD API, the matching
CPEs are cached and reused if identical ones appear in another
match string.

This can save memory when processing a large amount of CPE match strings
with duplicate matches.
@timopollmeier timopollmeier force-pushed the reduce-cpe-match-mem-usage branch from ee0e0fd to ced864f Compare January 9, 2025 10:57
Copy link

github-actions bot commented Jan 9, 2025

Conventional Commits Report

Type Number
Changed 1

🚀 Conventional commits found.

@greenbonebot greenbonebot merged commit d9b3105 into main Jan 9, 2025
19 checks passed
@greenbonebot greenbonebot deleted the reduce-cpe-match-mem-usage branch January 9, 2025 10:59
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.

4 participants