Skip to content

Refactor STIX cleaning code into macro #161

Description

@isaisabel

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:

  1. In object descriptions, we use a long-form format which parses from markdown, (consistently) replaces certain characters, and inserts citation markers.
  2. 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.

Metadata

Metadata

Assignees

Labels

timescale/short-termBecomes timescale/imminent in weeks or months

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions