As a developer of the ATT&CK website, I want to be able to easily and consistently format STIX descriptions when I'm creating or modifying templates.
The problem
Currently, we use a myriad of Python functions for formatting STIX data, which is oftentimes inconsistent across objects. For example, errant \n characters are replaced with <br> on mitigations but not on techniques.
The formatting and cleaning code needs to be consolidated and made easy to use by those developing and extending the website code.
There are two different ways we format long-form text:
- In object descriptions, we use a long-form format which parses from markdown, (consistently) replaces certain characters, and inserts citation markers.
- In relationship tables, we use a short-form format which oftentimes only takes the first paragraph of the data as a summary and omits the citation markers.
The solution
Replace the current solutions with a jinja macro. Replace all instances of {{ data }} with {{ stixToHTML(...) }} within the templates
stixToHTML(data, citations=None, firstParagraphOnly=False) should be implemented as a catch-all macro for formatting STIX data as HTML. Parameters:
data (required, string), the STIX description to format
citations (optional, object), if not None, add citation markers to the data. Citations object data structure TBD. Consider formatting as a Citation[], and implementing a python Citation class, to ensure consistancy.
firstParagraphOnly (optional, boolean), if true, only return the first paragraph of the data in question.
As a developer of the ATT&CK website, I want to be able to easily and consistently format STIX descriptions when I'm creating or modifying templates.
The problem
Currently, we use a myriad of Python functions for formatting STIX data, which is oftentimes inconsistent across objects. For example, errant
\ncharacters are replaced with<br>on mitigations but not on techniques.The formatting and cleaning code needs to be consolidated and made easy to use by those developing and extending the website code.
There are two different ways we format long-form text:
The solution
Replace the current solutions with a jinja macro. Replace all instances of
{{ data }}with{{ stixToHTML(...) }}within the templatesstixToHTML(data, citations=None, firstParagraphOnly=False)should be implemented as a catch-all macro for formatting STIX data as HTML. Parameters:data(required, string), the STIX description to formatcitations(optional, object), if notNone, add citation markers to the data. Citations object data structure TBD. Consider formatting as a Citation[], and implementing a pythonCitationclass, to ensure consistancy.firstParagraphOnly(optional, boolean), if true, only return the first paragraph of the data in question.