Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 544bee8

Browse files
committedNov 29, 2024·
Keep Revision info when mapping from CCI to NIST
Signed-off-by: Joyce Quach <jquach@mitre.org>
1 parent d0ae2f2 commit 544bee8

File tree

7 files changed

+30659
-5117
lines changed

7 files changed

+30659
-5117
lines changed
 

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

+22-5
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

+3-1
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

+10-5
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

+7-1
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)

‎libs/hdf-converters/src/mappings/U_CCI_List.nist.json

+30,612-5,102
Large diffs are not rendered by default.

‎libs/hdf-converters/src/nessus-mapper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function pluginNistTag(item: unknown): string[] {
8181
}
8282
function cciNistTag(input: string): string[] {
8383
const identifiers: string[] = parseRef(input, 'CCI');
84-
return CCI2NIST(identifiers, DEFAULT_NIST_TAG);
84+
return CCI2NIST(identifiers, DEFAULT_NIST_TAG).map(({nist}) => nist);
8585
}
8686

8787
function parseRef(input: string, key: string): string[] {

‎libs/hdf-converters/src/xccdf-results-mapper.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const DEFAULT_CCI_TAGS = [
2626
'CCI-000366'
2727
];
2828

29-
const DEFAULT_NIST_TAGS = CCI2NIST(DEFAULT_CCI_TAGS, []);
29+
const DEFAULT_NIST_TAGS = CCI2NIST(DEFAULT_CCI_TAGS, []).map(({nist}) => nist);
3030

3131
function asArray<T>(arg: T | T[]): T[] {
3232
if (Array.isArray(arg)) {
@@ -182,7 +182,9 @@ function cciAndNistTags(input: IIdent | IIdent[]): {
182182
const existingNists = extractNist(input);
183183

184184
if (existingCcis.length > 0) {
185-
const nistsFromMappedCcis = CCI2NIST(existingCcis, []);
185+
const nistsFromMappedCcis = CCI2NIST(existingCcis, []).map(
186+
({nist}) => nist
187+
);
186188
output.nist.push(...nistsFromMappedCcis);
187189
output.cci.push(...existingCcis);
188190
return output;

0 commit comments

Comments
 (0)
Please sign in to comment.