diff --git a/lib/HTMLTemplate2_0.js b/lib/HTMLTemplate2_0.js
index 4c6b0ef..1d36384 100644
--- a/lib/HTMLTemplate2_0.js
+++ b/lib/HTMLTemplate2_0.js
@@ -5,6 +5,7 @@ import {
DOCUMENT_NOTE,
REFERENCE,
REMEDIATION,
+ SCOPE,
THREAT,
URL,
VULNERABILITY_NOTE,
@@ -41,6 +42,7 @@ export default function HTMLTemplate2_0({ document }) {
document_note: DOCUMENT_NOTE,
acknowledgment: ACKNOWLEDGEMENT,
reference: REFERENCE,
+ scope: SCOPE,
url: URL,
})
}
diff --git a/lib/HTMLTemplate2_1.js b/lib/HTMLTemplate2_1.js
index db27d33..c32bc83 100644
--- a/lib/HTMLTemplate2_1.js
+++ b/lib/HTMLTemplate2_1.js
@@ -2,9 +2,11 @@ import Mustache from 'mustache'
import Template from './templates/csaf_2_1.js'
import {
ACKNOWLEDGEMENT,
+ CONTACT,
DOCUMENT_NOTE,
REFERENCE,
REMEDIATION,
+ SCOPE,
THREAT,
URL,
VULNERABILITY_NOTE,
@@ -43,6 +45,8 @@ export default function HTMLTemplate2_1({ document }) {
document_note: DOCUMENT_NOTE,
acknowledgment: ACKNOWLEDGEMENT,
reference: REFERENCE,
+ scope: SCOPE,
+ contact: CONTACT,
url: URL,
})
}
diff --git a/lib/enrichDocument.js b/lib/enrichDocument.js
index 9ecca14..8cb534f 100644
--- a/lib/enrichDocument.js
+++ b/lib/enrichDocument.js
@@ -112,6 +112,20 @@ const collectProductIds = (document) => {
}
}
+ const productPaths = document.product_tree?.product_paths
+ if (productPaths) {
+ for (let i = 0; i < productPaths.length; ++i) {
+ const fullProductName = productPaths[i]?.full_product_name
+ if (fullProductName?.product_id) {
+ entries.push({
+ id: fullProductName.product_id,
+ name: fullProductName.name ?? '',
+ instancePath: `/product_tree/product_paths/${i}/full_product_name/product_id`,
+ })
+ }
+ }
+ }
+
const branches = document.product_tree?.branches
if (branches) {
traverseBranches(branches, entries, '/product_tree/branches')
@@ -147,8 +161,10 @@ const collectGroupIds = (document) => {
/**
* @param {any} document
+ * @param {Map} productIds
+ * @param {Map} groupIds
*/
-const addDocumentNotesPreviewAttributes = (document) => {
+const addDocumentNotesPreviewAttributes = (document, productIds, groupIds) => {
const summary = []
const details = []
const general = []
@@ -162,6 +178,7 @@ const addDocumentNotesPreviewAttributes = (document) => {
if (notes) {
for (let i = 0; i < notes.length; ++i) {
const note = notes[i]
+ extendScopedItem(note, productIds, groupIds)
switch (note.category) {
case 'summary':
summary.push(note)
@@ -202,8 +219,14 @@ const addDocumentNotesPreviewAttributes = (document) => {
/**
* @param {any} vulnerability
+ * @param {Map} productIds
+ * @param {Map} groupIds
*/
-const addVulnerabilityNotesPreviewAttributes = (vulnerability) => {
+const addVulnerabilityNotesPreviewAttributes = (
+ vulnerability,
+ productIds,
+ groupIds,
+) => {
const summary = []
const details = []
const general = []
@@ -217,6 +240,7 @@ const addVulnerabilityNotesPreviewAttributes = (vulnerability) => {
if (notes) {
for (let i = 0; i < notes.length; ++i) {
const note = notes[i]
+ extendScopedItem(note, productIds, groupIds)
switch (note.category) {
case 'summary':
summary.push(note)
@@ -378,6 +402,23 @@ const extendRemediationOrThreat = (
}
}
+/**
+ * Like `extendRemediationOrThreat`, but for items where `product_ids` and
+ * `group_ids` are optional extras (e.g. CSAF 2.1 notes, vulnerability ids,
+ * first known exploitation dates, involvement actions): items without either
+ * property are left untouched, so documents that don't use them (all of CSAF
+ * 2.0) keep their exact shape.
+ *
+ * @param {any} item
+ * @param {Map} extProductIds
+ * @param {Map} extGroupIds
+ */
+const extendScopedItem = (item, extProductIds, extGroupIds) => {
+ if (item && (item.product_ids || item.group_ids)) {
+ extendRemediationOrThreat(item, extProductIds, extGroupIds)
+ }
+}
+
/**
* Sorts by `date` descending (most recent first), with entries that have no
* `date` at all (a valid, optional field on CSAF remediations/threats)
@@ -410,8 +451,10 @@ const addRemediationsPreviewAttributes = (
groupIds,
) => {
const vendorFix = []
+ const optionalPatch = []
const mitigation = []
const workaround = []
+ const fixPlanned = []
const noneAvailable = []
const noFixPlanned = []
const unknown = []
@@ -424,12 +467,18 @@ const addRemediationsPreviewAttributes = (
case 'vendor_fix':
vendorFix.push(remediation)
break
+ case 'optional_patch':
+ optionalPatch.push(remediation)
+ break
case 'mitigation':
mitigation.push(remediation)
break
case 'workaround':
workaround.push(remediation)
break
+ case 'fix_planned':
+ fixPlanned.push(remediation)
+ break
case 'none_available':
noneAvailable.push(remediation)
break
@@ -443,8 +492,10 @@ const addRemediationsPreviewAttributes = (
}
vulnerability.remediations_vendor_fix = vendorFix.sort(sortByDate)
+ vulnerability.remediations_optional_patch = optionalPatch.sort(sortByDate)
vulnerability.remediations_mitigation = mitigation.sort(sortByDate)
vulnerability.remediations_workaround = workaround.sort(sortByDate)
+ vulnerability.remediations_fix_planned = fixPlanned.sort(sortByDate)
vulnerability.remediations_none_available = noneAvailable.sort(sortByDate)
vulnerability.remediations_no_fix_planned = noFixPlanned.sort(sortByDate)
vulnerability.remediations_unknown = unknown.sort(sortByDate)
@@ -746,7 +797,132 @@ const addProductStatusPreviewAttributesV2_1 = (
extendedMetricIds,
productIds,
)
+ productStatus.unknown = extendProductStatus(
+ productStatus.unknown,
+ extendedMetricIds,
+ productIds,
+ )
+ }
+}
+
+/**
+ * Resolves the CSAF 2.1 `document.involvement` references into display names:
+ * entity/entity group refs in actions and entity ids in entity groups become
+ * `{id, name}` pairs (falling back to the id when the entity has no `name`),
+ * and product/group ids of actions are resolved like for remediations.
+ *
+ * @param {any} document
+ * @param {Map} productIds
+ * @param {Map} groupIds
+ */
+const addInvolvementPreviewAttributes = (document, productIds, groupIds) => {
+ const involvement = document?.involvement
+ if (!involvement) return
+
+ /** @type {Map} */
+ const entityNames = new Map()
+ for (const entity of involvement.entities ?? []) {
+ entity.display_name = entity.name ?? entity.entity_id
+ entityNames.set(entity.entity_id, entity.display_name)
+ }
+ for (const group of involvement.entity_groups ?? []) {
+ entityNames.set(group.entity_group_id, group.name ?? group.entity_group_id)
+ }
+
+ /** @param {string[] | undefined} ids */
+ const toEntityRefs = (ids) =>
+ ids
+ ? ids
+ .filter(Boolean)
+ .map((id) => ({ id, name: entityNames.get(id) ?? id }))
+ : undefined
+
+ for (const group of involvement.entity_groups ?? []) {
+ group.entity_ids = toEntityRefs(group.entity_ids)
+ }
+ for (const action of involvement.actions ?? []) {
+ action.acting_entity_refs = toEntityRefs(action.acting_entity_refs)
+ action.receiving_entity_refs = toEntityRefs(action.receiving_entity_refs)
+ extendScopedItem(action, productIds, groupIds)
+ }
+}
+
+/**
+ * Condenses a (SSVC v2 selection list) into plain strings the template can
+ * print without having to pick between optional `name` and required `key`
+ * fields itself.
+ *
+ * @param {any} ssvc
+ */
+const summarizeSsvc = (ssvc) => ({
+ timestamp: ssvc.timestamp,
+ selections: (ssvc.selections ?? []).map((/** @type {any} */ selection) => ({
+ label: selection.name ?? selection.key,
+ namespace: selection.namespace,
+ version: selection.version,
+ values: (selection.values ?? [])
+ .map((/** @type {any} */ value) => value.name ?? value.key)
+ .join(', '),
+ })),
+})
+
+/**
+ * Collects the parts of CSAF 2.1 `vulnerability.metrics[]` that are not CVSS
+ * (which is already shown in the product status tables): the qualitative
+ * severity rating, EPSS and SSVC v2 data, together with the products and
+ * source they belong to. Written to `vulnerability.metrics_details`.
+ *
+ * @param {any} vulnerability
+ * @param {Map} productIds
+ */
+const addMetricsDetailsPreviewAttributes = (vulnerability, productIds) => {
+ const details = []
+ for (const metric of vulnerability.metrics ?? []) {
+ const content = metric?.content
+ if (!content) continue
+ const rating = content.qualitative_severity_rating
+ const epss = content.epss
+ const ssvc = content.ssvc_v2
+ if (!rating && !epss && !ssvc) continue
+ details.push({
+ products: (metric.products ?? [])
+ .filter(Boolean)
+ .map((/** @type {string} */ id) => ({
+ id,
+ name: productIds.get(id)?.name || id,
+ })),
+ source: metric.source,
+ qualitative_severity_rating: rating,
+ epss,
+ ssvc: ssvc ? summarizeSsvc(ssvc) : undefined,
+ })
+ }
+ vulnerability.metrics_details = details
+}
+
+/**
+ * Resolves product/group ids of the CSAF 2.1 vulnerability properties that
+ * can be scoped to products (`ids`, `first_known_exploitation_dates`) and
+ * collects the `ids` that actually are scoped in `vulnerability.ids_scoped`.
+ *
+ * @param {any} vulnerability
+ * @param {Map} productIds
+ * @param {Map} groupIds
+ */
+const addVulnerabilityScopePreviewAttributes = (
+ vulnerability,
+ productIds,
+ groupIds,
+) => {
+ for (const item of vulnerability.first_known_exploitation_dates ?? []) {
+ extendScopedItem(item, productIds, groupIds)
+ }
+ const scopedIds = []
+ for (const id of vulnerability.ids ?? []) {
+ extendScopedItem(id, productIds, groupIds)
+ if (id?.product_ids?.length || id?.group_ids?.length) scopedIds.push(id)
}
+ vulnerability.ids_scoped = scopedIds
}
// ---------------------------------------------------------------------------
@@ -769,7 +945,11 @@ export function enrichDocumentV2_0(document) {
templateDoc.document.max_base_score = retrieveMaxBaseScoreV2_0(
templateDoc.vulnerabilities,
)
- addDocumentNotesPreviewAttributes(templateDoc.document)
+ addDocumentNotesPreviewAttributes(
+ templateDoc.document,
+ productIds,
+ groupIds,
+ )
}
if (templateDoc.product_tree) {
@@ -787,7 +967,11 @@ export function enrichDocumentV2_0(document) {
)
addRemediationsPreviewAttributes(vulnerability, productIds, groupIds)
addThreatsPreviewAttributes(vulnerability, productIds, groupIds)
- addVulnerabilityNotesPreviewAttributes(vulnerability)
+ addVulnerabilityNotesPreviewAttributes(
+ vulnerability,
+ productIds,
+ groupIds,
+ )
}
}
@@ -801,7 +985,7 @@ export function enrichDocumentV2_0(document) {
/**
* Enriches a CSAF 2.1 document for use with HTMLTemplate2_1.
- * Uses `vulnerability.metrics[i].content.cvss_v3` for CVSS data.
+ * Uses `vulnerability.metrics[i].content` (CVSS v2/v3/v4) for CVSS data.
*
* @param {any} document
* @returns {{ document: any }}
@@ -819,7 +1003,12 @@ export function enrichDocumentV2_1(document) {
templateDoc.document.max_base_score_cvss_label = maxBaseScoreCvssVersion
? `CVSSv${maxBaseScoreCvssVersion}`
: 'CVSS'
- addDocumentNotesPreviewAttributes(templateDoc.document)
+ addDocumentNotesPreviewAttributes(
+ templateDoc.document,
+ productIds,
+ groupIds,
+ )
+ addInvolvementPreviewAttributes(templateDoc.document, productIds, groupIds)
}
if (templateDoc.product_tree) {
@@ -837,7 +1026,17 @@ export function enrichDocumentV2_1(document) {
)
addRemediationsPreviewAttributes(vulnerability, productIds, groupIds)
addThreatsPreviewAttributes(vulnerability, productIds, groupIds)
- addVulnerabilityNotesPreviewAttributes(vulnerability)
+ addVulnerabilityNotesPreviewAttributes(
+ vulnerability,
+ productIds,
+ groupIds,
+ )
+ addVulnerabilityScopePreviewAttributes(
+ vulnerability,
+ productIds,
+ groupIds,
+ )
+ addMetricsDetailsPreviewAttributes(vulnerability, productIds)
}
}
diff --git a/lib/markdownParser.js b/lib/markdownParser.js
index cfd9496..eb01f47 100644
--- a/lib/markdownParser.js
+++ b/lib/markdownParser.js
@@ -13,7 +13,11 @@ const { get, set } = lodash
const markdownFields = [
'document.acknowledgments.*.summary',
'document.distribution.text',
+ 'document.involvement.actions.*.summary',
+ 'document.involvement.entities.*.contact.details',
+ 'document.involvement.entity_groups.*.summary',
'document.notes.*.text',
+ 'document.publisher.contact.details',
'document.publisher.issuing_authority',
'document.references.*.summary',
'document.tracking.revision_history.*.summary',
@@ -36,6 +40,14 @@ const markdownFields = [
// as raw, unrendered markdown wherever it's referenced via group_ids.
'vulnerabilities.*.remediations.*.group_ids.*.name',
'vulnerabilities.*.threats.*.group_ids.*.name',
+ // CSAF 2.1: same reasoning as above, for every other item enrichDocument
+ // resolves `group_ids` on (notes, involvement actions, vulnerability ids
+ // and first known exploitation dates).
+ 'document.notes.*.group_ids.*.name',
+ 'document.involvement.actions.*.group_ids.*.name',
+ 'vulnerabilities.*.notes.*.group_ids.*.name',
+ 'vulnerabilities.*.ids.*.group_ids.*.name',
+ 'vulnerabilities.*.first_known_exploitation_dates.*.group_ids.*.name',
]
/**
diff --git a/lib/mustachePartials.js b/lib/mustachePartials.js
index 5438b87..bd2d1ec 100644
--- a/lib/mustachePartials.js
+++ b/lib/mustachePartials.js
@@ -1,5 +1,7 @@
// Mustache partials shared between HTMLTemplate2_0.js and HTMLTemplate2_1.js.
-// These are identical between CSAF 2.0 and 2.1, unlike PRODUCT_STATUS_HEADER
+// These are identical between CSAF 2.0 and 2.1 (the 2.1-only properties they
+// render, like note product_ids, are simply absent in 2.0 documents), unlike
+// PRODUCT_STATUS_HEADER
// and PRODUCT_STATUS_ROW (which differ - CSAF 2.1 adds a CVSS Version
// column), so those two stay defined separately in each HTMLTemplate file.
@@ -51,14 +53,45 @@ export const THREAT = `
{{/group_ids.length}}`
+// Lists the products/groups an item is scoped to. Only CSAF 2.1 has items
+// carrying `product_ids`/`group_ids` besides remediations and threats (notes,
+// vulnerability ids, first known exploitation dates, involvement actions); for
+// all other items, and for all CSAF 2.0 documents, this renders nothing.
+export const SCOPE = `
+{{#product_ids.length}}
+ For products:
+
+ {{#product_ids}}
+ - {{name}}
+ {{/product_ids}}
+
+{{/product_ids.length}}
+{{#group_ids.length}}
+ For groups:
+
+ {{#group_ids}}
+ - {{{name}}}
+ {{/group_ids}}
+
+{{/group_ids.length}}`
+
+// CSAF 2.1 `contact_t` (publisher.contact, involvement.entities[].contact).
+export const CONTACT = `
+{{#details}}{{{.}}}
{{/details}}
+{{#email}}Email: {{.}}
{{/email}}
+{{#url}}URL: {{> url}}
{{/url}}
+{{#public_openpgp_key_url}}Public OpenPGP key: {{> url}}
{{/public_openpgp_key_url}}`
+
export const VULNERABILITY_NOTE = `
{{#title}}{{.}}{{/title}}{{#audience}} ({{.}}){{/audience}}
-{{#text}}{{{text}}}
{{/text}}`
+{{#text}}{{{text}}}
{{/text}}
+{{> scope}}`
export const DOCUMENT_NOTE = `
{{#title}}{{.}}
{{/title}}
{{#audience}}{{.}}{{/audience}}
-{{#text}}{{{text}}}
{{/text}}`
+{{#text}}{{{text}}}
{{/text}}
+{{> scope}}`
export const ACKNOWLEDGEMENT = `
{{#.}}
diff --git a/lib/templates/csaf_2_0.js b/lib/templates/csaf_2_0.js
index 4e59d50..5f2ad67 100644
--- a/lib/templates/csaf_2_0.js
+++ b/lib/templates/csaf_2_0.js
@@ -1,4 +1,4 @@
-import { BIG, HEAD, MID, TAIL } from './sharedTemplateParts.js'
+import { buildTemplate } from './sharedTemplateParts.js'
const CVSS = ` CVSSv3.1 Base Score: {{document.max_base_score}} | `
@@ -25,9 +25,26 @@ const CWE = `
{{/release_date}}`
-export default `${HEAD}
-${CVSS}
-${MID}
-${CWE}
-${BIG}
-${TAIL}`
+// CSAF 2.0 only: removed in CSAF 2.1 in favor of document.involvement.
+const INVOLVEMENTS = `
+
+ {{#involvements.length}}
+ Involvement
+
+ {{#involvements}}
+ {{#.}}
+ - {{#date}}{{.}} {{/date}}{{#upperCase}}{{party}}{{/upperCase}}{{#status}} ({{#replaceUnderscores}}{{.}}{{/replaceUnderscores}}){{/status}}{{#summary}}: {{{.}}}{{/summary}}
+ {{/.}}
+ {{/involvements}}
+
+ {{/involvements.length}}`
+
+// CSAF 2.0: `contact_details` is a plain string.
+const PUBLISHER_CONTACT = ` {{contact_details}}
`
+
+export default buildTemplate({
+ cvss: CVSS,
+ vulnerabilityRows: CWE,
+ involvements: INVOLVEMENTS,
+ publisherContact: PUBLISHER_CONTACT,
+})
diff --git a/lib/templates/csaf_2_1.js b/lib/templates/csaf_2_1.js
index 2ca7d17..db94046 100644
--- a/lib/templates/csaf_2_1.js
+++ b/lib/templates/csaf_2_1.js
@@ -1,7 +1,14 @@
-import { BIG, HEAD, MID, TAIL } from './sharedTemplateParts.js'
+import { buildTemplate } from './sharedTemplateParts.js'
const CVSS = ` {{document.max_base_score_cvss_label}} Base Score: {{document.max_base_score}} | `
+const LICENSE_EXPRESSION = `
+ {{#document.license_expression}}
+
+ | License expression: {{.}} |
+
+ {{/document.license_expression}}`
+
const CWE = ` CWE's
{{#cwes}}
@@ -25,7 +32,131 @@ const CWE = ` CWE's
Disclosure date: |
{{disclosure_date}} |
- {{/disclosure_date}}`
+ {{/disclosure_date}}
+ {{#dl_vuln_id}}
+
+ | Document-local ID: |
+ {{.}} |
+
+ {{/dl_vuln_id}}`
+
+const PRODUCT_STATUS_UNKNOWN = `
+
+ {{#product_status.unknown.length}}
+ Unknown
+
+ {{#product_status.unknown}}
+ - {{name}}
+ {{/product_status.unknown}}
+
+ {{/product_status.unknown.length}}`
+
+const VULNERABILITY_EXTRA = `
+
+ {{#first_known_exploitation_dates.length}}
+ First known exploitation dates
+ {{#first_known_exploitation_dates}}
+ {{exploitation_date}}{{#date}} (information from {{.}}){{/date}}
+ {{> scope}}
+ {{/first_known_exploitation_dates}}
+ {{/first_known_exploitation_dates.length}}
+
+ {{#ids_scoped.length}}
+ Scoped IDs
+ {{#ids_scoped}}
+ {{text}}{{#system_name}} ({{.}}){{/system_name}}
+ {{> scope}}
+ {{/ids_scoped}}
+ {{/ids_scoped.length}}
+
+ {{#metrics_details.length}}
+ Metrics
+ {{#metrics_details}}
+
+ {{#qualitative_severity_rating}}
+ - Qualitative severity rating: {{#upperCase}}{{.}}{{/upperCase}}
+ {{/qualitative_severity_rating}}
+ {{#epss}}
+ - EPSS: probability {{probability}}, percentile {{percentile}} ({{timestamp}})
+ {{/epss}}
+ {{#ssvc}}
+ - SSVC{{#timestamp}} ({{.}}){{/timestamp}}
+
+ {{#selections}}
+ - {{label}}: {{values}}
+ {{/selections}}
+
+
+ {{/ssvc}}
+ {{#products.length}}
+ - For products: {{#removeTrailingComma}}{{#products}}{{name}}, {{/products}}{{/removeTrailingComma}}
+ {{/products.length}}
+ {{#source}}
+ - Source: {{> url}}
+ {{/source}}
+
+ {{/metrics_details}}
+ {{/metrics_details.length}}`
+
+const PUBLISHER_CONTACT = ` {{#contact}}{{> contact}}{{/contact}}`
+
+const INVOLVEMENT = `
+
+ {{#document.involvement}}
+ Involvement
+
+ {{#entities.length}}
+ Entities
+
+ {{#entities}}
+ -
+ {{display_name}} ({{#replaceUnderscores}}{{category}}{{/replaceUnderscores}}, {{entity_id}})
+ {{#contact}}{{> contact}}{{/contact}}
+
+ {{/entities}}
+
+ {{/entities.length}}
+
+ {{#entity_groups.length}}
+ Entity groups
+
+ {{/entity_groups.length}}
+
+ {{#actions.length}}
+ Actions
+
+ {{#actions}}
+ -
+ {{date}}: {{#replaceUnderscores}}{{#upperCase}}{{category}}{{/upperCase}}{{/replaceUnderscores}} ({{#replaceUnderscores}}{{status}}{{/replaceUnderscores}}, {{action_id}})
+ {{#acting_entity_refs.length}}
+
By: {{#removeTrailingComma}}{{#acting_entity_refs}}{{name}}, {{/acting_entity_refs}}{{/removeTrailingComma}}
+ {{/acting_entity_refs.length}}
+ {{#receiving_entity_refs.length}}
+
To: {{#removeTrailingComma}}{{#receiving_entity_refs}}{{name}}, {{/receiving_entity_refs}}{{/removeTrailingComma}}
+ {{/receiving_entity_refs.length}}
+ {{#dl_vuln_ids.length}}
+
Vulnerabilities: {{#removeTrailingComma}}{{#dl_vuln_ids}}{{.}}, {{/dl_vuln_ids}}{{/removeTrailingComma}}
+ {{/dl_vuln_ids.length}}
+ {{#referenced_action_ids.length}}
+
Refers to actions: {{#removeTrailingComma}}{{#referenced_action_ids}}{{.}}, {{/referenced_action_ids}}{{/removeTrailingComma}}
+ {{/referenced_action_ids.length}}
+ {{#summary}}{{{.}}}
{{/summary}}
+ {{> scope}}
+
+ {{/actions}}
+
+ {{/actions.length}}
+ {{/document.involvement}}`
const SHARING_GROUP = ` {{#sharing_group}}
Sharing Group
@@ -35,10 +166,13 @@ const SHARING_GROUP = ` {{#sharing_group}}
`
-export default `${HEAD}
-${CVSS}
-${MID}
-${CWE}
-${BIG}
-${SHARING_GROUP}
-${TAIL}`
+export default buildTemplate({
+ cvss: CVSS,
+ headerRows: LICENSE_EXPRESSION,
+ vulnerabilityRows: CWE,
+ productStatusExtra: PRODUCT_STATUS_UNKNOWN,
+ vulnerabilityExtra: VULNERABILITY_EXTRA,
+ publisherContact: PUBLISHER_CONTACT,
+ documentExtra: INVOLVEMENT,
+ sharingGroup: SHARING_GROUP,
+})
diff --git a/lib/templates/sharedTemplateParts.js b/lib/templates/sharedTemplateParts.js
index 9fddd23..eb762bc 100644
--- a/lib/templates/sharedTemplateParts.js
+++ b/lib/templates/sharedTemplateParts.js
@@ -2,11 +2,27 @@ import gutenbergCss from '../css/gutenberg.js'
import modernCss from '../css/modern.js'
import previewCss from '../css/preview.js'
-// Shared, version-independent building blocks of the csaf_2_0.js and
-// csaf_2_1.js top-level HTML templates. These two CSAF versions render an
-// almost identical document; the only real differences are the CVSS label
-// row, the CWE/date fields, and the CSAF 2.1-only sharing_group block, which
-// stay defined separately in each templates/csaf_2_*.js file.
+// Shared building blocks of the csaf_2_0.js and csaf_2_1.js top-level HTML templates.
+// Both CSAF versions render the same overall document layout,
+// but differ in several places (CVSS source, publisher contact,
+// vulnerability involvements, 2.1-only properties such as document.involvement,
+// license_expression, product_status.unknown, metrics, ...).
+// Everything that differs is injected through the named slots of `buildTemplate`,
+// so each templates/csaf_2_*.js file only defines its own version-specific fragments.
+// Every slot defaults to an empty string.
+
+/**
+ * @typedef {Object} TemplateSlots
+ * @property {string} cvss Last cell of the document header table's "Current version" row.
+ * @property {string} [headerRows] Extra rows appended to the document header table.
+ * @property {string} [vulnerabilityRows] Rows inside the vulnerability details table.
+ * @property {string} [productStatusExtra] Extra product status blocks, after "Under investigation".
+ * @property {string} [involvements] Vulnerability-level involvements block.
+ * @property {string} [vulnerabilityExtra] Extra vulnerability sections, after "Threats".
+ * @property {string} [publisherContact] Publisher contact markup inside the publisher block.
+ * @property {string} [documentExtra] Extra document-level sections, after the publisher block.
+ * @property {string} [sharingGroup] Sharing group markup inside the "Sharing rules" block.
+ */
export const HEAD = `
@@ -40,7 +56,8 @@ export const HEAD = `
`
-export const MID = ` | Severity:
+/** @param {string} headerRows */
+export const MID = (headerRows) => ` | Severity:
{{#document.aggregate_severity.namespace}} {{document.aggregate_severity.text}}{{/document.aggregate_severity.namespace}}
{{^document.aggregate_severity.namespace}} {{document.aggregate_severity.text}}{{/document.aggregate_severity.namespace}}
|
@@ -51,7 +68,7 @@ export const MID = ` Severity:
|
| Also referred to: {{#removeTrailingComma}}{{#document.tracking.aliases}}{{.}}, {{/document.tracking.aliases}}{{/removeTrailingComma}} |
-
+ ${headerRows}
{{#document.notes_summary}}
@@ -116,7 +133,16 @@ export const MID = ` Severity:
+/**
+ * @param {Pick, 'productStatusExtra' | 'involvements' | 'vulnerabilityExtra' | 'publisherContact' | 'documentExtra'>} slots
+ */
+export const BIG = ({
+ productStatusExtra,
+ involvements,
+ vulnerabilityExtra,
+ publisherContact,
+ documentExtra,
+}) => `
Product status
{{#product_status.known_affected.length}}
@@ -194,25 +220,31 @@ export const BIG = `
{{/product_status.first_fixed.length}}
{{#product_status.under_investigation.length}}
- Under investgation
+ Under investigation
{{#product_status.under_investigation}}
- {{name}}
{{/product_status.under_investigation}}
- {{/product_status.under_investigation.length}}
+ {{/product_status.under_investigation.length}}${productStatusExtra}
{{#remediations.length}}
Remediations
{{#remediations_vendor_fix}}
{{> remediation}}
{{/remediations_vendor_fix}}
+ {{#remediations_optional_patch}}
+ {{> remediation}}
+ {{/remediations_optional_patch}}
{{#remediations_mitigation}}
{{> remediation}}
{{/remediations_mitigation}}
{{#remediations_workaround}}
{{> remediation}}
{{/remediations_workaround}}
+ {{#remediations_fix_planned}}
+ {{> remediation}}
+ {{/remediations_fix_planned}}
{{#remediations_none_available}}
{{> remediation}}
{{/remediations_none_available}}
@@ -231,18 +263,7 @@ export const BIG = `
{{> acknowledgment}}
{{/acknowledgments}}
- {{/acknowledgments.length}}
-
- {{#involvements.length}}
- Involvement
-
- {{#involvements}}
- {{#.}}
- - {{#date}}{{.}} {{/date}}{{#upperCase}}{{party}}{{/upperCase}}{{#status}} ({{#replaceUnderscores}}{{.}}{{/replaceUnderscores}}){{/status}}{{#summary}}: {{{.}}}{{/summary}}
- {{/.}}
- {{/involvements}}
-
- {{/involvements.length}}
+ {{/acknowledgments.length}}${involvements}
{{#references.length}}
References
@@ -267,7 +288,7 @@ export const BIG = `
{{#threats_unknown}}
{{> threat}}
{{/threats_unknown}}
- {{/threats.length}}
+ {{/threats.length}}${vulnerabilityExtra}
{{/vulnerabilities}}
@@ -288,9 +309,9 @@ export const BIG = `
{{#document.publisher}}
{{name}}
Namespace: {{namespace}}
- {{contact_details}}
+${publisherContact}
{{{issuing_authority}}}
- {{/document.publisher}}
+ {{/document.publisher}}${documentExtra}
{{#document.references.length}}
References
@@ -340,3 +361,38 @@ export const TAIL = ` {{#tlp}}
|