@mitre/inspec-objects 0.0.22 → 0.0.25

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,12 +39,21 @@ function getExistingDescribeFromControl(control) {
39
39
  let existingDescribeBlock = '';
40
40
  let currentQuoteEscape = '';
41
41
  let inQuoteBlock = false;
42
- let haveUsedSpecialCasingForArrays = false;
42
+ let inMetadataValueOverride = false;
43
+ let indentedMetadataOverride = false;
44
+ let mostSpacesSeen = 0;
43
45
  control.code.split('\n').forEach((line) => {
44
46
  const wordSplit = line.trim().split(' ');
45
- if (!inQuoteBlock) {
47
+ const spaces = line.substring(0, line.indexOf(wordSplit[0])).length;
48
+ if (spaces - mostSpacesSeen > 10) {
49
+ indentedMetadataOverride = true;
50
+ }
51
+ else {
52
+ mostSpacesSeen = spaces;
53
+ indentedMetadataOverride = false;
54
+ }
55
+ if (!inQuoteBlock && !inMetadataValueOverride && !indentedMetadataOverride) {
46
56
  // Get the number of spaces at the beggining of the current line
47
- const spaces = line.substring(0, line.indexOf(wordSplit[0])).length;
48
57
  if (spaces >= 2) {
49
58
  const firstWord = wordSplit[0];
50
59
  if (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) === -1 || (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) !== -1 && spaces > 2)) {
@@ -73,19 +82,6 @@ function getExistingDescribeFromControl(control) {
73
82
  }
74
83
  });
75
84
  });
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
85
  });
90
86
  return existingDescribeBlock;
91
87
  }
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.25",
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.25",
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.25",
4
4
  "description": "Typescript objects for normalizing between InSpec profiles and XCCDF benchmarks",
5
5
  "main": "lib/index.js",
6
6
  "publishConfig": {