Skip to content

Conversation

laojianzi
Copy link
Contributor

Problem

The MatchVulnerabilities method in osvmatcher.go could panic when accessing batchResp.Results if batchResp is nil.

Solution

  • Added nil check for batchResp before accessing its Results field

Testing

  • Added test case "Timeout returns deadline exceeded error" to verify the timeout behavior
  • Test ensures the method returns context.DeadlineExceeded error without panicking

Changes

  • internal/clients/clientimpl/osvmatcher/osvmatcher.go: Added nil check and documentation
  • internal/clients/clientimpl/osvmatcher/osvmatcher_test.go: New test file with timeout test case

* Add nil check for batchResp before accessing Results to avoid panic
* Handle timeout scenarios gracefully by returning error instead of crashing
* Add test case to verify timeout behavior with deadline exceeded error
* Add function documentation comment for MatchVulnerabilities method
Copy link

google-cla bot commented Jun 3, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@cuixq cuixq requested a review from another-rex June 4, 2025 02:24
Copy link
Collaborator

@another-rex another-rex left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@codecov-commenter
Copy link

codecov-commenter commented Jun 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.69%. Comparing base (821ca57) to head (2e50835).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1922      +/-   ##
==========================================
+ Coverage   65.67%   65.69%   +0.02%     
==========================================
  Files         166      166              
  Lines       16064    16058       -6     
==========================================
  Hits        10550    10550              
+ Misses       4848     4842       -6     
  Partials      666      666              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@laojianzi laojianzi requested a review from another-rex June 4, 2025 03:50
@cuixq cuixq merged commit 19b56af into google:main Jun 10, 2025
15 checks passed
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