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
- Edit a report template so the header (or footer) contains the text
${today}.
- Generate a
.docx report for any assessment.
- 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
-
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.
- 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.
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
${today}..docxreport for any assessment.Expected
${today}is replaced with the current date (default formatMM/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
Date variables are substituted by
replacementDate(String key, Date date). That method rewrites only the main document part:It never touches
HeaderPart/FooterPart. Sotoday,asmtStart, andasmtEnd— all pushed throughreplacementDate(...)— are only ever resolved in the body.replaceHeaderAndFooter(Map<String,String> replacements), which does a plainxml.replace("${" + key + "}", value)for each entry in the map. But the map built inreplaceAssessment(...)only ever receives non-date keys (asmtName,asmtId,asmtAppId,asmtType,remediation, custom fieldscf*, vuln totals, etc.).today(and the other date keys) are never put into that map, because dates are handled by the body-onlyreplacementDate(...)path above.Net effect: date variables have no code path that reaches header/footer parts.
Notes
ReportManagerextension: extensions only receive main-document paragraph text (updateDocWithExtensions/replacement) and never seeHeaderPart/FooterPartcontent.