@mitre/inspec-objects 0.0.7 → 0.0.8
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/objects/control.d.ts +2 -1
- package/lib/parsers/xccdf.js +0 -6
- package/lib/utilities/diff.d.ts +1 -0
- package/lib/utilities/diff.js +23 -12
- package/package.json +1 -1
- package/mitre-inspec-objects-v0.0.1.tgz +0 -0
- package/mitre-inspec-objects-v0.0.3.tgz +0 -0
- package/mitre-inspec-objects-v0.0.4.tgz +0 -0
- package/mitre-inspec-objects-v0.0.6.tgz +0 -0
package/lib/objects/control.d.ts
CHANGED
|
@@ -21,14 +21,15 @@ export default class Control {
|
|
|
21
21
|
})[];
|
|
22
22
|
tags: {
|
|
23
23
|
check?: string;
|
|
24
|
+
check_id?: string;
|
|
24
25
|
fix?: string;
|
|
26
|
+
fix_id?: string | null;
|
|
25
27
|
severity?: string;
|
|
26
28
|
gtitle?: string;
|
|
27
29
|
gid?: string;
|
|
28
30
|
satisfies?: string[];
|
|
29
31
|
rid?: string;
|
|
30
32
|
stig_id?: string;
|
|
31
|
-
fix_id?: string | null;
|
|
32
33
|
cci?: string[];
|
|
33
34
|
cis_controls?: Record<string, string[]>[];
|
|
34
35
|
nist?: string[];
|
package/lib/parsers/xccdf.js
CHANGED
|
@@ -125,15 +125,9 @@ function processXCCDF(xml, removeNewlines = false, useRuleId, ovalDefinitions) {
|
|
|
125
125
|
if (rule['fix'] && rule['fix'].length > 0) {
|
|
126
126
|
control.tags.fix_id = rule['fix'][0]['@_id'];
|
|
127
127
|
}
|
|
128
|
-
else {
|
|
129
|
-
control.tags.fix_id = null;
|
|
130
|
-
}
|
|
131
128
|
if (rule['rationale']) {
|
|
132
129
|
control.tags.rationale = rule['rationale'][0]['#text'];
|
|
133
130
|
}
|
|
134
|
-
else {
|
|
135
|
-
control.tags.rationale = null;
|
|
136
|
-
}
|
|
137
131
|
if (typeof extractedDescription === 'object') {
|
|
138
132
|
control.tags.satisfies = ((_c = extractedDescription.VulnDiscussion) === null || _c === void 0 ? void 0 : _c.includes('Satisfies: ')) && extractedDescription.VulnDiscussion.split('Satisfies: ').length >= 1 ? extractedDescription.VulnDiscussion.split('Satisfies: ')[1].split(',').map(satisfaction => satisfaction.trim()) : undefined;
|
|
139
133
|
control.tags.false_negatives = extractedDescription.FalseNegatives || undefined;
|
package/lib/utilities/diff.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Profile from '../objects/profile';
|
|
2
2
|
import { ProfileDiff } from '../types/diff';
|
|
3
3
|
export declare function removeNewlines(control?: Record<string, unknown>): Record<string, unknown>;
|
|
4
|
+
export declare function simplifyDiff(diffData: Record<string, unknown>): Record<string, unknown>;
|
|
4
5
|
export declare function diffProfile(fromProfile: Profile, toProfile: Profile): ProfileDiff;
|
package/lib/utilities/diff.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.diffProfile = exports.removeNewlines = void 0;
|
|
3
|
+
exports.diffProfile = exports.simplifyDiff = exports.removeNewlines = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const json_diff_1 = require("json-diff");
|
|
6
6
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
@@ -19,6 +19,26 @@ function removeNewlines(control) {
|
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
exports.removeNewlines = removeNewlines;
|
|
22
|
+
function simplifyDiff(diffData) {
|
|
23
|
+
return lodash_1.default.transform(diffData, (result, diffValue, key) => {
|
|
24
|
+
if (lodash_1.default.has(diffValue, '__new')) {
|
|
25
|
+
result[key] = lodash_1.default.get(diffValue, '__new');
|
|
26
|
+
}
|
|
27
|
+
else if (Array.isArray(diffValue)) {
|
|
28
|
+
result[key] = diffValue.map((value) => value[0] === '+' && value[1]).filter(value => value);
|
|
29
|
+
}
|
|
30
|
+
else if (typeof diffValue === 'object') {
|
|
31
|
+
result[key] = simplifyDiff(diffValue);
|
|
32
|
+
}
|
|
33
|
+
else if (key.endsWith('__deleted')) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
result[key] = diffValue;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.simplifyDiff = simplifyDiff;
|
|
22
42
|
function diffProfile(fromProfile, toProfile) {
|
|
23
43
|
const profileDiff = {
|
|
24
44
|
addedControlIDs: [],
|
|
@@ -48,18 +68,9 @@ function diffProfile(fromProfile, toProfile) {
|
|
|
48
68
|
for (const fromControl of fromProfile.controls) {
|
|
49
69
|
const toControl = toProfile.controls.find((control) => control.id === fromControl.id);
|
|
50
70
|
if (toControl) {
|
|
51
|
-
const controlDiff = (0, json_diff_1.diff)(fromControl, toControl);
|
|
71
|
+
const controlDiff = lodash_1.default.omit((0, json_diff_1.diff)(fromControl, toControl), 'code__deleted');
|
|
52
72
|
if (controlDiff) {
|
|
53
|
-
|
|
54
|
-
if (lodash_1.default.has(value, '__new')) {
|
|
55
|
-
lodash_1.default.set(profileDiff, 'changedControls.' + fromControl.id + '.' + key.replace('.', '\\.'), lodash_1.default.get(controlDiff, key + '.__new'));
|
|
56
|
-
}
|
|
57
|
-
else if (typeof value === 'object') {
|
|
58
|
-
Object.entries(value).forEach(([subKey]) => {
|
|
59
|
-
lodash_1.default.set(profileDiff, 'changedControls.' + fromControl.id + '.' + key.replace('.', '\\.') + '.' + subKey.replace('.', '\\.'), lodash_1.default.get(controlDiff, key + '.' + subKey + '.__new'));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
});
|
|
73
|
+
profileDiff.changedControls[toControl.id] = simplifyDiff(controlDiff);
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|