@mitre/inspec-objects 0.0.22 → 0.0.23

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.
@@ -39,10 +39,15 @@ function getExistingDescribeFromControl(control) {
39
39
  let existingDescribeBlock = '';
40
40
  let currentQuoteEscape = '';
41
41
  let inQuoteBlock = false;
42
- let haveUsedSpecialCasingForArrays = false;
43
- control.code.split('\n').forEach((line) => {
42
+ let inMetadataValueOverride = false;
43
+ const splitLines = control.code.split('\n');
44
+ splitLines.forEach((line, lineIndex) => {
45
+ // 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;
48
+ }
44
49
  const wordSplit = line.trim().split(' ');
45
- if (!inQuoteBlock) {
50
+ if (!inQuoteBlock && !inMetadataValueOverride) {
46
51
  // Get the number of spaces at the beggining of the current line
47
52
  const spaces = line.substring(0, line.indexOf(wordSplit[0])).length;
48
53
  if (spaces >= 2) {
@@ -73,19 +78,6 @@ function getExistingDescribeFromControl(control) {
73
78
  }
74
79
  });
75
80
  });
76
- // Special casing for arrays split across multiple lines
77
- if (line.endsWith(']')) {
78
- if (line.trim().startsWith('"') || line.trim().startsWith("'")) {
79
- inQuoteBlock = true;
80
- haveUsedSpecialCasingForArrays = false;
81
- }
82
- }
83
- else {
84
- if (haveUsedSpecialCasingForArrays) {
85
- inQuoteBlock = false;
86
- haveUsedSpecialCasingForArrays = false;
87
- }
88
- }
89
81
  });
90
82
  return existingDescribeBlock;
91
83
  }
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mitre/inspec-objects",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@mitre/inspec-objects",
9
- "version": "0.0.22",
9
+ "version": "0.0.23",
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.22",
3
+ "version": "0.0.23",
4
4
  "description": "Typescript objects for normalizing between InSpec profiles and XCCDF benchmarks",
5
5
  "main": "lib/index.js",
6
6
  "publishConfig": {