Skip to content

${today} is not rendered inside headers/footers #143

Description

@ZuhaibT

When a report template places the ${today} variable in a page header or footer, Faction generates the report without replacing it — the literal string ${today} survives into the delivered .docx. The same variable works correctly in the document body. This forces a manual post-processing step on every generated report.

Steps to reproduce

  1. Edit a report template so the header (or footer) contains the text ${today}.
  2. Generate a .docx report for any assessment.
  3. Open the produced report and inspect the header/footer.

Expected

${today} is replaced with the current date (default format MM/dd/yyyy, or a custom format via ${today <pattern>}), exactly as it is in the document body.

Actual

The header/footer still shows the literal text ${today}. Only body occurrences are replaced.

Root cause

  1. Date variables are substituted by replacementDate(String key, Date date). That method rewrites only the main document part:

    private void replacementDate(String key, Date date) {
        String xml = XmlUtils.marshaltoString(
            this.mlp.getMainDocumentPart().getContents(), false, false);
        xml = DocxUtils.replaceDateVariable(xml, key, date);
        this.mlp.getMainDocumentPart().setContents(
            (Document) XmlUtils.unmarshalString(xml));
    }

It never touches HeaderPart / FooterPart. So today, asmtStart, and asmtEnd — all pushed through replacementDate(...) — are only ever resolved in the body.

  1. Headers and footers are processed separately, by replaceHeaderAndFooter(Map<String,String> replacements), which does a plain xml.replace("${" + key + "}", value) for each entry in the map. But the map built in replaceAssessment(...) only ever receives non-date keys (asmtName, asmtId, asmtAppId, asmtType, remediation, custom fields cf*, vuln totals, etc.). today (and the other date keys) are never put into that map, because dates are handled by the body-only replacementDate(...) path above.

Net effect: date variables have no code path that reaches header/footer parts.

Notes

  • This cannot be fixed from a report ReportManager extension: extensions only receive main-document paragraph text (updateDocWithExtensions / replacement) and never see HeaderPart / FooterPart content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions