@mitre/inspec-objects 0.0.19 → 0.0.22

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,8 +39,19 @@ function getExistingDescribeFromControl(control) {
39
39
  let existingDescribeBlock = '';
40
40
  let currentQuoteEscape = '';
41
41
  let inQuoteBlock = false;
42
+ let haveUsedSpecialCasingForArrays = false;
42
43
  control.code.split('\n').forEach((line) => {
43
44
  const wordSplit = line.trim().split(' ');
45
+ if (!inQuoteBlock) {
46
+ // Get the number of spaces at the beggining of the current line
47
+ const spaces = line.substring(0, line.indexOf(wordSplit[0])).length;
48
+ if (spaces >= 2) {
49
+ const firstWord = wordSplit[0];
50
+ if (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) === -1 || (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) !== -1 && spaces > 2)) {
51
+ existingDescribeBlock += line + '\n';
52
+ }
53
+ }
54
+ }
44
55
  wordSplit.forEach((word, index) => {
45
56
  const charSplit = word.split('');
46
57
  charSplit.forEach((char, index) => {
@@ -62,14 +73,17 @@ function getExistingDescribeFromControl(control) {
62
73
  }
63
74
  });
64
75
  });
65
- if (!inQuoteBlock) {
66
- // Get the number of spaces at the beggining of the current line
67
- const spaces = line.substring(0, line.indexOf(wordSplit[0])).length;
68
- if (spaces >= 2) {
69
- const firstWord = wordSplit[0];
70
- if (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) === -1 || (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) !== -1 && spaces > 2)) {
71
- existingDescribeBlock += line + '\n';
72
- }
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;
73
87
  }
74
88
  }
75
89
  });
package/package-lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mitre/inspec-objects",
3
- "version": "0.0.17",
3
+ "version": "0.0.22",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@mitre/inspec-objects",
9
- "version": "0.0.17",
9
+ "version": "0.0.22",
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.19",
3
+ "version": "0.0.22",
4
4
  "description": "Typescript objects for normalizing between InSpec profiles and XCCDF benchmarks",
5
5
  "main": "lib/index.js",
6
6
  "publishConfig": {