Skip to content

Commit

Permalink
Fix code smell
Browse files Browse the repository at this point in the history
Signed-off-by: Joyce Quach <[email protected]>
  • Loading branch information
jtquach1 committed Dec 26, 2024
1 parent da6ebda commit 7ecfcb3
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions libs/hdf-converters/data/converters/cciListXml2json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,34 +125,38 @@ function produceConversions(cciList: ICCIList): {
);
const cciId = cciItem.$.id;

if (newestReference) {
/* There's 1 out of the 2000+ CCI controls where this index string is composed of at
if (!newestReference) {
console.error(`No NIST Controls found for ${cciId}`);
continue;
}

/* There's 1 out of the 2000+ CCI controls where this index string is composed of at
least 2 comma-and-space-separated controls found in the latest revision. */
const {version, creator, index, title} = newestReference.$;
if (creator === 'NIST') {
const nistIds = index
.split(/,\s*/)
.map(parse_nist)
.filter(is_control)
.map((n) => n.canonize());

_.set(
nists,
cciId,
nistIds.map((nist) => ({version, title, nist}))
);
_.set(definitions, cciId, cciItem.definition[0]);

for (const nistId of nistIds) {
if (ccis[nistId] === undefined) {
ccis[nistId] = [cciId];
} else {
ccis[nistId].push(cciId);
}
}
const {version, creator, index, title} = newestReference.$;
if (creator !== 'NIST') {
console.error(`Creator is ${creator} and not NIST, skipping`);
continue;
}

const nistIds = index
.split(/,\s*/)
.map(parse_nist)
.filter(is_control)
.map((n) => n.canonize());

_.set(
nists,
cciId,
nistIds.map((nist) => ({version, title, nist}))
);
_.set(definitions, cciId, cciItem.definition[0]);

for (const nistId of nistIds) {
if (ccis[nistId] === undefined) {
ccis[nistId] = [cciId];
} else {
ccis[nistId].push(cciId);
}
} else {
console.error(`No NIST Controls found for ${cciId}`);
}
}
return {nists, definitions, ccis};
Expand Down

0 comments on commit 7ecfcb3

Please sign in to comment.