@mitre/inspec-objects 2.0.2 → 2.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/.github/dependabot.yml +5 -3
- package/.github/workflows/auto-approve-and-merge.yml +1 -0
- package/.github/workflows/build.yml +30 -0
- package/.github/workflows/push-to-gpr.yml +9 -7
- package/lib/objects/control.js +2 -10
- package/lib/parsers/oval.js +0 -1
- package/lib/parsers/xccdf.js +3 -5
- package/package.json +8 -19
- package/tsconfig.json +2 -2
- package/vitest.config.ts +7 -0
package/.github/dependabot.yml
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Build and Pack TS-InSpec-Objects
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [ main ]
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
name: Build and Pack TS-InSpec-Objects
|
|
10
|
+
runs-on: ubuntu-24.04
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Setup Node.js
|
|
16
|
+
uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: 22
|
|
19
|
+
cache: 'npm'
|
|
20
|
+
|
|
21
|
+
- name: Prep
|
|
22
|
+
run: |
|
|
23
|
+
npm ci
|
|
24
|
+
rm -rf test
|
|
25
|
+
|
|
26
|
+
- name: Build
|
|
27
|
+
run: npm run build
|
|
28
|
+
|
|
29
|
+
- name: Pack
|
|
30
|
+
run: npm pack
|
|
@@ -17,16 +17,18 @@ jobs:
|
|
|
17
17
|
registry-url: 'https://npm.pkg.github.com'
|
|
18
18
|
scope: '@mitre'
|
|
19
19
|
|
|
20
|
-
- name:
|
|
21
|
-
run:
|
|
22
|
-
npm install
|
|
23
|
-
rm -rf test
|
|
24
|
-
npm run build
|
|
20
|
+
- name: Install project dependencies
|
|
21
|
+
run: npm ci
|
|
25
22
|
|
|
26
|
-
- name:
|
|
23
|
+
- name: Remove testing resources
|
|
24
|
+
run: rm -rf test
|
|
25
|
+
|
|
26
|
+
- name: Build
|
|
27
|
+
run: npm run build
|
|
28
|
+
|
|
29
|
+
- name: Pack all items that are published as packages
|
|
27
30
|
run: npm pack
|
|
28
31
|
|
|
29
|
-
# Publish inspec-objects to GitHub Package Registry
|
|
30
32
|
- name: Publish inspec-objects to GPR
|
|
31
33
|
run: npm publish mitre-inspec-objects-*.tgz
|
|
32
34
|
env:
|
package/lib/objects/control.js
CHANGED
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.objectifyDescriptions = objectifyDescriptions;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
6
|
-
const flat_1 = require("flat");
|
|
7
|
-
const flat_2 = require("flat");
|
|
8
6
|
const global_1 = require("../utilities/global");
|
|
9
7
|
const logging_1 = require("../utilities/logging");
|
|
10
8
|
/**
|
|
@@ -60,7 +58,7 @@ class Control {
|
|
|
60
58
|
this.refs = [];
|
|
61
59
|
this.tags = {};
|
|
62
60
|
if (data) {
|
|
63
|
-
Object.entries(data).forEach(([key, value]) => {
|
|
61
|
+
Object.entries(lodash_1.default.cloneDeep(data)).forEach(([key, value]) => {
|
|
64
62
|
lodash_1.default.set(this, key, value);
|
|
65
63
|
});
|
|
66
64
|
}
|
|
@@ -73,13 +71,7 @@ class Control {
|
|
|
73
71
|
* @returns {Control} A new Control object created from the unformatted data.
|
|
74
72
|
*/
|
|
75
73
|
toUnformattedObject() {
|
|
76
|
-
|
|
77
|
-
Object.entries(flattened).forEach(([key, value]) => {
|
|
78
|
-
if (typeof value === 'string') {
|
|
79
|
-
lodash_1.default.set(flattened, key, value);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return new Control((0, flat_2.unflatten)(flattened));
|
|
74
|
+
return new Control(this);
|
|
83
75
|
}
|
|
84
76
|
/**
|
|
85
77
|
* Converts the control object to a string representation in a specific format.
|
package/lib/parsers/oval.js
CHANGED
|
@@ -109,7 +109,6 @@ function processOVAL(oval) {
|
|
|
109
109
|
extractedDefinitions[definition['@_id']].resolvedValues = (_a = extractedDefinitions[definition['@_id']].criteriaRefs) === null || _a === void 0 ? void 0 : _a.map((criteriaRef) => {
|
|
110
110
|
// Extract the original criteria from the oval file
|
|
111
111
|
const foundCriteriaRefererence = searchTree(parsed.oval_definitions[0].tests, (oNode) => oNode['@_id'] === criteriaRef, false)[0];
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
113
112
|
const foundObjects = [];
|
|
114
113
|
const foundStates = [];
|
|
115
114
|
if (foundCriteriaRefererence) {
|
package/lib/parsers/xccdf.js
CHANGED
|
@@ -174,9 +174,7 @@ function processXCCDF(xml, removeNewlines, useRuleId, ovalDefinitions) {
|
|
|
174
174
|
break;
|
|
175
175
|
case 'version':
|
|
176
176
|
if (rule.version !== undefined) {
|
|
177
|
-
(lodash_1.default.isArray(rule.version))
|
|
178
|
-
? control.id = rule.version[0]
|
|
179
|
-
: control.id = rule.version;
|
|
177
|
+
control.id = (lodash_1.default.isArray(rule.version)) ? rule.version[0] : rule.version;
|
|
180
178
|
}
|
|
181
179
|
else {
|
|
182
180
|
throw new Error('The rule type "version" did not provide an identification (Id) value');
|
|
@@ -344,8 +342,8 @@ function processXCCDF(xml, removeNewlines, useRuleId, ovalDefinitions) {
|
|
|
344
342
|
}
|
|
345
343
|
// Update the control tags base on corresponding rule tags.
|
|
346
344
|
control.tags.severity = (0, xccdf_1.impactNumberToSeverityString)((0, xccdf_1.severityStringToImpact)(rule['@_severity'] || 'medium'));
|
|
347
|
-
control.tags.gid = rule.group['@_id']
|
|
348
|
-
|
|
345
|
+
control.tags.gid = rule.group['@_id'];
|
|
346
|
+
control.tags.rid = rule['@_id'];
|
|
349
347
|
control.tags.stig_id = rule['version'];
|
|
350
348
|
if (typeof rule.group.title === 'string') {
|
|
351
349
|
control.tags.gtitle = (0, xccdf_1.removeXMLSpecialCharacters)(rule.group.title);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mitre/inspec-objects",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Typescript objects for normalizing between InSpec profiles and XCCDF benchmarks",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc -p ./tsconfig.build.json",
|
|
11
11
|
"dev": "npx -y ts-node test.ts",
|
|
12
|
-
"test": "
|
|
12
|
+
"test": "vitest",
|
|
13
13
|
"lint": "eslint \"**/*.ts\" --fix",
|
|
14
14
|
"lint:ci": "eslint \"**/*.ts\" --max-warnings 0"
|
|
15
15
|
},
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/mitre/ts-inspec-objects#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@types/flat": "5.0.2",
|
|
28
27
|
"@types/he": "^1.1.2",
|
|
29
28
|
"@types/json-diff": "^1.0.0",
|
|
30
29
|
"@types/jstoxml": "^2.0.2",
|
|
@@ -32,34 +31,24 @@
|
|
|
32
31
|
"@types/mustache": "^4.2.0",
|
|
33
32
|
"@types/pretty": "^2.0.1",
|
|
34
33
|
"fast-xml-parser": "^5.0.7",
|
|
35
|
-
"flat": "5.0.2",
|
|
36
34
|
"he": "^1.2.0",
|
|
37
35
|
"htmlparser2": "^10.0.0",
|
|
38
36
|
"inspecjs": "^2.6.6",
|
|
39
37
|
"json-diff": "^1.0.6",
|
|
40
|
-
"jstoxml": "^
|
|
38
|
+
"jstoxml": "^7.0.1",
|
|
41
39
|
"lodash": "^4.17.21",
|
|
42
40
|
"mustache": "^4.2.0",
|
|
43
41
|
"pretty": "^2.0.0",
|
|
42
|
+
"tslib": "^2.8.1",
|
|
44
43
|
"winston": "^3.8.1",
|
|
45
44
|
"yaml": "^2.3.1"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
|
-
"@types/jest": "^30.0.0",
|
|
49
47
|
"@types/node": "^24.0.0",
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
51
|
-
"@typescript-eslint/parser": "^
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
|
49
|
+
"@typescript-eslint/parser": "^8.35.1",
|
|
52
50
|
"eslint": "^8.30.0",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"tslib": "^2.4.0",
|
|
56
|
-
"typescript": "^5.2.2"
|
|
57
|
-
},
|
|
58
|
-
"jest": {
|
|
59
|
-
"rootDir": ".",
|
|
60
|
-
"testTimeout": 10000000,
|
|
61
|
-
"transform": {
|
|
62
|
-
"^.+\\.ts$": "ts-jest"
|
|
63
|
-
}
|
|
51
|
+
"typescript": "^5.2.2",
|
|
52
|
+
"vitest": "^3.2.4"
|
|
64
53
|
}
|
|
65
54
|
}
|
package/tsconfig.json
CHANGED