@mitre/hdf-converters 2.10.2 → 2.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -2,6 +2,8 @@ export { ASFFResults } from './src/asff-mapper/asff-mapper';
2
2
  export * from './src/aws-config-mapper';
3
3
  export * from './src/burpsuite-mapper';
4
4
  export * from './src/ckl-mapper/checklist-mapper';
5
+ export * from './src/ckl-mapper/checklistJsonix';
6
+ export * from './src/ckl-mapper/checklist-jsonix-converter';
5
7
  export * from './src/converters-from-hdf/asff/reverse-asff-mapper';
6
8
  export * from './src/converters-from-hdf/caat/reverse-caat-mapper';
7
9
  export * from './src/converters-from-hdf/html/reverse-html-mapper';
package/lib/index.js CHANGED
@@ -32,6 +32,8 @@ Object.defineProperty(exports, "ASFFResults", { enumerable: true, get: function
32
32
  __exportStar(require("./src/aws-config-mapper"), exports);
33
33
  __exportStar(require("./src/burpsuite-mapper"), exports);
34
34
  __exportStar(require("./src/ckl-mapper/checklist-mapper"), exports);
35
+ __exportStar(require("./src/ckl-mapper/checklistJsonix"), exports);
36
+ __exportStar(require("./src/ckl-mapper/checklist-jsonix-converter"), exports);
35
37
  __exportStar(require("./src/converters-from-hdf/asff/reverse-asff-mapper"), exports);
36
38
  __exportStar(require("./src/converters-from-hdf/caat/reverse-caat-mapper"), exports);
37
39
  __exportStar(require("./src/converters-from-hdf/html/reverse-html-mapper"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA0D;AAAlD,0GAAA,WAAW,OAAA;AACnB,0DAAwC;AACxC,yDAAuC;AACvC,oEAAkD;AAClD,qFAAmE;AACnE,qFAAmE;AACnE,qFAAmE;AACnE,yFAAuE;AACvE,uFAAqE;AACrE,wDAAsC;AACtC,yDAAuC;AACvC,uDAAqC;AACrC,qDAAmC;AACnC,0DAAwC;AACxC,0DAAwC;AACxC,4FAA4E;AAC5E,wFAAwE;AACxE,wFAAwE;AACxE,0GAA0F;AAC1F,4FAA4E;AAC5E,wFAAwE;AACxE,4FAA4E;AAC5E,sGAAsF;AACtF,sDAAoC;AACpC,0DAAwC;AACxC,qDAAmC;AACnC,sDAAoC;AACpC,qDAAmC;AACnC,0DAAwC;AACxC,oDAAkC;AAClC,yDAAuC;AACvC,sDAAoC;AACpC,yDAAuC;AACvC,2DAAyC;AACzC,yDAAuC;AACvC,6DAA2C;AAC3C,wDAAsC;AACtC,6DAA2C;AAC3C,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA0D;AAAlD,0GAAA,WAAW,OAAA;AACnB,0DAAwC;AACxC,yDAAuC;AACvC,oEAAkD;AAClD,mEAAiD;AACjD,8EAA4D;AAC5D,qFAAmE;AACnE,qFAAmE;AACnE,qFAAmE;AACnE,yFAAuE;AACvE,uFAAqE;AACrE,wDAAsC;AACtC,yDAAuC;AACvC,uDAAqC;AACrC,qDAAmC;AACnC,0DAAwC;AACxC,0DAAwC;AACxC,4FAA4E;AAC5E,wFAAwE;AACxE,wFAAwE;AACxE,0GAA0F;AAC1F,4FAA4E;AAC5E,wFAAwE;AACxE,4FAA4E;AAC5E,sGAAsF;AACtF,sDAAoC;AACpC,0DAAwC;AACxC,qDAAmC;AACnC,sDAAoC;AACpC,qDAAmC;AACnC,0DAAwC;AACxC,oDAAkC;AAClC,yDAAuC;AACvC,sDAAoC;AACpC,yDAAuC;AACvC,2DAAyC;AACzC,yDAAuC;AACvC,6DAA2C;AAC3C,wDAAsC;AACtC,6DAA2C;AAC3C,mDAAiC"}
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitre/hdf-converters",
3
- "version": "2.10.2",
3
+ "version": "2.10.5",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Converter util library used to transform various scan results into HDF format",
6
6
  "files": [
@@ -49,9 +49,12 @@
49
49
  "mustache": "^4.2.0",
50
50
  "papaparse": "^5.3.1",
51
51
  "run-script-os": "^1.1.6",
52
+ "semver": "^7.6.0",
52
53
  "tailwindcss": "^3.3.3",
53
54
  "tw-elements": "^1.0.0-beta2",
54
55
  "winston": "^3.6.0",
56
+ "xml-formatter": "^3.6.2",
57
+ "xml-parser-xo": "^4.1.1",
55
58
  "xml2js": "^0.6.0",
56
59
  "yaml": "^2.1.1"
57
60
  },
@@ -1,9 +1,10 @@
1
- import { Asset, Checklist, Sidata, Stigdata, Vuln } from '../../types/checklistJsonix';
1
+ import { ExecJSON } from 'inspecjs';
2
2
  import { JsonixIntermediateConverter } from '../jsonix-intermediate-converter';
3
+ import { Asset, Assettype, Checklist, Role, Sidata, Stigdata, StigdatumElement, Techarea, Vuln } from './checklistJsonix';
3
4
  export type ChecklistObject = {
4
5
  asset: ChecklistAsset;
5
6
  stigs: ChecklistStig[];
6
- jsonixData: Checklist;
7
+ jsonixData?: Checklist;
7
8
  };
8
9
  type ChecklistAsset = Asset;
9
10
  type ChecklistStig = {
@@ -29,7 +30,7 @@ export type ChecklistVuln = Omit<Vuln, 'stigdata' | 'status'> & {
29
30
  severity: Severity;
30
31
  groupTitle: string;
31
32
  ruleId: string;
32
- ruleVersion: string;
33
+ ruleVer: string;
33
34
  ruleTitle: string;
34
35
  vulnDiscuss: string;
35
36
  iaControls: string;
@@ -37,7 +38,7 @@ export type ChecklistVuln = Omit<Vuln, 'stigdata' | 'status'> & {
37
38
  fixText: string;
38
39
  falsePositives: string;
39
40
  falseNegatives: string;
40
- documentable: boolean;
41
+ documentable: string;
41
42
  mitigations: string;
42
43
  potentialImpact: string;
43
44
  thirdPartyTools: string;
@@ -65,8 +66,48 @@ export declare enum Severity {
65
66
  Low = "low",
66
67
  Medium = "medium"
67
68
  }
69
+ export type ChecklistMetadata = {
70
+ marking: string;
71
+ hostname: string;
72
+ hostip: string;
73
+ hostmac: string;
74
+ hostfqdn: string;
75
+ targetcomment: string;
76
+ role: Role;
77
+ assettype: Assettype;
78
+ techarea: Techarea;
79
+ webordatabase: string;
80
+ webdbsite: string;
81
+ webdbinstance: string;
82
+ vulidmapping: 'id' | 'gid';
83
+ profiles: StigMetadata[];
84
+ };
85
+ export type StigMetadata = {
86
+ name: string;
87
+ title: string;
88
+ releasenumber: number;
89
+ version: number;
90
+ releasedate: string;
91
+ showCalendar: boolean;
92
+ };
93
+ export declare const EmptyChecklistObject: ChecklistObject;
94
+ export declare function updateChecklistWithMetadata(file: ExecJSON.Execution): ChecklistObject;
68
95
  export declare class ChecklistJsonixConverter extends JsonixIntermediateConverter<Checklist, ChecklistObject> {
69
96
  getValueFromAttributeName<T extends Stigdata | Sidata>(data: T[], tag: string): string;
70
97
  toIntermediateObject(jsonixData: Checklist): ChecklistObject;
98
+ expandHeader(header: StigHeader): Sidata[];
99
+ expandVulns(checklistVuln: ChecklistVuln): StigdatumElement[];
100
+ createVulns(checklistVulns: ChecklistVuln[]): Vuln[];
101
+ fromIntermediateObject(intermediateObj: ChecklistObject): Checklist;
102
+ getStatus(results: ExecJSON.ControlResult[], impact: number): StatusMapping;
103
+ severityMap(impact: number): Severity;
104
+ getFindingDetails(results: ExecJSON.ControlResult[]): string;
105
+ matchNistToCcis(nistRefs: string[]): string[];
106
+ getComments(descriptions: ExecJSON.ControlDescription[]): string;
107
+ addHdfControlSpecificData(control: ExecJSON.Control): string;
108
+ addHdfProfileSpecificData(profile: ExecJSON.Profile): string;
109
+ controlsToVulns(profile: ExecJSON.Profile, stigRef: string, metadata?: ChecklistMetadata): ChecklistVuln[];
110
+ getReleaseInfo(releasenumber: number | undefined, releasedate: string | undefined): string | undefined;
111
+ hdfToIntermediateObject(hdf: ExecJSON.Execution): ChecklistObject;
71
112
  }
72
113
  export {};
@@ -1,31 +1,16 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ChecklistJsonixConverter = exports.Severity = void 0;
27
- const _ = __importStar(require("lodash"));
6
+ exports.ChecklistJsonixConverter = exports.updateChecklistWithMetadata = exports.EmptyChecklistObject = exports.Severity = void 0;
7
+ const inspecjs_1 = require("inspecjs");
8
+ const lodash_1 = __importDefault(require("lodash"));
28
9
  const jsonix_intermediate_converter_1 = require("../jsonix-intermediate-converter");
10
+ const CciNistMapping_1 = require("../mappings/CciNistMapping");
11
+ const global_1 = require("../utils/global");
12
+ const checklistJsonix_1 = require("./checklistJsonix");
13
+ const semver_1 = require("semver");
29
14
  var StatusMapping;
30
15
  (function (StatusMapping) {
31
16
  StatusMapping["NotAFinding"] = "Passed";
@@ -40,6 +25,102 @@ var Severity;
40
25
  Severity["Low"] = "low";
41
26
  Severity["Medium"] = "medium";
42
27
  })(Severity = exports.Severity || (exports.Severity = {}));
28
+ exports.EmptyChecklistObject = {
29
+ asset: {
30
+ assettype: checklistJsonix_1.Assettype.Computing,
31
+ marking: 'CUI',
32
+ hostfqdn: null,
33
+ hostip: null,
34
+ hostmac: null,
35
+ hostname: null,
36
+ targetcomment: null,
37
+ role: checklistJsonix_1.Role.None,
38
+ targetkey: null,
39
+ techarea: checklistJsonix_1.Techarea.Empty,
40
+ webdbinstance: null,
41
+ webdbsite: null,
42
+ webordatabase: null
43
+ },
44
+ stigs: [
45
+ {
46
+ header: {
47
+ version: '',
48
+ classification: 'UNCLASSIFIED',
49
+ stigid: '',
50
+ description: '',
51
+ filename: '',
52
+ title: '',
53
+ uuid: ''
54
+ },
55
+ vulns: [
56
+ {
57
+ status: StatusMapping.Not_Reviewed,
58
+ vulnNum: '',
59
+ severity: Severity.Low,
60
+ groupTitle: '',
61
+ ruleId: '',
62
+ ruleVer: '',
63
+ ruleTitle: '',
64
+ vulnDiscuss: '',
65
+ iaControls: '',
66
+ checkContent: '',
67
+ fixText: '',
68
+ falsePositives: '',
69
+ falseNegatives: '',
70
+ documentable: 'false',
71
+ mitigations: '',
72
+ potentialImpact: '',
73
+ thirdPartyTools: '',
74
+ mitigationControl: '',
75
+ responsibility: '',
76
+ securityOverrideGuidance: '',
77
+ checkContentRef: '',
78
+ weight: '',
79
+ class: 'Unclass',
80
+ stigRef: '',
81
+ targetKey: '',
82
+ stigUuid: '',
83
+ legacyId: '',
84
+ cciRef: '',
85
+ comments: null,
86
+ findingdetails: null,
87
+ severityjustification: null,
88
+ severityoverride: checklistJsonix_1.Severityoverride.Empty
89
+ }
90
+ ]
91
+ }
92
+ ]
93
+ };
94
+ function updateChecklistWithMetadata(file) {
95
+ const metadata = lodash_1.default.get(file, 'passthrough.metadata');
96
+ const checklist = lodash_1.default.get(file, 'passthrough.checklist');
97
+ checklist.asset.assettype = metadata.assettype;
98
+ checklist.asset.marking = metadata.marking;
99
+ checklist.asset.hostfqdn = metadata.hostfqdn;
100
+ checklist.asset.hostip = metadata.hostip;
101
+ checklist.asset.hostname = metadata.hostname;
102
+ checklist.asset.hostmac = metadata.hostmac;
103
+ checklist.asset.targetcomment = metadata.targetcomment;
104
+ checklist.asset.role = metadata.role;
105
+ checklist.asset.techarea = metadata.techarea;
106
+ checklist.asset.webordatabase = [true, 'true'].includes(metadata.webordatabase);
107
+ checklist.asset.webdbsite = metadata.webdbsite;
108
+ checklist.asset.webdbinstance = metadata.webdbinstance;
109
+ for (const stig of checklist.stigs) {
110
+ for (const profile of metadata.profiles) {
111
+ if (stig.header.title === profile.name) {
112
+ stig.header.title = profile.title || profile.name;
113
+ stig.header.version = profile.version.toString();
114
+ stig.header.releaseinfo = `Release: ${profile.releasenumber} Benchmark Date: ${profile.releasedate}`;
115
+ for (const vuln of stig.vulns) {
116
+ vuln.stigRef = `${stig.header.title} :: Version ${stig.header.version}, ${stig.header.releaseinfo}`;
117
+ }
118
+ }
119
+ }
120
+ }
121
+ return checklist;
122
+ }
123
+ exports.updateChecklistWithMetadata = updateChecklistWithMetadata;
43
124
  class ChecklistJsonixConverter extends jsonix_intermediate_converter_1.JsonixIntermediateConverter {
44
125
  getValueFromAttributeName(data, tag) {
45
126
  let keyName = 'vulnattribute';
@@ -49,30 +130,30 @@ class ChecklistJsonixConverter extends jsonix_intermediate_converter_1.JsonixInt
49
130
  dataName = 'siddata';
50
131
  }
51
132
  const results = data.filter((attribute) => {
52
- return _.get(attribute, keyName) == tag;
133
+ return lodash_1.default.get(attribute, keyName) == tag;
53
134
  });
54
- return results.map((result) => _.get(result, dataName)).join('; ');
135
+ return results.map((result) => lodash_1.default.get(result, dataName)).join('; ');
55
136
  }
56
137
  toIntermediateObject(jsonixData) {
57
138
  const asset = {
58
- role: _.get(jsonixData, 'value.asset.role'),
59
- assettype: _.get(jsonixData, 'value.asset.assettype'),
60
- hostname: _.get(jsonixData, 'value.asset.hostname'),
61
- hostip: _.get(jsonixData, 'value.asset.hostip'),
62
- hostmac: _.get(jsonixData, 'value.asset.hostmac'),
63
- hostfqdn: _.get(jsonixData, 'value.asset.hostfqdn'),
64
- marking: _.get(jsonixData, 'value.asset.marking'),
65
- targetcomment: _.get(jsonixData, 'value.asset.targetcomment'),
66
- techarea: _.get(jsonixData, 'value.asset.techarea'),
67
- targetkey: _.get(jsonixData, 'value.asset.targetkey'),
68
- webordatabase: _.get(jsonixData, 'value.asset.webordatabase'),
69
- webdbsite: _.get(jsonixData, 'value.asset.webdbsite'),
70
- webdbinstance: _.get(jsonixData, 'value.asset.webdbinstance')
139
+ role: lodash_1.default.get(jsonixData, 'value.asset.role'),
140
+ assettype: lodash_1.default.get(jsonixData, 'value.asset.assettype'),
141
+ hostname: lodash_1.default.get(jsonixData, 'value.asset.hostname'),
142
+ hostip: lodash_1.default.get(jsonixData, 'value.asset.hostip'),
143
+ hostmac: lodash_1.default.get(jsonixData, 'value.asset.hostmac'),
144
+ hostfqdn: lodash_1.default.get(jsonixData, 'value.asset.hostfqdn'),
145
+ marking: lodash_1.default.get(jsonixData, 'value.asset.marking'),
146
+ targetcomment: lodash_1.default.get(jsonixData, 'value.asset.targetcomment'),
147
+ techarea: lodash_1.default.get(jsonixData, 'value.asset.techarea'),
148
+ targetkey: lodash_1.default.get(jsonixData, 'value.asset.targetkey'),
149
+ webordatabase: [true, 'true'].includes(lodash_1.default.get(jsonixData, 'value.asset.webordatabase', false)),
150
+ webdbsite: lodash_1.default.get(jsonixData, 'value.asset.webdbsite'),
151
+ webdbinstance: lodash_1.default.get(jsonixData, 'value.asset.webdbinstance')
71
152
  };
72
- const rawStigs = _.get(jsonixData, 'value.stigs.istig');
153
+ const rawStigs = lodash_1.default.get(jsonixData, 'value.stigs.istig');
73
154
  const stigs = [];
74
155
  for (const stig of rawStigs) {
75
- const stigInfo = _.get(stig, 'stiginfo.sidata');
156
+ const stigInfo = lodash_1.default.get(stig, 'stiginfo.sidata');
76
157
  const header = {
77
158
  version: this.getValueFromAttributeName(stigInfo, 'version'),
78
159
  classification: this.getValueFromAttributeName(stigInfo, 'classification'),
@@ -87,20 +168,20 @@ class ChecklistJsonixConverter extends jsonix_intermediate_converter_1.JsonixInt
87
168
  source: this.getValueFromAttributeName(stigInfo, 'source')
88
169
  };
89
170
  const checklistVulns = [];
90
- const vulns = _.get(stig, 'vuln');
171
+ const vulns = lodash_1.default.get(stig, 'vuln');
91
172
  for (const vuln of vulns) {
92
- const stigdata = _.get(vuln, 'stigdata');
173
+ const stigdata = lodash_1.default.get(vuln, 'stigdata');
93
174
  const checklistVuln = {
94
- status: StatusMapping[_.get(vuln, 'status')],
95
- findingdetails: _.get(vuln, 'findingdetails'),
96
- comments: _.get(vuln, 'comments'),
97
- severityoverride: _.get(vuln, 'severityoverride'),
98
- severityjustification: _.get(vuln, 'severityjustification'),
175
+ status: StatusMapping[lodash_1.default.get(vuln, 'status')],
176
+ findingdetails: lodash_1.default.get(vuln, 'findingdetails'),
177
+ comments: lodash_1.default.get(vuln, 'comments'),
178
+ severityoverride: lodash_1.default.get(vuln, 'severityoverride'),
179
+ severityjustification: lodash_1.default.get(vuln, 'severityjustification'),
99
180
  vulnNum: this.getValueFromAttributeName(stigdata, 'Vuln_Num'),
100
181
  severity: this.getValueFromAttributeName(stigdata, 'Severity'),
101
182
  groupTitle: this.getValueFromAttributeName(stigdata, 'Group_Title'),
102
183
  ruleId: this.getValueFromAttributeName(stigdata, 'Rule_ID'),
103
- ruleVersion: this.getValueFromAttributeName(stigdata, 'Rule_Ver'),
184
+ ruleVer: this.getValueFromAttributeName(stigdata, 'Rule_Ver'),
104
185
  ruleTitle: this.getValueFromAttributeName(stigdata, 'Rule_Title'),
105
186
  vulnDiscuss: this.getValueFromAttributeName(stigdata, 'Vuln_Discuss'),
106
187
  iaControls: this.getValueFromAttributeName(stigdata, 'IA_Controls'),
@@ -138,6 +219,308 @@ class ChecklistJsonixConverter extends jsonix_intermediate_converter_1.JsonixInt
138
219
  };
139
220
  return checklistObject;
140
221
  }
222
+ expandHeader(header) {
223
+ const sidata = [];
224
+ for (const [name, data] of Object.entries(header)) {
225
+ if (data) {
226
+ sidata.push({
227
+ sidname: name,
228
+ siddata: data
229
+ });
230
+ }
231
+ else {
232
+ sidata.push({ sidname: name });
233
+ }
234
+ }
235
+ return sidata;
236
+ }
237
+ expandVulns(checklistVuln) {
238
+ var _a;
239
+ const separateElementNames = ['CciRef', 'IAControls', 'LegacyID'];
240
+ const stigdata = [];
241
+ for (const [attributeName, data] of Object.entries(checklistVuln)) {
242
+ const keyFoundInVulnattribute = Object.keys(checklistJsonix_1.Vulnattribute).find((key) => key.toLowerCase() === attributeName.toLowerCase());
243
+ if (keyFoundInVulnattribute) {
244
+ if (separateElementNames.includes(keyFoundInVulnattribute)) {
245
+ const dataStrings = (_a = data === null || data === void 0 ? void 0 : data.toString().split(/[,|;]/)) !== null && _a !== void 0 ? _a : [];
246
+ for (const dataString of dataStrings) {
247
+ stigdata.push({
248
+ vulnattribute: checklistJsonix_1.Vulnattribute[keyFoundInVulnattribute],
249
+ attributedata: dataString.trim()
250
+ });
251
+ }
252
+ continue;
253
+ }
254
+ stigdata.push({
255
+ vulnattribute: checklistJsonix_1.Vulnattribute[keyFoundInVulnattribute],
256
+ attributedata: data
257
+ });
258
+ }
259
+ }
260
+ return stigdata;
261
+ }
262
+ createVulns(checklistVulns) {
263
+ const vulns = [];
264
+ for (const checklistVuln of checklistVulns) {
265
+ const stigdata = this.expandVulns(checklistVuln);
266
+ const vuln = {
267
+ comments: checklistVuln.comments,
268
+ findingdetails: checklistVuln.findingdetails,
269
+ severityjustification: checklistVuln.severityjustification,
270
+ severityoverride: checklistVuln.severityoverride,
271
+ status: Object.keys(StatusMapping)[Object.values(StatusMapping).indexOf(checklistVuln.status)],
272
+ stigdata: stigdata
273
+ };
274
+ vulns.push(vuln);
275
+ }
276
+ return vulns;
277
+ }
278
+ fromIntermediateObject(intermediateObj) {
279
+ const name = {
280
+ localPart: checklistJsonix_1.LocalPartEnum.Checklist
281
+ };
282
+ const istigs = [];
283
+ for (const stig of intermediateObj.stigs) {
284
+ const istig = {
285
+ stiginfo: {
286
+ sidata: this.expandHeader(stig.header)
287
+ },
288
+ vuln: this.createVulns(stig.vulns)
289
+ };
290
+ istigs.push(istig);
291
+ }
292
+ const value = {
293
+ asset: {
294
+ ...intermediateObj.asset
295
+ },
296
+ stigs: {
297
+ istig: istigs
298
+ }
299
+ };
300
+ const checklist = {
301
+ name: name,
302
+ value: value
303
+ };
304
+ return checklist;
305
+ }
306
+ getStatus(results, impact) {
307
+ const statuses = results.map((result) => {
308
+ return result.status;
309
+ });
310
+ if (impact === 0) {
311
+ return StatusMapping.Not_Applicable;
312
+ }
313
+ else if (statuses.includes(inspecjs_1.ExecJSON.ControlResultStatus.Failed)) {
314
+ return StatusMapping.Open;
315
+ }
316
+ else if (statuses.includes(inspecjs_1.ExecJSON.ControlResultStatus.Passed)) {
317
+ return StatusMapping.NotAFinding;
318
+ }
319
+ else {
320
+ return StatusMapping.Not_Reviewed;
321
+ }
322
+ }
323
+ severityMap(impact) {
324
+ if (impact < 0.4) {
325
+ return Severity.Low;
326
+ }
327
+ else if (impact < 0.7) {
328
+ return Severity.Medium;
329
+ }
330
+ else {
331
+ return Severity.High;
332
+ }
333
+ }
334
+ getFindingDetails(results) {
335
+ if (typeof results === 'undefined') {
336
+ return '';
337
+ }
338
+ else {
339
+ return results
340
+ .map((result) => {
341
+ if (result.message) {
342
+ return `${result.status} :: TEST ${result.code_desc} :: MESSAGE ${result.message}`;
343
+ }
344
+ else if (result.skip_message) {
345
+ return `${result.status} :: TEST ${result.code_desc} :: SKIP_MESSAGE ${result.skip_message}`;
346
+ }
347
+ else {
348
+ return `${result.status} :: TEST ${result.code_desc}`;
349
+ }
350
+ })
351
+ .join('\n--------------------------------\n');
352
+ }
353
+ }
354
+ matchNistToCcis(nistRefs) {
355
+ if (!nistRefs) {
356
+ return [''];
357
+ }
358
+ const CCI_NIST_TWO_WAY_MAPPER = new CciNistMapping_1.CciNistTwoWayMapper();
359
+ return CCI_NIST_TWO_WAY_MAPPER.cciFilter(nistRefs, ['']);
360
+ }
361
+ getComments(descriptions) {
362
+ let results = '';
363
+ const caveat = (0, global_1.getDescription)(descriptions, 'caveat');
364
+ const justification = (0, global_1.getDescription)(descriptions, 'justification');
365
+ const rationale = (0, global_1.getDescription)(descriptions, 'rationale');
366
+ const comments = (0, global_1.getDescription)(descriptions, 'comments');
367
+ if (caveat) {
368
+ results += `CAVEAT :: ${caveat}\n`;
369
+ }
370
+ if (justification) {
371
+ results += `JUSTIFICATION :: ${justification}\n`;
372
+ }
373
+ if (rationale) {
374
+ results += `RATIONALE :: ${rationale}\n`;
375
+ }
376
+ if (comments) {
377
+ results += `COMMENTS :: ${comments}`;
378
+ }
379
+ return results;
380
+ }
381
+ addHdfControlSpecificData(control) {
382
+ var _a;
383
+ const hdfSpecificData = {};
384
+ const checklistImpactNumbers = [0.7, 0.5, 0.3, 0];
385
+ if (!checklistImpactNumbers.includes(control.impact)) {
386
+ hdfSpecificData['impact'] = control.impact;
387
+ }
388
+ if ((_a = control.code) === null || _a === void 0 ? void 0 : _a.startsWith('control')) {
389
+ hdfSpecificData['code'] = control.code;
390
+ }
391
+ const hdfDataExist = Object.keys(hdfSpecificData).length !== 0;
392
+ return hdfDataExist
393
+ ? JSON.stringify({ hdfSpecificData: hdfSpecificData }, null, 2)
394
+ : '';
395
+ }
396
+ addHdfProfileSpecificData(profile) {
397
+ const hdfSpecificData = {};
398
+ if (profile.attributes.length) {
399
+ hdfSpecificData['attributes'] = profile.attributes;
400
+ }
401
+ if (profile.copyright) {
402
+ hdfSpecificData['copyright'] = profile.copyright;
403
+ }
404
+ if (profile.copyright_email) {
405
+ hdfSpecificData['copyright_email'] = profile.copyright_email;
406
+ }
407
+ if (profile.maintainer) {
408
+ hdfSpecificData['maintainer'] = profile.maintainer;
409
+ }
410
+ if (profile.version) {
411
+ hdfSpecificData['version'] = profile.version;
412
+ }
413
+ const hdfDataExist = Object.keys(hdfSpecificData).length !== 0;
414
+ return hdfDataExist ? JSON.stringify({ hdfSpecificData }) : '';
415
+ }
416
+ controlsToVulns(profile, stigRef, metadata) {
417
+ var _a, _b, _c, _d, _e, _f, _g, _h;
418
+ const vulns = [];
419
+ for (const control of profile.controls) {
420
+ const defaultId = lodash_1.default.get(control, 'id', '');
421
+ const vuln = {
422
+ status: this.getStatus(control.results, control.impact),
423
+ vulnNum: (metadata === null || metadata === void 0 ? void 0 : metadata.vulidmapping) === 'gid'
424
+ ? lodash_1.default.get(control.tags, 'gid', defaultId)
425
+ : defaultId,
426
+ severity: this.severityMap(control.impact),
427
+ groupTitle: lodash_1.default.get(control.tags, 'gtitle', defaultId),
428
+ ruleId: lodash_1.default.get(control.tags, 'rid', defaultId),
429
+ ruleVer: lodash_1.default.get(control.tags, 'stig_id', defaultId),
430
+ ruleTitle: (_a = control.title) !== null && _a !== void 0 ? _a : '',
431
+ vulnDiscuss: (_b = control.desc) !== null && _b !== void 0 ? _b : '',
432
+ iaControls: lodash_1.default.get(control.tags, 'IA_Controls', ''),
433
+ checkContent: (_d = (_c = lodash_1.default.get(control.tags, 'check')) !== null && _c !== void 0 ? _c : (0, global_1.getDescription)(control.descriptions, 'check')) !== null && _d !== void 0 ? _d : '',
434
+ fixText: (_f = (_e = lodash_1.default.get(control.tags, 'fix')) !== null && _e !== void 0 ? _e : (0, global_1.getDescription)(control.descriptions, 'fix')) !== null && _f !== void 0 ? _f : '',
435
+ falsePositives: lodash_1.default.get(control.tags, 'False_Positives', ''),
436
+ falseNegatives: lodash_1.default.get(control.tags, 'False_Negatives', ''),
437
+ documentable: 'false',
438
+ mitigations: lodash_1.default.get(control.tags, 'Mitigations', ''),
439
+ potentialImpact: lodash_1.default.get(control.tags, 'Potential_Impact', ''),
440
+ thirdPartyTools: this.addHdfControlSpecificData(control),
441
+ mitigationControl: lodash_1.default.get(control.tags, 'Mitigation_Control', ''),
442
+ responsibility: lodash_1.default.get(control.tags, 'Responsibility', ''),
443
+ securityOverrideGuidance: lodash_1.default.get(control.tags, 'Security_Override_Guidance', ''),
444
+ checkContentRef: 'M',
445
+ weight: lodash_1.default.get(control.tags, 'weight', '10.0'),
446
+ class: 'Unclass',
447
+ stigRef,
448
+ targetKey: '',
449
+ stigUuid: '',
450
+ legacyId: lodash_1.default.get(control.tags, 'Legacy_ID'),
451
+ cciRef: (_g = lodash_1.default.get(control.tags, 'cci')) !== null && _g !== void 0 ? _g : this.matchNistToCcis(lodash_1.default.get(control.tags, 'nist')),
452
+ comments: this.getComments(control.descriptions),
453
+ findingdetails: (_h = this.getFindingDetails(control.results)) !== null && _h !== void 0 ? _h : '',
454
+ severityjustification: '',
455
+ severityoverride: checklistJsonix_1.Severityoverride.Empty
456
+ };
457
+ vulns.push(vuln);
458
+ }
459
+ return vulns;
460
+ }
461
+ getReleaseInfo(releasenumber, releasedate) {
462
+ if (releasenumber && releasedate) {
463
+ return `Release: ${releasenumber} Benchmark Date: ${releasedate}`;
464
+ }
465
+ else if (releasenumber) {
466
+ return `Release: ${releasenumber}`;
467
+ }
468
+ else if (releasedate) {
469
+ return `Benchmark Date: ${releasedate}`;
470
+ }
471
+ else {
472
+ return undefined;
473
+ }
474
+ }
475
+ hdfToIntermediateObject(hdf) {
476
+ var _a, _b;
477
+ const stigs = [];
478
+ const metadata = lodash_1.default.get(hdf, 'passthrough.metadata');
479
+ for (const profile of hdf.profiles) {
480
+ if ((_a = profile.depends) === null || _a === void 0 ? void 0 : _a.length) {
481
+ continue;
482
+ }
483
+ const profileMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.profiles.find((p) => p.name === profile.name);
484
+ const version = (0, semver_1.coerce)(profile.version);
485
+ const header = {
486
+ version: lodash_1.default.get(profileMetadata, 'version', (_b = version === null || version === void 0 ? void 0 : version.major) !== null && _b !== void 0 ? _b : 0).toString(),
487
+ classification: 'UNCLASSIFIED',
488
+ customname: this.addHdfProfileSpecificData(profile),
489
+ stigid: profile.name,
490
+ description: (profile.summary || '') +
491
+ (profile.summary && profile.description ? '\n' : '') +
492
+ (profile.description || ''),
493
+ filename: '',
494
+ releaseinfo: this.getReleaseInfo((profileMetadata === null || profileMetadata === void 0 ? void 0 : profileMetadata.releasenumber) || (version === null || version === void 0 ? void 0 : version.minor) || 0, profileMetadata === null || profileMetadata === void 0 ? void 0 : profileMetadata.releasedate),
495
+ title: (profileMetadata === null || profileMetadata === void 0 ? void 0 : profileMetadata.title) || profile.title || profile.name,
496
+ uuid: '',
497
+ notice: profile.license || '',
498
+ source: 'STIG.DOD.MIL'
499
+ };
500
+ const stigRef = `${header.title} :: Version ${header.version}${header.releaseinfo ? ', ' + header.releaseinfo : ''}`;
501
+ const vulns = this.controlsToVulns(profile, stigRef, metadata);
502
+ stigs.push({ header, vulns });
503
+ }
504
+ const checklistObject = {
505
+ asset: {
506
+ assettype: lodash_1.default.get(hdf, 'passthrough.metadata.assettype', checklistJsonix_1.Assettype.Computing),
507
+ hostfqdn: lodash_1.default.get(hdf, 'passthrough.metadata.hostfqdn', ''),
508
+ hostip: lodash_1.default.get(hdf, 'passthrough.metadata.hostip', ''),
509
+ hostmac: lodash_1.default.get(hdf, 'passthrough.metadata.hostmac', ''),
510
+ hostname: lodash_1.default.get(hdf, 'passthrough.metadata.hostname', ''),
511
+ marking: lodash_1.default.get(hdf, 'passthrough.metadata.marking', 'CUI'),
512
+ role: lodash_1.default.get(hdf, 'passthrough.metadata.role', checklistJsonix_1.Role.None),
513
+ targetcomment: lodash_1.default.get(hdf, 'passthrough.metadata.targetcomment', ''),
514
+ targetkey: '',
515
+ techarea: lodash_1.default.get(hdf, 'passthrough.metadata.techarea', checklistJsonix_1.Techarea.Empty),
516
+ webdbinstance: lodash_1.default.get(hdf, 'passthrough.metadata.webdbinstance', ''),
517
+ webdbsite: lodash_1.default.get(hdf, 'passthrough.metadata.webdbsite', ''),
518
+ webordatabase: [true, 'true'].includes(lodash_1.default.get(hdf, 'passthrough.metadata.webordatabase', false))
519
+ },
520
+ stigs: stigs
521
+ };
522
+ return checklistObject;
523
+ }
141
524
  }
142
525
  exports.ChecklistJsonixConverter = ChecklistJsonixConverter;
143
526
  //# sourceMappingURL=checklist-jsonix-converter.js.map