Skip to content

Commit

Permalink
Fix: Put match_strings last in MatchStringResponse JSON
Browse files Browse the repository at this point in the history
The dataclass and convert_keys_to_camel have been adjusted so
the match_strings should always appear last in the JSON.

This makes the metadata fields faster to find.
  • Loading branch information
timopollmeier committed Jan 15, 2025
1 parent db0bf43 commit 09cc964
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 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
2 changes: 1 addition & 1 deletion greenbone/scap/data_utils/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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)
Expand Down

0 comments on commit 09cc964

Please sign in to comment.