original_docstring: Return a JSON representation of this class.
  
          For this class, the exported JSON is callled the intermediate representation file.
          This should be valid as per the specification and allows different projects from different
          languages to be merged into a single Threat Model.
          
docstring: Return a JSON representation of this class.
  For this class, the exported JSON is callled the intermediate representation file.
  This should be valid as per the specification and allows different projects from different
  languages to be merged into a single Threat Model.
docstring_tokens: Return a JSON representation of this class . For this class the exported JSON is callled the intermediate representation file . This should be valid as per the specification and allows different projects from different languages to be merged into a single Threat Model .
code: def export_to_json(self):
          """Return a JSON representation of this class.
  
          For this class, the exported JSON is callled the intermediate representation file.
          This should be valid as per the specification and allows different projects from different
          languages to be merged into a single Threat Model.
          """
          data = {
              "specification": {
                  "name": "ThreatSpec",
                  "version": "0.1.0"
              },
              "document": {
                  "created": self.parser.creation_time,
                  "updated": self.parser.updated_time
              },
              "boundaries": {},
              "components": {},
              "threats": {},
              "dfd": {},
              "projects": {}
          }
  
          """Boundaries, components and threats are top-level and are shared across projects."""
          for boundary_id, boundary in self.parser.boundaries.items():
              if boundary_id not in data["boundaries"]:
                  data["boundaries"][boundary_id] = boundary.export_to_json()
  
          for boundary_id, component_obj in self.parser.components.items():
              if boundary_id not in data["components"]:
                  data["components"][boundary_id] = {}
              for component_id, component in component_obj.items():
                  if component_id not in data["components"][boundary_id]:
                      data["components"][boundary_id][component_id] = component.export_to_json()
  
          for threat_id, threat in self.parser.threats.items():
              if threat_id not in data["threats"]:
                  data["threats"][threat_id] = threat.export_to_json()
  
          """As is the DFD."""
          data["dfd"].update(self.parser.dfd.export_to_json())
  
          """Project-specific mitigations, exposures etc. are managed below."""
          project_details = {
              "mitigations": {},
              "exposures": {},
              "acceptances": {},
              "transfers": {},
              "reviews": {}
          }
  
          for review_id, reviews in self.parser.reviews.items():
              if review_id not in project_details["reviews"]:
                  project_details["reviews"][review_id] = []
              for review in reviews:
                  project_details["reviews"][review_id].append(review.export_to_json())
  
          for mitigation_id, mitigations in self.parser.mitigations.items():
              if mitigation_id not in project_details["mitigations"]:
                  project_details["mitigations"][mitigation_id] = []
              for mitigation in mitigations:
                  project_details["mitigations"][mitigation_id].append(mitigation.export_to_json())
  
          for exposure_id, exposures in self.parser.exposures.items():
              if exposure_id not in project_details["exposures"]:
                  project_details["exposures"][exposure_id] = []
              for exposure in exposures:
                  project_details["exposures"][exposure_id].append(exposure.export_to_json())
  
          for acceptance_id, acceptances in self.parser.acceptances.items():
              if acceptance_id not in project_details["acceptances"]:
                  project_details["acceptances"][acceptance_id] = []
              for acceptance in acceptances:
                  project_details["acceptances"][acceptance_id].append(acceptance.export_to_json())
  
          for transfer_id, transfers in self.parser.transfers.items():
              if transfer_id not in project_details["transfers"]:
                  project_details["transfers"][transfer_id] = []
              for transfer in transfers:
                  project_details["transfers"][transfer_id].append(transfer.export_to_json())
  
          data["projects"][self.project] = project_details
  
          return data
code_tokens: def export_to_json ( self ) : data = { "specification" : { "name" : "ThreatSpec" , "version" : "0.1.0" } , "document" : { "created" : self . parser . creation_time , "updated" : self . parser . updated_time } , "boundaries" : { } , "components" : { } , "threats" : { } , "dfd" : { } , "projects" : { } } """Boundaries, components and threats are top-level and are shared across projects.""" for boundary_id , boundary in self . parser . boundaries . items ( ) : if boundary_id not in data [ "boundaries" ] : data [ "boundaries" ] [ boundary_id ] = boundary . export_to_json ( ) for boundary_id , component_obj in self . parser . components . items ( ) : if boundary_id not in data [ "components" ] : data [ "components" ] [ boundary_id ] = { } for component_id , component in component_obj . items ( ) : if component_id not in data [ "components" ] [ boundary_id ] : data [ "components" ] [ boundary_id ] [ component_id ] = component . export_to_json ( ) for threat_id , threat in self . parser . threats . items ( ) : if threat_id not in data [ "threats" ] : data [ "threats" ] [ threat_id ] = threat . export_to_json ( ) """As is the DFD.""" data [ "dfd" ] . update ( self . parser . dfd . export_to_json ( ) ) """Project-specific mitigations, exposures etc. are managed below.""" project_details = { "mitigations" : { } , "exposures" : { } , "acceptances" : { } , "transfers" : { } , "reviews" : { } } for review_id , reviews in self . parser . reviews . items ( ) : if review_id not in project_details [ "reviews" ] : project_details [ "reviews" ] [ review_id ] = [ ] for review in reviews : project_details [ "reviews" ] [ review_id ] . append ( review . export_to_json ( ) ) for mitigation_id , mitigations in self . parser . mitigations . items ( ) : if mitigation_id not in project_details [ "mitigations" ] : project_details [ "mitigations" ] [ mitigation_id ] = [ ] for mitigation in mitigations : project_details [ "mitigations" ] [ mitigation_id ] . append ( mitigation . export_to_json ( ) ) for exposure_id , exposures in self . parser . exposures . items ( ) : if exposure_id not in project_details [ "exposures" ] : project_details [ "exposures" ] [ exposure_id ] = [ ] for exposure in exposures : project_details [ "exposures" ] [ exposure_id ] . append ( exposure . export_to_json ( ) ) for acceptance_id , acceptances in self . parser . acceptances . items ( ) : if acceptance_id not in project_details [ "acceptances" ] : project_details [ "acceptances" ] [ acceptance_id ] = [ ] for acceptance in acceptances : project_details [ "acceptances" ] [ acceptance_id ] . append ( acceptance . export_to_json ( ) ) for transfer_id , transfers in self . parser . transfers . items ( ) : if transfer_id not in project_details [ "transfers" ] : project_details [ "transfers" ] [ transfer_id ] = [ ] for transfer in transfers : project_details [ "transfers" ] [ transfer_id ] . append ( transfer . export_to_json ( ) ) data [ "projects" ] [ self . project ] = project_details return data
short_docstring: Return a JSON representation of this class.
short_docstring_tokens: Return a JSON representation of this class .
comment: """Return a JSON representation of this class.
  
          For this class, the exported JSON is callled the intermediate representation file.
          This should be valid as per the specification and allows different projects from different
          languages to be merged into a single Threat Model.
          """$SEP$"""Boundaries, components and threats are top-level and are shared across projects."""$SEP$"""As is the DFD."""$SEP$"""Project-specific mitigations, exposures etc. are managed below."""