tooling: include OSV JSON data in official CVE feed#181
tooling: include OSV JSON data in official CVE feed#181Pnkcaht wants to merge 2 commits intokubernetes:mainfrom
Conversation
Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
|
Hi @Pnkcaht. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
|
/ok-to-test |
|
@Pnkcaht Thank you so much for making this contribution. I tested this locally and it works well! /lgtm |
|
@PushkarJ Thank you my friend, I will be contributing regularly here as well. |
mtardy
left a comment
There was a problem hiding this comment.
Thanks, it works but I think the patch could be adjusted
There was a problem hiding this comment.
hey you committed a binary file here, please remove
|
|
||
| # Initialize the OSV field as None in case no OSV JSON is available | ||
| cve['_kubernetes_io']['osv'] = None |
| except requests.RequestException: | ||
| # If any network error occurs (timeout, connection error, etc.), leave 'osv' as None | ||
| cve['_kubernetes_io']['osv'] = None |
There was a problem hiding this comment.
It's already none, you can again remove that
| # Make a deep copy of the main CVE to avoid overwriting its data | ||
| additional_cve = copy.deepcopy(cve) | ||
|
|
||
| # Update the CVE ID for this additional CVE | ||
| additional_cve['id'] = additional_cve_id | ||
|
|
||
| # Set the external URL for this CVE on CVE.org | ||
| additional_cve['external_url'] = f'https://www.cve.org/cverecord?id={additional_cve_id}' | ||
|
|
||
| # Set the Google Group URL specific to this CVE |
There was a problem hiding this comment.
please do not add unnecessary comments on un-related lines to your changes
| # --- Add OSV data for the additional CVE --- | ||
| # Initialize the OSV field as None in case no JSON exists | ||
| additional_cve['_kubernetes_io']['osv'] = None | ||
|
|
||
| # Construct the URL to fetch the OSV JSON from the official repository | ||
| additional_osv_url = f'https://raw.githubusercontent.com/kubernetes-sigs/cve-feed-osv/main/vulns/{additional_cve_id}.json' | ||
|
|
||
| try: | ||
| # Attempt to fetch the OSV JSON with a 5-second timeout | ||
| res_additional_osv = requests.get(additional_osv_url, timeout=5) | ||
|
|
||
| # If the file exists, parse it as JSON and store it in the 'osv' field | ||
| if res_additional_osv.status_code == 200: | ||
| additional_cve['_kubernetes_io']['osv'] = res_additional_osv.json() | ||
|
|
||
| except requests.RequestException: | ||
| # If any network error occurs (timeout, connection issue, etc.), keep 'osv' as None | ||
| additional_cve['_kubernetes_io']['osv'] = None |
There was a problem hiding this comment.
could you reuse that code with a function instead of duplicating?
| if not body: | ||
| return None | ||
|
|
||
| match = re.search(r"```json\s*(\{.*?\})\s*```", body, re.DOTALL) |
There was a problem hiding this comment.
please match the full "```json osv" because the "```json" can appear in different places in the issue if any json blob is included.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Pnkcaht The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/hold until we fix the patches |
Also by the way, could you add actual tests that indeed for one coming from the OSV feed repo you have a not null OSV value, and the same from the body of an issue. |
What I Did
(new SRC CVE announcement format).
kubernetes-sigs/cve-feed-osvrepository when no embedded OSV is present._kubernetes_io["osv"]field.same issue include OSV data.
try/exceptblocks and atimeout=5to prevent feed generation failures.
osvfield remains
None.Related Issue
kubernetes-sigs/cve-feed-osvOSV information in the CVE feed #178Tests
I picked 2 different CVEs to do the test, in which the first one is related to the correct error, that is, a null return for an expected pattern.The second one is based on the correct pattern related to a CVE with the public OSV.
CVE test with OSV not published
The correct and standard behavior is for the OSV to be null, since this example CVE does not have a published OSV.
CVE with a Public OSV
CVE with public OSV where the expected default behavior is receiving a JSON with the correct information.
Output Terminal
{ "id": "CVE-2019-11243", "osv": { "id": "CVE-2019-11243", "modified": "2019-04-18T21:31:53Z", "published": "2019-04-18T21:31:53Z", "summary": "rest.AnonymousClientConfig() does not remove the serviceaccount credentials from config created by rest.InClusterConfig()", "details": "In Kubernetes v1.12.0-v1.12.4 and v1.13.0, the rest.AnonymousClientConfig() method returns a copy of the provided config, with credentials removed (bearer token, username/password, and client certificate/key data). In the affected versions, rest.AnonymousClientConfig() did not effectively clear service account credentials loaded using rest.InClusterConfig()", "affected": [ { "package": { "ecosystem": "kubernetes", "name": "k8s.io/client-go" }, "severity": [ { "type": "CVSS_V3", "score": "CVSS:3.0/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N" } ], "ranges": [ { "type": "SEMVER", "events": [ { "introduced": "1.12.0" }, { "fixed": "1.12.5" }, { "introduced": "1.13.0" }, { "fixed": "1.13.1" } ] } ] } ], "references": [ { "type": "ADVISORY", "url": "https://github.com/kubernetes/kubernetes/issues/76797" }, { "type": "ADVISORY", "url": "https://www.cve.org/cverecord?id=CVE-2019-11243" } ] } }