izar / pytm

A Pythonic framework for threat modeling
Other
861 stars 161 forks source link

[FEAT] support to serialize Findings as JSON #213

Closed mohan-ravichandran closed 1 year ago

mohan-ravichandran commented 1 year ago

Added a couple of functions to serialize the Findings class objects as JSON representations.

izar commented 1 year ago

hi and thanks for the PR! How is this different from the current json output capability (./tm.py [...] --json JSON_FILE) ?

mohan-ravichandran commented 1 year ago

I just tweaked the script to only show the threats by calling

from pytm.pytm import TM

tm = TM()
tm.resolve() # instead of tm.process()
for finding in tm.findings:
  print(finding.to_json())

This way, one can view the findings and the corresponding target instead of the entire model. That is just my opinion 😅

izar commented 1 year ago

I'm a bit confused perhaps about the use case you have in mind. How would this be different from jq '.findings' on the file generated by --json ?

izar commented 1 year ago

Hi, @mohan-ravichandran , can this be closed ?

izar commented 1 year ago

No answer from author.