From 11d47a717302667a5ff07eac584414dab99b4b07 Mon Sep 17 00:00:00 2001 From: Joyce Quach Date: Tue, 5 Nov 2024 13:46:47 -0500 Subject: [PATCH] Export variables representing magic strings to be used in NIST2CCI function Signed-off-by: Joyce Quach --- libs/hdf-converters/data/converters/cciListXml2json.ts | 4 ++-- libs/hdf-converters/src/mappings/CciNistMapping.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/hdf-converters/data/converters/cciListXml2json.ts b/libs/hdf-converters/data/converters/cciListXml2json.ts index ea8adebdb..a9b217f40 100644 --- a/libs/hdf-converters/data/converters/cciListXml2json.ts +++ b/libs/hdf-converters/data/converters/cciListXml2json.ts @@ -115,7 +115,8 @@ if (scriptIsCalled) { } } -const CCIS_KEY = 'ccis'; +export const CCIS_KEY = 'ccis'; +export const DELIMITER = ' '; type Leaf = { [CCIS_KEY]?: string[]; @@ -134,7 +135,6 @@ export function removeParentheses(key: string): string { } function unflatten(fullNistPathToListOfCcis: Record): Trie { - const DELIMITER = ' '; const result = {}; const keys = _.keys(fullNistPathToListOfCcis); for (const key of keys) { diff --git a/libs/hdf-converters/src/mappings/CciNistMapping.ts b/libs/hdf-converters/src/mappings/CciNistMapping.ts index a82103f1f..a102933c9 100644 --- a/libs/hdf-converters/src/mappings/CciNistMapping.ts +++ b/libs/hdf-converters/src/mappings/CciNistMapping.ts @@ -2,7 +2,11 @@ import _ from 'lodash'; import {NIST_TO_CCI} from '../mappings/NistCciMappingData'; import {is_control, parse_nist} from 'inspecjs'; import {CCI_TO_NIST} from './CciNistMappingData'; -import {removeParentheses} from '../../data/converters/cciListXml2json'; +import { + CCIS_KEY, + DELIMITER, + removeParentheses +} from '../../data/converters/cciListXml2json'; export function CCI2NIST( identifiers: string[], @@ -29,7 +33,7 @@ export function NIST2CCI( collapse = true ): string[] { const DEFAULT_CCI_TAGS = defaultNist2Cci || []; - const createPath = (nist: string) => [...nist.split(' '), 'ccis']; + const createPath = (nist: string) => [...nist.split(DELIMITER), CCIS_KEY]; const nists = identifiers.map(parse_nist); const controls = nists.filter(is_control); const paths = controls.map((control) =>