flowstrider.converters package¶
Submodules¶
flowstrider.converters.dfd_to_dot_converter module¶
- flowstrider.converters.dfd_to_dot_converter.cluster_to_dot(cluster: Cluster, dfd: DataflowDiagram, relationships: dict) str[source]¶
- takes a cluster object and generates dot string. recursively includes
nested clusters
- Parameters:
cluster – the cluster to be converted to dot
dfd – the dataflow diagram to which the cluster belongs (needed to get node and child cluster objects)
relationships – possible child clusters to be added recursively
- Returns:
the dot representation of the cluster(s) as a string
- flowstrider.converters.dfd_to_dot_converter.dataflow_to_dot(edge: Edge) str[source]¶
takes an edge object and generates dot string
- Parameters:
edge – the edge to be converted to dot
- Returns:
the dot representation of the edge as a string
- flowstrider.converters.dfd_to_dot_converter.deserialized_dfd_to_dot(dfd: DataflowDiagram) str[source]¶
- takes dfd object as input and creates a dot representation (as string)
which can be rendered as PNG file
- Parameters:
dfd – the dataflow diagram to be converted to dot format
- Returns:
the dot representation of the dfd as a string
- flowstrider.converters.dfd_to_dot_converter.format_attributes(attributes: dict) str[source]¶
- takes metadata of an entity and formats it in a more human-readable format
(helpful for the SVG representation where a metadata tooltip can be added)
- Parameters:
attributes – the metadata dictionary of an entity (node, edge, cluster)
- Returns:
the formatted attributes to be added to the dot string of the entity
- flowstrider.converters.dfd_to_dot_converter.node_to_dot(node: Node) str[source]¶
takes a node object and generates dot string
- Parameters:
node – the node to be converted to dot
- Returns:
the dot representation of the node as a string
- flowstrider.converters.dfd_to_dot_converter.render_dfd(dfd: DataflowDiagram)[source]¶
Renders a given dataflow diagram as a PNG file (or SVG)
- Parameters:
dfd – the dataflowdiagram to be rendered
- flowstrider.converters.dfd_to_dot_converter.wrap_text(text_to_wrap: str, max_line_char_length: int = 80, include_hyphen: bool = True) str[source]¶
Inserts line breaks in the given string to fit the given maximum character length per line
- Parameters:
text_to_wrap – the text that is being wrapped
max_line_char_length – number of characters that will be allowed in one line
include_hyphen – if hyphen are used to indicate that a long word continues on the next line; set to False for hyperlinks!
- Returns:
wrapped version of the input text up to the maximum char length per line as a string with line breaks
flowstrider.converters.metadata_xsxl_converter module¶
- flowstrider.converters.metadata_xsxl_converter.metadata_check(dfd: DataflowDiagram, output_path: Path)[source]¶
- Generates an xlsx file highlighting missing metadata
that would be helpful to add to a dataflowdiagram
- Parameters:
dfd – the dataflowdiagram for which the metadata overview should be generated
- flowstrider.converters.metadata_xsxl_converter.parse_value(value)[source]¶
- Helper method when updating a dfd.json file from an xlsx file.
Is given the value from a cell and attempts to parse it. Especially relevant to parse lists properly.
- Parameters:
value – the value from a specific cell
- Returns:
the parsed value where more complex parsing is necessary. Otherwise returns unparsed value
- flowstrider.converters.metadata_xsxl_converter.update_dfd_json_from_xlsx(dfd: DataflowDiagram, xlsx_file) DataflowDiagram[source]¶
- Updates the metadata of a given dfd from a given xlsx file
Changes to the dfd are saved to the json file of it
- Parameters:
dfd – the dfd that should be updated with new metadata
xlsx_file – file from which metadata is taken
- Returns:
updated dfd
flowstrider.converters.threats_to_file_converter module¶
- class flowstrider.converters.threats_to_file_converter.PDF(orientation='P', unit='mm', format='A4')[source]¶
Bases:
FPDFFooter to be implemented in your own inherited class
- flowstrider.converters.threats_to_file_converter.create_threats_pdf(threats: List[Threat], dfd: DataflowDiagram, threat_management_database: ThreatManagementDatabase, output_path: Path)[source]¶
- Generates a pdf report with all generated threats for a dfd
and the graphviz visualisation if apllicable
- Parameters:
threats – a list of threats generated by the elicit command
dfd – the dataflowdiagram for which the threats were generated