mirror of
https://github.com/mandiant/capa.git
synced 2025-12-12 15:49:46 -08:00
remove exclude_none = True to not drop none fields
This commit is contained in:
@@ -80,7 +80,7 @@ class Analysis(Model):
|
|||||||
class Metadata(Model):
|
class Metadata(Model):
|
||||||
timestamp: datetime.datetime
|
timestamp: datetime.datetime
|
||||||
version: str
|
version: str
|
||||||
argv: Optional[Tuple[str, ...]] = None
|
argv: Optional[Tuple[str, ...]]
|
||||||
sample: Sample
|
sample: Sample
|
||||||
analysis: Analysis
|
analysis: Analysis
|
||||||
|
|
||||||
|
|||||||
@@ -144,8 +144,7 @@ def get_capa_results(args):
|
|||||||
meta.analysis.layout = capa.main.compute_layout(rules, extractor, capabilities)
|
meta.analysis.layout = capa.main.compute_layout(rules, extractor, capabilities)
|
||||||
|
|
||||||
doc = rd.ResultDocument.from_capa(meta, rules, capabilities)
|
doc = rd.ResultDocument.from_capa(meta, rules, capabilities)
|
||||||
|
return {"path": path, "status": "ok", "ok": doc.model_dump()}
|
||||||
return {"path": path, "status": "ok", "ok": doc.dict(exclude_none=True)}
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
@@ -214,9 +213,7 @@ def main(argv=None):
|
|||||||
if result["status"] == "error":
|
if result["status"] == "error":
|
||||||
logger.warning(result["error"])
|
logger.warning(result["error"])
|
||||||
elif result["status"] == "ok":
|
elif result["status"] == "ok":
|
||||||
results[result["path"].as_posix()] = rd.ResultDocument.parse_obj(result["ok"]).model_dump_json(
|
results[result["path"].as_posix()] = rd.ResultDocument.model_validate(result["ok"]).model_dump_json()
|
||||||
exclude_none=True
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"unexpected status: {result['status']}")
|
raise ValueError(f"unexpected status: {result['status']}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user