@mitre/inspec-objects 0.0.2 → 0.0.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/mappings/CciNistMappingData.d.ts +5100 -0
- package/lib/mappings/CciNistMappingData.js +5103 -0
- package/lib/objects/control.js +6 -6
- package/lib/parsers/xccdf.d.ts +1 -1
- package/lib/parsers/xccdf.js +62 -16
- package/lib/utilities/CciNistMappingData.d.ts +5100 -0
- package/lib/utilities/CciNistMappingData.js +5103 -0
- package/lib/utilities/diff.d.ts +1 -2
- package/lib/utilities/diff.js +15 -4
- package/lib/utilities/global.d.ts +1 -0
- package/lib/utilities/global.js +34 -2
- package/lib/utilities/xccdf.d.ts +1 -0
- package/lib/utilities/xccdf.js +5 -1
- package/mitre-inspec-objects-v0.0.3.tgz +0 -0
- package/mitre-inspec-objects-v0.0.5.tgz +0 -0
- package/package-lock.json +38 -3415
- package/package.json +4 -4
- package/tsconfig.json +1 -1
- package/error.log +0 -12
- package/mitre-inspec-objects-v0.0.1.tgz +0 -0
- package/src/index.ts +0 -5
- package/src/objects/control.ts +0 -148
- package/src/objects/profile.ts +0 -93
- package/src/parsers/json.ts +0 -92
- package/src/parsers/oval.ts +0 -18
- package/src/parsers/xccdf.ts +0 -222
- package/src/types/diff.d.ts +0 -9
- package/src/types/oval.d.ts +0 -609
- package/src/types/xccdf.d.ts +0 -883
- package/src/utilities/diff.ts +0 -60
- package/src/utilities/global.ts +0 -52
- package/src/utilities/xccdf.ts +0 -115
- package/types/ionchannelAnalysis.d.ts +0 -238
- package/types/ionchannelProjects.d.ts +0 -72
- package/types/ionchannelTeams.d.ts +0 -26
- package/types/reverseMappedXCCDF.d.ts +0 -67
- package/types/splunk-sdk-no-env/index.d.ts +0 -88
package/lib/utilities/diff.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Profile from '../objects/profile';
|
|
2
2
|
import { ProfileDiff } from '../types/diff';
|
|
3
|
-
|
|
4
|
-
export declare function updateControl(originalControlString: string, originalControl: Control, updatedControl: Control): void;
|
|
3
|
+
export declare function removeNewlines(control?: Record<string, unknown>): Record<string, unknown>;
|
|
5
4
|
export declare function diffProfile(fromProfile: Profile, toProfile: Profile): ProfileDiff;
|
package/lib/utilities/diff.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.diffProfile = exports.
|
|
3
|
+
exports.diffProfile = 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"));
|
|
7
|
-
function
|
|
8
|
-
|
|
7
|
+
function removeNewlines(control) {
|
|
8
|
+
if (!control) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
return lodash_1.default.mapValues(control, (value) => {
|
|
12
|
+
if (typeof value === 'string') {
|
|
13
|
+
return value.replace(/\n/g, '{{{{newlineHERE}}}}').trim();
|
|
14
|
+
}
|
|
15
|
+
else if (typeof value === 'object' && value !== null) {
|
|
16
|
+
return removeNewlines(value);
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
});
|
|
9
20
|
}
|
|
10
|
-
exports.
|
|
21
|
+
exports.removeNewlines = removeNewlines;
|
|
11
22
|
function diffProfile(fromProfile, toProfile) {
|
|
12
23
|
const profileDiff = {
|
|
13
24
|
addedControlIDs: [],
|
|
@@ -4,5 +4,6 @@ declare const escapeQuotes: (s: string) => string;
|
|
|
4
4
|
declare const escapeDoubleQuotes: (s: string) => string;
|
|
5
5
|
declare const wrapAndEscapeQuotes: (s: string, lineLength?: number) => string;
|
|
6
6
|
export { escapeQuotes, escapeDoubleQuotes, wrapAndEscapeQuotes };
|
|
7
|
+
export declare function removeNewlinePlaceholders(s: string): string;
|
|
7
8
|
export declare function getFirstPath(object: Record<string, unknown>, paths: string[]): string;
|
|
8
9
|
export declare function hasPath(file: Record<string, unknown>, path: string | string[]): boolean;
|
package/lib/utilities/global.js
CHANGED
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasPath = exports.getFirstPath = exports.wrapAndEscapeQuotes = exports.escapeDoubleQuotes = exports.escapeQuotes = exports.unformatText = exports.wrap = void 0;
|
|
3
|
+
exports.hasPath = exports.getFirstPath = exports.removeNewlinePlaceholders = exports.wrapAndEscapeQuotes = exports.escapeDoubleQuotes = exports.escapeQuotes = exports.unformatText = exports.wrap = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
6
|
// Breaks lines down to lineLength number of characters
|
|
7
7
|
function wrap(s, lineLength = 80) {
|
|
8
|
-
|
|
8
|
+
let newString = "";
|
|
9
|
+
let currentLine = "";
|
|
10
|
+
let currentLength = 0;
|
|
11
|
+
let shouldBreakLine = false;
|
|
12
|
+
for (var i = 0; i < s.length; i++) {
|
|
13
|
+
if (shouldBreakLine) {
|
|
14
|
+
newString += `\n`;
|
|
15
|
+
currentLength = 0;
|
|
16
|
+
shouldBreakLine = false;
|
|
17
|
+
}
|
|
18
|
+
let currentChar = s.charAt(i);
|
|
19
|
+
let nextChar = s.charAt(i + 1);
|
|
20
|
+
if (nextChar === " ") {
|
|
21
|
+
if (currentLength >= lineLength) {
|
|
22
|
+
shouldBreakLine = true;
|
|
23
|
+
newString += currentChar;
|
|
24
|
+
currentLength++;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
newString += currentChar;
|
|
28
|
+
currentLength++;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
newString += currentChar;
|
|
33
|
+
currentLength++;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return newString;
|
|
9
37
|
}
|
|
10
38
|
exports.wrap = wrap;
|
|
11
39
|
function unformatText(s) {
|
|
@@ -18,6 +46,10 @@ const escapeDoubleQuotes = (s) => s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
|
18
46
|
exports.escapeDoubleQuotes = escapeDoubleQuotes;
|
|
19
47
|
const wrapAndEscapeQuotes = (s, lineLength) => escapeDoubleQuotes(wrap(s, lineLength)); // Escape backslashes and quotes, and wrap long lines
|
|
20
48
|
exports.wrapAndEscapeQuotes = wrapAndEscapeQuotes;
|
|
49
|
+
function removeNewlinePlaceholders(s) {
|
|
50
|
+
return s.replace(/\{\{\{\{newlineHERE\}\}\}\}/g, '\n');
|
|
51
|
+
}
|
|
52
|
+
exports.removeNewlinePlaceholders = removeNewlinePlaceholders;
|
|
21
53
|
function getFirstPath(object, paths) {
|
|
22
54
|
const index = lodash_1.default.findIndex(paths, (p) => hasPath(object, p));
|
|
23
55
|
if (index === -1) {
|
package/lib/utilities/xccdf.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DecodedDescription } from '../types/xccdf';
|
|
2
2
|
export declare function convertEncodedXmlIntoJson(encodedXml: string): any;
|
|
3
|
+
export declare function removeXMLSpecialCharacters(input: string): string;
|
|
3
4
|
export declare function severityStringToImpact(string: string, id: string): number;
|
|
4
5
|
export declare function impactNumberToSeverityString(impact: number): string;
|
|
5
6
|
export declare function convertEncodedHTMLIntoJson(encodedHTML?: string): DecodedDescription;
|
package/lib/utilities/xccdf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertEncodedHTMLIntoJson = exports.impactNumberToSeverityString = exports.severityStringToImpact = exports.convertEncodedXmlIntoJson = void 0;
|
|
3
|
+
exports.convertEncodedHTMLIntoJson = exports.impactNumberToSeverityString = exports.severityStringToImpact = exports.removeXMLSpecialCharacters = exports.convertEncodedXmlIntoJson = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fast_xml_parser_1 = tslib_1.__importDefault(require("fast-xml-parser"));
|
|
6
6
|
const htmlparser = tslib_1.__importStar(require("htmlparser2"));
|
|
@@ -14,6 +14,10 @@ function convertEncodedXmlIntoJson(encodedXml) {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
exports.convertEncodedXmlIntoJson = convertEncodedXmlIntoJson;
|
|
17
|
+
function removeXMLSpecialCharacters(input) {
|
|
18
|
+
return input.replace(/&/gm, '&').replace(/</gm, '<').replace(/>/gm, '>');
|
|
19
|
+
}
|
|
20
|
+
exports.removeXMLSpecialCharacters = removeXMLSpecialCharacters;
|
|
17
21
|
function severityStringToImpact(string, id) {
|
|
18
22
|
var _a, _b, _c, _d, _e;
|
|
19
23
|
if ((_a = string.match(/none|na|n\/a|not[\s()*_|]?applicable/i)) === null || _a === void 0 ? void 0 : _a.length) {
|
|
Binary file
|
|
Binary file
|