@mitre/inspec-objects 2.0.1 → 2.0.4
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 +2 -4
- package/.github/workflows/build.yml +30 -0
- package/.github/workflows/draft-release.yml +3 -3
- package/.github/workflows/e2e-test.yml +4 -4
- package/.github/workflows/linter.yml +4 -4
- package/.github/workflows/push-to-gpr.yml +16 -17
- package/.github/workflows/push-to-npm.yml +4 -4
- package/README.md +39 -7
- package/images/ts-inspec-objects-inspec-profile-workflow-process.png +0 -0
- package/images/ts-inspec-objects-oval-workflow-process.png +0 -0
- package/images/ts-inspec-objects-process-updateControl-workflow.png +0 -0
- package/images/ts-inspec-objects-updateProfileUsingXccdf-workflow.png +0 -0
- package/images/ts-inspec-objects-xccdf-workflow-process.png +0 -0
- package/lib/parsers/oval.js +0 -1
- package/lib/parsers/xccdf.d.ts +2 -1
- package/lib/parsers/xccdf.js +5 -6
- package/lib/utilities/update.d.ts +10 -0
- package/lib/utilities/update.js +11 -1
- package/lib/utilities/xccdf.d.ts +9 -2
- package/lib/utilities/xccdf.js +19 -2
- package/package.json +12 -21
- package/tsconfig.json +2 -2
- package/vitest.config.ts +7 -0
package/.github/dependabot.yml
CHANGED
|
@@ -10,11 +10,9 @@ jobs:
|
|
|
10
10
|
approve:
|
|
11
11
|
name: Auto-approve dependabot PRs
|
|
12
12
|
if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies')
|
|
13
|
-
runs-on: ubuntu-
|
|
13
|
+
runs-on: ubuntu-24.04
|
|
14
14
|
steps:
|
|
15
|
-
- uses: hmarr/auto-approve-action@
|
|
16
|
-
with:
|
|
17
|
-
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
15
|
+
- uses: hmarr/auto-approve-action@v4
|
|
18
16
|
- name: Enable auto-merge for Dependabot PRs
|
|
19
17
|
run: gh pr merge --auto --merge "$PR_URL"
|
|
20
18
|
env:
|
|
@@ -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
|
|
@@ -8,9 +8,9 @@ on:
|
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
10
|
update_draft_release:
|
|
11
|
-
runs-on: ubuntu-
|
|
11
|
+
runs-on: ubuntu-24.04
|
|
12
12
|
steps:
|
|
13
13
|
# Drafts your next Release notes as Pull Requests are merged into "master"
|
|
14
|
-
- uses:
|
|
14
|
+
- uses: release-drafter/release-drafter@v6
|
|
15
15
|
env:
|
|
16
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
16
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -7,15 +7,15 @@ on:
|
|
|
7
7
|
jobs:
|
|
8
8
|
build:
|
|
9
9
|
name: Run TS-InSpec-Objects E2E Tests
|
|
10
|
-
runs-on: ubuntu-
|
|
10
|
+
runs-on: ubuntu-24.04
|
|
11
11
|
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
14
|
|
|
15
15
|
- name: Setup Node.js
|
|
16
|
-
uses: actions/setup-node@
|
|
16
|
+
uses: actions/setup-node@v4
|
|
17
17
|
with:
|
|
18
|
-
node-version:
|
|
18
|
+
node-version: 22
|
|
19
19
|
cache: 'npm'
|
|
20
20
|
|
|
21
21
|
- name: Install dependencies
|
|
@@ -7,16 +7,16 @@ on:
|
|
|
7
7
|
jobs:
|
|
8
8
|
build:
|
|
9
9
|
name: Lint TS-InSpec-Objects
|
|
10
|
-
runs-on: ubuntu-
|
|
10
|
+
runs-on: ubuntu-24.04
|
|
11
11
|
|
|
12
12
|
steps:
|
|
13
13
|
- name: Checkout code
|
|
14
|
-
uses: actions/checkout@
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
15
|
|
|
16
16
|
- name: Setup Node.js
|
|
17
|
-
uses: actions/setup-node@
|
|
17
|
+
uses: actions/setup-node@v4
|
|
18
18
|
with:
|
|
19
|
-
node-version:
|
|
19
|
+
node-version: 22
|
|
20
20
|
cache: 'npm'
|
|
21
21
|
|
|
22
22
|
- name: Install project dependencies
|
|
@@ -6,31 +6,30 @@ on:
|
|
|
6
6
|
|
|
7
7
|
jobs:
|
|
8
8
|
build-deploy:
|
|
9
|
-
runs-on: ubuntu-
|
|
9
|
+
runs-on: ubuntu-24.04
|
|
10
10
|
steps:
|
|
11
|
-
- uses: actions/checkout@
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
12
|
|
|
13
13
|
- name: Setup node
|
|
14
|
-
uses: actions/setup-node@
|
|
14
|
+
uses: actions/setup-node@v4
|
|
15
15
|
with:
|
|
16
|
-
node-version:
|
|
17
|
-
registry-url: https://npm.pkg.github.com
|
|
16
|
+
node-version: 22
|
|
17
|
+
registry-url: 'https://npm.pkg.github.com'
|
|
18
18
|
scope: '@mitre'
|
|
19
19
|
|
|
20
|
-
- name:
|
|
21
|
-
run:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
- name: Install project dependencies
|
|
21
|
+
run: npm ci
|
|
22
|
+
|
|
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
|
|
25
30
|
run: npm pack
|
|
26
|
-
# Setup .npmrc file to publish to GitHub Package Registry
|
|
27
|
-
- uses: actions/setup-node@v1
|
|
28
|
-
with:
|
|
29
|
-
registry-url: 'https://npm.pkg.github.com'
|
|
30
|
-
scope: '@mitre'
|
|
31
31
|
|
|
32
|
-
# Publish inspec-objects to GitHub Package Registry
|
|
33
32
|
- name: Publish inspec-objects to GPR
|
|
34
33
|
run: npm publish mitre-inspec-objects-*.tgz
|
|
35
34
|
env:
|
|
36
|
-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -6,14 +6,14 @@ on:
|
|
|
6
6
|
|
|
7
7
|
jobs:
|
|
8
8
|
build-deploy:
|
|
9
|
-
runs-on: ubuntu-
|
|
9
|
+
runs-on: ubuntu-24.04
|
|
10
10
|
steps:
|
|
11
|
-
- uses: actions/checkout@
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
12
|
|
|
13
13
|
- name: setup node
|
|
14
|
-
uses: actions/setup-node@
|
|
14
|
+
uses: actions/setup-node@v4
|
|
15
15
|
with:
|
|
16
|
-
node-version:
|
|
16
|
+
node-version: 22
|
|
17
17
|
registry-url: 'https://registry.npmjs.org'
|
|
18
18
|
|
|
19
19
|
- name: Install project dependencies
|
package/README.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# ts-inspec-objects
|
|
2
|
-
Typescript objects for InSpec
|
|
2
|
+
Typescript objects for InSpec Profiles
|
|
3
3
|
|
|
4
|
-
This repository contains the source code that facilitates the writing of InSpec
|
|
4
|
+
This repository contains the source code that facilitates the writing of InSpec Profiles (for use in things like stub generation and delta comparisons) more consistent with `Chef Cookstyle` formatting for ease of use when comparing with new changes from delta and when generating InSpec stubs that match a standard format.
|
|
5
5
|
|
|
6
6
|
For more information about Chef Cookstyle see:
|
|
7
7
|
- [chef/cookstyle on GitHub](https://github.com/chef/cookstyle)
|
|
8
8
|
- [Chef Cookstyle on Chef documents page](https://docs.chef.io/workstation/cookstyle/)
|
|
9
9
|
|
|
10
|
+
The `ts-inspec-objects` provides the capability of updating InSpect Profiles and creating stub Profiles based on XCCDF Benchmarks. This is accomplished by providing `Profile` and `Control` classes and supporting methods (functions).
|
|
11
|
+
|
|
10
12
|
## How to Use
|
|
11
13
|
The process code maintained in this repository generates a `npm` executable that is published to the `npm registry` as [mitre-inspec-objects](https://www.npmjs.com/package/@mitre/inspec-objects).
|
|
12
14
|
|
|
@@ -18,7 +20,7 @@ The package is a CommonJS-based npm written in TypeScript
|
|
|
18
20
|
|
|
19
21
|
## Parsing Process
|
|
20
22
|
|
|
21
|
-
When using this library to parse `InSpec
|
|
23
|
+
When using this library to parse `InSpec Profiles` or `xccdf files` for the purposes of generating InSpec profiles, the general workflow is as follows:
|
|
22
24
|
```
|
|
23
25
|
- The input is processed, read into a typescript object
|
|
24
26
|
- Operated on with any required action / logic
|
|
@@ -39,16 +41,46 @@ Here are some formatting choices that are being made.
|
|
|
39
41
|
2. Tag keywords are not quoted (ex: tag severity: 'medium')
|
|
40
42
|
3. Each control file ends with a newline
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
---
|
|
45
|
+
### XCCDF Workflow Process
|
|
46
|
+
Processes an XCCDF (Extensible Configuration Checklist Description Format) XML string based on the `Rule Identifier` provided and converts it into a Profile object.
|
|
47
|
+
If and OVAL definition is provided it retrives the oval objects and associated states and the Controls description check text is update with the content.
|
|
48
|
+
<div align="center">
|
|
49
|
+
<img src="images/ts-inspec-objects-xccdf-workflow-process.png" alt="Typescript Objects XCCDF Conversion Workflow Process" title="Typescript Objects XCCDF Conversion Workflow Process">
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
### OVAL Workflow Process
|
|
53
|
+
Processes an OVAL (Open Vulnerability and Assessment Language) XML string and converts it into a JSON object.
|
|
54
|
+
The process extracts definitions and their associated criteria references and resolved values.
|
|
55
|
+
The process executes the following steps:
|
|
56
|
+
1. Converts the OVAL XML string into a JSON object.
|
|
57
|
+
2. Iterates through the OVAL definitions and extracts each definition.
|
|
58
|
+
3. For each definition, extracts criteria references and resolves the associated objects and states.
|
|
59
|
+
4. Logs warnings if any objects or states cannot be found.
|
|
60
|
+
<div align="center">
|
|
61
|
+
<img src="images/ts-inspec-objects-oval-workflow-process.png" alt="Typescript Objects Oval Conversion Workflow Process" title="Typescript Objects Oval Conversion Workflow Process">
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
### InSpec Profile Workflow Process
|
|
65
|
+
Process a JSON string representing an InSpec profile, converts it, and processes it to return a `Profile` object.
|
|
66
|
+
It handles different versions of the InSpec JSON format and sorts the controls by their ID.
|
|
67
|
+
<div align="center">
|
|
68
|
+
<img src="images/ts-inspec-objects-inspec-profile-workflow-process.png" alt="Typescript Objects InSpec Profile Workflow Process" title="Typescript Objects InSpec Profile Workflow Process">
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
### Update Profile Using XCCDF Workflow Process
|
|
72
|
+
Updates a Profile with new metadata from and XCCDF, based on the `Rule Indetefier` and logs the process.
|
|
43
73
|
<div align="center">
|
|
44
|
-
<img src="images/ts-inspec-objects.
|
|
74
|
+
<img src="images/ts-inspec-objects-updateProfileUsingXccdf-workflow.png" alt="Typescript Objects Update Profile Using XCCDF Workflow Process" title="Typescript Objects Update Profile Using XCCDF Workflow Process">
|
|
45
75
|
</div>
|
|
46
76
|
|
|
47
|
-
###
|
|
77
|
+
### Update Control Workflow Process
|
|
78
|
+
Updates a given control object with the provided partial control and logs the process.
|
|
48
79
|
<div align="center">
|
|
49
|
-
<img src="images/
|
|
80
|
+
<img src="images/ts-inspec-objects-process-updateControl-workflow.png" alt="Typescript Objects Update Control Workflow Process" title="Typescript Objects Update Control Workflow Process">
|
|
50
81
|
</div>
|
|
51
82
|
|
|
83
|
+
---
|
|
52
84
|
## Development Environment Configuration
|
|
53
85
|
### Installation
|
|
54
86
|
To install the project, clone the repository and install the dependencies:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
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.d.ts
CHANGED
|
@@ -27,7 +27,8 @@ export type InputTextLang = {
|
|
|
27
27
|
'@_lang': string;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* Processes an XCCDF
|
|
30
|
+
* Processes an XCCDF (Extensible Configuration Checklist Description Format) XML
|
|
31
|
+
* string and converts it into a Profile object.
|
|
31
32
|
* NOTE: We are using the fast xml parser (FXP) V4 which requires to specify
|
|
32
33
|
* which Whether a single tag should be parsed as an array or an object,
|
|
33
34
|
* it can't be decided by FXP. We process every tag as an array, this is
|
package/lib/parsers/xccdf.js
CHANGED
|
@@ -75,7 +75,8 @@ function ensureDecodedXMLStringValue(input, defaultValue) {
|
|
|
75
75
|
: lodash_1.default.get(input, '#text', defaultValue);
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* Processes an XCCDF
|
|
78
|
+
* Processes an XCCDF (Extensible Configuration Checklist Description Format) XML
|
|
79
|
+
* string and converts it into a Profile object.
|
|
79
80
|
* NOTE: We are using the fast xml parser (FXP) V4 which requires to specify
|
|
80
81
|
* which Whether a single tag should be parsed as an array or an object,
|
|
81
82
|
* it can't be decided by FXP. We process every tag as an array, this is
|
|
@@ -173,9 +174,7 @@ function processXCCDF(xml, removeNewlines, useRuleId, ovalDefinitions) {
|
|
|
173
174
|
break;
|
|
174
175
|
case 'version':
|
|
175
176
|
if (rule.version !== undefined) {
|
|
176
|
-
(lodash_1.default.isArray(rule.version))
|
|
177
|
-
? control.id = rule.version[0]
|
|
178
|
-
: control.id = rule.version;
|
|
177
|
+
control.id = (lodash_1.default.isArray(rule.version)) ? rule.version[0] : rule.version;
|
|
179
178
|
}
|
|
180
179
|
else {
|
|
181
180
|
throw new Error('The rule type "version" did not provide an identification (Id) value');
|
|
@@ -343,8 +342,8 @@ function processXCCDF(xml, removeNewlines, useRuleId, ovalDefinitions) {
|
|
|
343
342
|
}
|
|
344
343
|
// Update the control tags base on corresponding rule tags.
|
|
345
344
|
control.tags.severity = (0, xccdf_1.impactNumberToSeverityString)((0, xccdf_1.severityStringToImpact)(rule['@_severity'] || 'medium'));
|
|
346
|
-
control.tags.gid = rule.group['@_id']
|
|
347
|
-
|
|
345
|
+
control.tags.gid = rule.group['@_id'];
|
|
346
|
+
control.tags.rid = rule['@_id'];
|
|
348
347
|
control.tags.stig_id = rule['version'];
|
|
349
348
|
if (typeof rule.group.title === 'string') {
|
|
350
349
|
control.tags.gtitle = (0, xccdf_1.removeXMLSpecialCharacters)(rule.group.title);
|
|
@@ -74,4 +74,14 @@ export declare function updateControlDescribeBlock(from: Control, update: Partia
|
|
|
74
74
|
* @throws Will throw an error if a new control is added but the control data is not available.
|
|
75
75
|
*/
|
|
76
76
|
export declare function updateProfile(from: Profile, using: Profile, logger: winston.Logger): Omit<UpdatedProfileReturn, 'markdown'>;
|
|
77
|
+
/**
|
|
78
|
+
* Update a Profile with with new metadata from a XCCDF benchmark
|
|
79
|
+
*
|
|
80
|
+
* @param from - A Profile object
|
|
81
|
+
* @param using - An XCCDF in string format (XML)
|
|
82
|
+
* @param id - Specifies the rule ID format to use ('group', 'rule', 'version', or 'cis').
|
|
83
|
+
* @param logger - A winston logger instance for logging debug information.
|
|
84
|
+
* @param ovalDefinitions - Optional OVAL definitions to use for resolving values.
|
|
85
|
+
* @returns The Updated Profile (profile, the diff between from and using, and the markdown)
|
|
86
|
+
*/
|
|
77
87
|
export declare function updateProfileUsingXCCDF(from: Profile, using: string, id: 'group' | 'rule' | 'version' | 'cis', logger: winston.Logger, ovalDefinitions?: Record<string, OvalDefinitionValue>): UpdatedProfileReturn;
|
package/lib/utilities/update.js
CHANGED
|
@@ -377,9 +377,19 @@ function updateProfile(from, using, logger) {
|
|
|
377
377
|
diff,
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* Update a Profile with with new metadata from a XCCDF benchmark
|
|
382
|
+
*
|
|
383
|
+
* @param from - A Profile object
|
|
384
|
+
* @param using - An XCCDF in string format (XML)
|
|
385
|
+
* @param id - Specifies the rule ID format to use ('group', 'rule', 'version', or 'cis').
|
|
386
|
+
* @param logger - A winston logger instance for logging debug information.
|
|
387
|
+
* @param ovalDefinitions - Optional OVAL definitions to use for resolving values.
|
|
388
|
+
* @returns The Updated Profile (profile, the diff between from and using, and the markdown)
|
|
389
|
+
*/
|
|
380
390
|
function updateProfileUsingXCCDF(from, using, id, logger, ovalDefinitions) {
|
|
381
391
|
logger.info(`Updating profile ${from.name} with control IDs type: ${id}`);
|
|
382
|
-
// Parse the XCCDF benchmark and convert it into a Profile
|
|
392
|
+
// Parse the XCCDF benchmark and convert it into a Profile object
|
|
383
393
|
logger.debug('Loading XCCDF File');
|
|
384
394
|
const xccdfProfile = (0, xccdf_1.processXCCDF)(using, false, id, ovalDefinitions);
|
|
385
395
|
logger.debug('Loaded XCCDF File');
|
package/lib/utilities/xccdf.d.ts
CHANGED
|
@@ -68,10 +68,17 @@ export declare function convertJsonIntoXML(data: any): string;
|
|
|
68
68
|
*/
|
|
69
69
|
export declare function removeXMLSpecialCharacters(str: string): string;
|
|
70
70
|
/**
|
|
71
|
-
* Removes HTML tags
|
|
72
|
-
|
|
71
|
+
* Removes all of the HTML tags and leaves only the text content.
|
|
72
|
+
*
|
|
73
73
|
* @param input - The string from which HTML tags should be removed.
|
|
74
74
|
* @returns A new string with all HTML tags removed.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const str = '<div>Hello <b>World</b>!</div>';
|
|
79
|
+
* const stripped = removeHtmlTags(str);
|
|
80
|
+
* console.log(stripped); // Output: "Hello World!"
|
|
81
|
+
* ```
|
|
75
82
|
*/
|
|
76
83
|
export declare function removeHtmlTags(input: string): string;
|
|
77
84
|
/**
|
package/lib/utilities/xccdf.js
CHANGED
|
@@ -118,12 +118,29 @@ function removeXMLSpecialCharacters(str) {
|
|
|
118
118
|
return result;
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
|
-
* Removes HTML tags
|
|
122
|
-
|
|
121
|
+
* Removes all of the HTML tags and leaves only the text content.
|
|
122
|
+
*
|
|
123
123
|
* @param input - The string from which HTML tags should be removed.
|
|
124
124
|
* @returns A new string with all HTML tags removed.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const str = '<div>Hello <b>World</b>!</div>';
|
|
129
|
+
* const stripped = removeHtmlTags(str);
|
|
130
|
+
* console.log(stripped); // Output: "Hello World!"
|
|
131
|
+
* ```
|
|
125
132
|
*/
|
|
126
133
|
function removeHtmlTags(input) {
|
|
134
|
+
// Regex explained
|
|
135
|
+
// <: Matches the opening angle bracket of an HTML tag
|
|
136
|
+
// /?: Matches zero or one forward slash /, to include closing tags
|
|
137
|
+
// [^>]: Matches any character except the > symbol
|
|
138
|
+
// +: Ensures preceding pattern ([^>]) matches one or more characters
|
|
139
|
+
// (>|$):
|
|
140
|
+
// > matches the closing angle bracket of an HTML tag.
|
|
141
|
+
// $ matches the end of the string. This ensures the regex can handle
|
|
142
|
+
// cases where the tag is incomplete or unclosed (e.g., <div)
|
|
143
|
+
// g: Global flag to find all matches in the input string
|
|
127
144
|
return input.replace(/<\/?[^>]+(>|$)/g, '');
|
|
128
145
|
}
|
|
129
146
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mitre/inspec-objects",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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,42 +24,33 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/mitre/ts-inspec-objects#readme",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@types/flat": "5.0.
|
|
27
|
+
"@types/flat": "5.0.5",
|
|
28
28
|
"@types/he": "^1.1.2",
|
|
29
29
|
"@types/json-diff": "^1.0.0",
|
|
30
30
|
"@types/jstoxml": "^2.0.2",
|
|
31
31
|
"@types/lodash": "^4.14.178",
|
|
32
32
|
"@types/mustache": "^4.2.0",
|
|
33
33
|
"@types/pretty": "^2.0.1",
|
|
34
|
-
"fast-xml-parser": "^
|
|
35
|
-
"flat": "
|
|
34
|
+
"fast-xml-parser": "^5.0.7",
|
|
35
|
+
"flat": "6.0.1",
|
|
36
36
|
"he": "^1.2.0",
|
|
37
37
|
"htmlparser2": "^10.0.0",
|
|
38
38
|
"inspecjs": "^2.6.6",
|
|
39
39
|
"json-diff": "^1.0.6",
|
|
40
|
-
"jstoxml": "^
|
|
40
|
+
"jstoxml": "^7.0.1",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"mustache": "^4.2.0",
|
|
43
43
|
"pretty": "^2.0.0",
|
|
44
|
+
"tslib": "^2.8.1",
|
|
44
45
|
"winston": "^3.8.1",
|
|
45
46
|
"yaml": "^2.3.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@types/
|
|
49
|
-
"@
|
|
50
|
-
"@typescript-eslint/
|
|
51
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
49
|
+
"@types/node": "^24.0.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
|
51
|
+
"@typescript-eslint/parser": "^8.35.1",
|
|
52
52
|
"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
|
-
}
|
|
53
|
+
"typescript": "^5.2.2",
|
|
54
|
+
"vitest": "^3.2.4"
|
|
64
55
|
}
|
|
65
56
|
}
|
package/tsconfig.json
CHANGED