Jinja and Runbooks/Procedures

The following is the raw Jinja code from our implementation of Runbook/Engagement into Report calling of Procedures and Engagement statistics.

Report Procedures

{%p for procedure in REPORT_INFO.REPORT_PROCEDURES %}
{{ procedure.name }}
Description:
{{p procedure.description }}
{%p if 'reportedBy' in procedure %}
Reporters:
{%p for reporter in procedure.reportedBy %}
{{ reporter.name }}
{%p endfor %}
{%p endif %}
{%p if 'outcomeRed' in procedure %}
Outcome red:
{{ procedure.outcomeRed }}
{%p endif %}
{%p if 'outcomeBlue' in procedure %}
Outcome blue:
{{ procedure.outcomeBlue }}
{%p endif %}
{%p if 'customFields' in procedure %}
{%p for field in procedure.customFields %}
{{ field.label }}
{{p field.text }}
{%p endfor %}
{%p endif %}
{%p if procedure.exhibits %}
Exhibits:
{%p for exhibit in procedure.exhibits %}
{%p if exhibit.caption %}
{{ exhibit.caption }}
{%p endif %}
{%p if exhibit.path %}
{{ exhibit.path }}
{%p endif %}
{%p endfor %}
{%p endif %}
{%p endfor %}

Runbooks Appendix

Tested Tactics

{%p for key, tactic in REPORT_INFO.RUNBOOKS_APPENDIX.get('tactics').items()%}
{{ tactic.name }}
Short name: {{ tactic.shortName }}
{%p if 'description' in tactic and tactic.description %}
{{p tactic.description }}
{%p endif %}
Success/Failure/Coverage Criteria:
{%p if 'total_detections' in tactic and tactic.total_detections %}
Total detections: {{ tactic.total_detections }}
{%p endif %}
{%p if 'total_failures' in tactic and tactic.total_failures %}
Total failures: {{ tactic.total_failures }}
{%p endif %}
{%p if 'total_incomplete_attacks' in tactic and tactic.total_incomplete_attacks %}
Total incomplete attacks: {{ tactic.total_incomplete_attacks }}
{%p endif %}
{%p if 'total_incomplete_detects' in tactic and tactic.total_incomplete_detects %}
Total incomplete detections: {{ tactic.total_incomplete_detects }}
{%p endif %}
{%p if 'total_failed_detections' in tactic and tactic.total_failed_detections %}
Total failed detections: {{ tactic.total_failed_detections }}
{%p endif %}
{%p if 'total_successes' in tactic and tactic.total_successes %}
Total successes: {{ tactic.total_successes }}
{%p endif %}
{%p if 'total_tests' in tactic and tactic.total_tests %}
Total tests executed: {{ tactic.total_tests }}
{%p endif %}
{%p endfor %}

Tested Techniques

{%p for key, technique in REPORT_INFO.RUNBOOKS_APPENDIX.get('techniques').items()%}
{{ technique.name }}
Short name: {{ technique.shortName }}
{%p if 'description' in technique and technique.description %}
{{p technique.description }}
{%p endif %}
Success/Failure/Coverage Criteria:
{%p if 'total_detections' in technique and technique.total_detections %}
Total detections: {{ technique.total_detections }}
{%p endif %}
{%p if 'total_failures' in technique and technique.total_failures %}
Total failures: {{ technique.total_failures }}
{%p endif %}
{%p if 'total_incomplete_attacks' in technique and technique.total_incomplete_attacks %}
Total incomplete attacks: {{ technique.total_incomplete_attacks }}
{%p endif %}
{%p if 'total_incomplete_detects' in technique and technique.total_incomplete_detects %}
Total incomplete detections: {{ technique.total_incomplete_detects }}
{%p endif %}
{%p if 'total_failed_detections' in technique and technique.total_failed_detections %}
Total failed detections: {{ technique.total_failed_detections }}
{%p endif %}
{%p if 'total_successes' in technique and technique.total_successes %}
Total successes: {{ technique.total_successes }}
{%p endif %}
{%p if 'total_tests' in technique and technique.total_tests %}
Total tests executed: {{ technique.total_tests }}
{%p endif %}
{%p endfor %}

Runbooks Statistics

{%p for stat in REPORT_INFO.RUNBOOKS_STATISTICS %}
{%p if stat.label != '' %}
{{ stat.label }}: {{ stat.value }}
{%p endif %}
{%p endfor %}