Skip to content

Commit

Permalink
Produce empty array of CCI tags in JSONIX->CKL mapper if the input JS…
Browse files Browse the repository at this point in the history
…ONIX is an empty string representing the serialized CCI tags

Signed-off-by: Joyce Quach <[email protected]>
  • Loading branch information
jtquach1 committed Nov 22, 2024
1 parent ccf28b7 commit 3ada0d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export class ChecklistJsonixConverter extends JsonixIntermediateConverter<
const results = data.filter((attribute: T) => {
return _.get(attribute, keyName) == tag;
});
// This produces a string that looks like '' or /(w+); (w+)/.
return results.map((result: T) => _.get(result, dataName)).join('; ');
}

Expand Down
13 changes: 11 additions & 2 deletions libs/hdf-converters/src/ckl-mapper/checklist-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ enum ImpactMapping {
}

/**
* Tranformer function that splits a string and return array
* Transformer function that splits a string and return array
* @param input - string of CCI references
* @returns ref - array of CCI references
*/
function cciRef(input: string): string[] {
return input.split('; ');
/* Input string from CKL->jsonix could look like '' or 'CCI-001234; CCI-005678'.
The former comes from this tag in the originating CKL:
<STIG_DATA>
<VULN_ATTRIBUTE>CCI_REF</VULN_ATTRIBUTE>
<ATTRIBUTE_DATA></ATTRIBUTE_DATA>
</STIG_DATA>
*/
const CCI_REGEX = /CCI-(\d*)/g;
const foundCcis = input.match(CCI_REGEX);
return foundCcis || [];
}

/**
Expand Down

0 comments on commit 3ada0d5

Please sign in to comment.