Skip to content

Commit

Permalink
Merge pull request #64 from greenbone/fix-cpe-match-json
Browse files Browse the repository at this point in the history
Fixes for CPE match JSON
  • Loading branch information
y0urself authored Jan 15, 2025
2 parents 1dd0e1f + 09cc964 commit 79e65e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions greenbone/scap/cpe_match/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later

import gzip
from dataclasses import asdict, dataclass
from dataclasses import asdict, dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Any, Optional, Sequence, TextIO
Expand Down Expand Up @@ -49,10 +49,10 @@ class MatchStringResponse:
start_index: int
total_results: int
timestamp: datetime
match_strings: list[MatchStringItem]

format: str = "NVD_CPEMatchString"
version: str = "2.0"
match_strings: list[MatchStringItem] = field(default_factory=list)


class MatchStringJsonManager(JsonManager):
Expand Down
7 changes: 3 additions & 4 deletions greenbone/scap/data_utils/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ def convert_keys_to_camel(obj: Any) -> Any:
"""

if isinstance(obj, dict):
old_keys = set(obj.keys())
old_keys = list(obj.keys())
for old_key in old_keys:
v = obj[old_key]
convert_keys_to_camel(v)
del obj[old_key]
# Exclude None values
if v is not None:
new_key = _snake_to_camel(old_key)
if new_key != old_key:
obj[new_key] = v
del obj[old_key]
obj[new_key] = v
elif isinstance(obj, list):
for item in obj:
convert_keys_to_camel(item)
Expand Down

0 comments on commit 79e65e7

Please sign in to comment.