Skip to content

Commit 31f77ee

Browse files
committed
Keep Revision info when mapping from CCI to NIST
Signed-off-by: Joyce Quach <[email protected]>
1 parent 8ca987d commit 31f77ee

File tree

7 files changed

+30659
-5117
lines changed

7 files changed

+30659
-5117
lines changed

libs/hdf-converters/data/converters/cciListXml2json.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ export interface ICCIList {
3434
$: Record<string, string>;
3535
references?: {
3636
reference: {
37-
$: Record<string, string>;
37+
$: {
38+
creator: string;
39+
title: string;
40+
version: string;
41+
index: string;
42+
};
3843
}[];
3944
}[];
4045
definition: string[];
@@ -43,6 +48,13 @@ export interface ICCIList {
4348
};
4449
}
4550

51+
export type NistReference = {
52+
version: string;
53+
creator: string;
54+
title: string;
55+
nist: string;
56+
};
57+
4658
// Check that we're not doing `npm test`; it will look for the arguments to the input and output files.
4759
const scriptIsCalled = process.argv[1].includes('cciListXml2json');
4860

@@ -98,11 +110,11 @@ if (scriptIsCalled) {
98110
}
99111

100112
function produceConversions(cciList: ICCIList): {
101-
nists: Record<string, string[]>;
113+
nists: Record<string, NistReference[]>;
102114
definitions: Record<string, string>;
103115
ccis: Record<string, string[]>;
104116
} {
105-
const nists: Record<string, string[]> = {};
117+
const nists: Record<string, NistReference[]> = {};
106118
const definitions: Record<string, string> = {};
107119
const ccis: Record<string, string[]> = {};
108120

@@ -117,13 +129,18 @@ function produceConversions(cciList: ICCIList): {
117129
if (newestReference) {
118130
/* There's 1 out of the 2000+ CCI controls where this index string is composed of at
119131
least 2 comma-and-space-separated controls found in the latest revision. */
120-
const nistIds = newestReference.$.index
132+
const {version, creator, index, title} = newestReference.$;
133+
const nistIds = index
121134
.split(/,\s*/)
122135
.map(parse_nist)
123136
.filter(is_control)
124137
.map((n) => n.canonize());
125138

126-
_.set(nists, cciId, nistIds);
139+
_.set(
140+
nists,
141+
cciId,
142+
nistIds.map((nist) => ({version, creator, title, nist}))
143+
);
127144
_.set(definitions, cciId, cciItem.definition[0]);
128145

129146
for (const nistId of nistIds) {

libs/hdf-converters/src/ckl-mapper/checklist-mapper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ function cciRef(input: string): string[] {
5454
*/
5555
function nistTag(input: string): string[] {
5656
const identifiers: string[] = cciRef(input);
57-
return CCI2NIST(identifiers, DEFAULT_STATIC_CODE_ANALYSIS_NIST_TAGS);
57+
return CCI2NIST(identifiers, DEFAULT_STATIC_CODE_ANALYSIS_NIST_TAGS).map(
58+
({nist}) => nist
59+
);
5860
}
5961

6062
/**

libs/hdf-converters/src/mappings/CciNistMapping.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ import {
44
NIST_TO_CCI
55
} from '../mappings/NistCciMappingData';
66
import {is_control, parse_nist} from 'inspecjs';
7-
import {CCI_TO_NIST} from './CciNistMappingData';
7+
import {CCI_TO_NIST, DEFAULT_NIST_REFERENCE} from './CciNistMappingData';
8+
import {NistReference} from '../../data/converters/cciListXml2json';
89

910
export function CCI2NIST(
1011
identifiers: string[],
1112
defaultCci2Nist: string[]
12-
): string[] {
13-
const DEFAULT_NIST_TAGS = defaultCci2Nist;
14-
const nists: string[] = _.uniq(
15-
identifiers.flatMap((cci) => _.get(CCI_TO_NIST, cci, []))
13+
): NistReference[] {
14+
const DEFAULT_NIST_TAGS = defaultCci2Nist.map((nist) => ({
15+
nist,
16+
...DEFAULT_NIST_REFERENCE
17+
}));
18+
const nists: NistReference[] = _.uniqBy(
19+
identifiers.flatMap((cci) => _.get(CCI_TO_NIST, cci, [])),
20+
(ref) => ref.nist
1621
);
1722
return nists.length > 0 ? nists : DEFAULT_NIST_TAGS;
1823
}

libs/hdf-converters/src/mappings/CciNistMappingData.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import cciToNistData from './U_CCI_List.nist.json';
22
import cciToDefinitionData from './U_CCI_List.defs.json';
33
import {HANDCRAFTED_DEFAULT_NIST_TO_CCI} from '../mappings/NistCciMappingData';
4+
import {NistReference} from '../../data/converters/cciListXml2json';
45

5-
export const CCI_TO_NIST: Record<string, string[]> = cciToNistData;
6+
export const CCI_TO_NIST: Record<string, NistReference[]> = cciToNistData;
67
export const CCI_TO_DEFINITION: Record<string, string> = cciToDefinitionData;
8+
export const DEFAULT_NIST_REFERENCE: Omit<NistReference, 'nist'> = {
9+
version: '5',
10+
creator: 'NIST',
11+
title: 'NIST SP 800-53 Revision 5'
12+
};
713

814
// DEFAULT_NIST_TAG is applicable to all automated configuration tests.
915
// SA-11 (DEVELOPER SECURITY TESTING AND EVALUATION) - RA-5 (VULNERABILITY SCANNING)

0 commit comments

Comments
 (0)