@mitre/inspec-objects 0.0.23 → 0.0.24

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.
@@ -1,4 +1,4 @@
1
- import winston from "winston";
1
+ import winston from 'winston';
2
2
  import Control from '../objects/control';
3
3
  import Profile from '../objects/profile';
4
4
  import { ProfileDiff } from '../types/diff';
@@ -9,13 +9,15 @@ const profile_1 = tslib_1.__importDefault(require("../objects/profile"));
9
9
  const xccdf_1 = require("../parsers/xccdf");
10
10
  const diff_1 = require("./diff");
11
11
  const diffMarkdown_1 = require("./diffMarkdown");
12
- const knownInSpecKeywords = ['title', 'desc', 'impact', 'ref', 'tag', "\""];
12
+ const knownInSpecKeywords = ['title', 'desc', 'impact', 'ref', 'tag', '"'];
13
13
  function projectValuesOntoExistingObj(dst, src, currentPath = '') {
14
14
  for (const updatedValue in src) {
15
15
  const existingValue = lodash_1.default.get(dst, updatedValue);
16
16
  // We have a new value for something that already exists in dst
17
17
  if (existingValue !== undefined) {
18
- if (typeof existingValue === 'object' && existingValue !== null && !Array.isArray(existingValue)) {
18
+ if (typeof existingValue === 'object' &&
19
+ existingValue !== null &&
20
+ !Array.isArray(existingValue)) {
19
21
  dst[updatedValue] = projectValuesOntoExistingObj(existingValue, src[updatedValue], currentPath + updatedValue + '.');
20
22
  }
21
23
  else if (typeof src[updatedValue] === 'string') {
@@ -25,7 +27,9 @@ function projectValuesOntoExistingObj(dst, src, currentPath = '') {
25
27
  lodash_1.default.set(dst, updatedValue, src[updatedValue]);
26
28
  }
27
29
  else if (Array.isArray(src[updatedValue])) {
28
- const uniqueArrayValues = [...new Set(lodash_1.default.get(dst, updatedValue, []).concat(src[updatedValue]))];
30
+ const uniqueArrayValues = [
31
+ ...new Set(lodash_1.default.get(dst, updatedValue, []).concat(src[updatedValue]))
32
+ ];
29
33
  lodash_1.default.set(dst, updatedValue, uniqueArrayValues);
30
34
  }
31
35
  }
@@ -43,8 +47,11 @@ function getExistingDescribeFromControl(control) {
43
47
  const splitLines = control.code.split('\n');
44
48
  splitLines.forEach((line, lineIndex) => {
45
49
  // Special case - Multi-line arrayed metadata value
46
- if (knownInSpecKeywords.indexOf(splitLines[lineIndex - 1].trim().split(' ')[0]) !== -1 && splitLines[lineIndex - 1].trim().split(' ')[1].startsWith('[')) {
47
- inMetadataValueOverride = true;
50
+ if (typeof splitLines[lineIndex - 1] === 'string') {
51
+ if (knownInSpecKeywords.indexOf(splitLines[lineIndex - 1].trim().split(' ')[0]) !== -1 &&
52
+ splitLines[lineIndex - 1].trim().split(' ')[1].startsWith('[')) {
53
+ inMetadataValueOverride = true;
54
+ }
48
55
  }
49
56
  const wordSplit = line.trim().split(' ');
50
57
  if (!inQuoteBlock && !inMetadataValueOverride) {
@@ -52,7 +59,9 @@ function getExistingDescribeFromControl(control) {
52
59
  const spaces = line.substring(0, line.indexOf(wordSplit[0])).length;
53
60
  if (spaces >= 2) {
54
61
  const firstWord = wordSplit[0];
55
- if (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) === -1 || (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) !== -1 && spaces > 2)) {
62
+ if (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) === -1 ||
63
+ (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) !== -1 &&
64
+ spaces > 2)) {
56
65
  existingDescribeBlock += line + '\n';
57
66
  }
58
67
  }
@@ -121,7 +130,7 @@ function updateProfile(from, using, logger) {
121
130
  // Find the diff
122
131
  const diff = (0, diff_1.diffProfile)(from, using, logger);
123
132
  // Add the new controls
124
- diff.simplified.addedControlIDs.forEach(id => {
133
+ diff.simplified.addedControlIDs.forEach((id) => {
125
134
  const addedControl = diff.simplified.addedControls[id];
126
135
  if (addedControl) {
127
136
  logger.debug(`New Control: ${addedControl.id} - ${addedControl.title}`);
@@ -146,7 +155,7 @@ function updateProfile(from, using, logger) {
146
155
  }
147
156
  return {
148
157
  profile: to,
149
- diff,
158
+ diff
150
159
  };
151
160
  }
152
161
  exports.updateProfile = updateProfile;
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mitre/inspec-objects",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@mitre/inspec-objects",
9
- "version": "0.0.23",
9
+ "version": "0.0.24",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@types/flat": "^5.0.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitre/inspec-objects",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Typescript objects for normalizing between InSpec profiles and XCCDF benchmarks",
5
5
  "main": "lib/index.js",
6
6
  "publishConfig": {