blackstork-io / fabric

An open-source command-line tool for reporting workflow automation and a configuration language for reusable templates. Reporting-as-Code
https://blackstork.io/fabric/
Apache License 2.0
10 stars 0 forks source link

Incorrect nesting of the titles in ToC #165

Open traut opened 3 weeks ago

traut commented 3 weeks ago

Description

While working on OffSec OSCP exam report template, which has many titles, I noticed that the produced ToC has incorrect nesting.

For this nested structure (code snippet):

  section "active_directory_systems" {
    title = "Active Directory Systems"

    section "target_1" {
      title = "Target #1 - {{ (index .data.inline.findings.hosts_in_ad 0).host }}"

      section "service_enumeration" {
        title = "Service Enumeration"

        section "port_scan_results" {
          title = "Port Scan Results"

the ToC generated looks like this (full doc):

- Active Directory Systems
  - Target #1 - 192.168.x.1
  - Service Enumeration
    - Port Scan Results
  - Initial Access - Anonymous SMB share leads to Wordpress RCE
  - Privilege Escalation - Scripts running as root user

The ToC content provider is configured with start and end levels (code):

  content toc {
    start_level = 1
    end_level = 4
  }

Environment

Fabric version: 0.4.1 Operating System: macOS Sonoma

How to reproduce

fabric render document.offsec_oscp_exam_report

Expected Behavior

The ToC should have correct nesting:

- Active Directory Systems
  - Target #1 - 192.168.x.1
    - Service Enumeration
      - Port Scan Results
    - Initial Access - Anonymous SMB share leads to Wordpress RCE
    - Privilege Escalation - Scripts running as root user

Additional Context