@mitre/inspec-objects 0.0.23 → 0.0.26

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.
@@ -40,16 +40,20 @@ function getExistingDescribeFromControl(control) {
40
40
  let currentQuoteEscape = '';
41
41
  let inQuoteBlock = false;
42
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
- }
43
+ let indentedMetadataOverride = false;
44
+ let mostSpacesSeen = 0;
45
+ control.code.split('\n').forEach((line) => {
49
46
  const wordSplit = line.trim().split(' ');
50
- if (!inQuoteBlock && !inMetadataValueOverride) {
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) {
51
56
  // Get the number of spaces at the beggining of the current line
52
- const spaces = line.substring(0, line.indexOf(wordSplit[0])).length;
53
57
  if (spaces >= 2) {
54
58
  const firstWord = wordSplit[0];
55
59
  if (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) === -1 || (knownInSpecKeywords.indexOf(firstWord.toLowerCase()) !== -1 && spaces > 2)) {
@@ -1,5 +1,6 @@
1
1
  import { DecodedDescription } from '../types/xccdf';
2
2
  export declare function convertEncodedXmlIntoJson(encodedXml: string): any;
3
+ export declare function convertJsonIntoXML(data: any): string;
3
4
  export declare function removeXMLSpecialCharacters(str: string): string;
4
5
  export declare function severityStringToImpact(string: string, id: string): number;
5
6
  export declare function impactNumberToSeverityString(impact: number): string;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertEncodedHTMLIntoJson = exports.impactNumberToSeverityString = exports.severityStringToImpact = exports.removeXMLSpecialCharacters = exports.convertEncodedXmlIntoJson = void 0;
3
+ exports.convertEncodedHTMLIntoJson = exports.impactNumberToSeverityString = exports.severityStringToImpact = exports.removeXMLSpecialCharacters = exports.convertJsonIntoXML = exports.convertEncodedXmlIntoJson = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fast_xml_parser_1 = tslib_1.__importDefault(require("fast-xml-parser"));
6
+ const jstoxml_1 = require("jstoxml");
6
7
  const htmlparser = tslib_1.__importStar(require("htmlparser2"));
7
8
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
8
9
  const he_1 = tslib_1.__importDefault(require("he"));
@@ -11,10 +12,15 @@ function convertEncodedXmlIntoJson(encodedXml) {
11
12
  ignoreAttributes: false,
12
13
  ignoreNameSpace: true,
13
14
  attributeNamePrefix: '@_',
15
+ stopNodes: ['div', 'p'],
14
16
  arrayMode: true
15
17
  });
16
18
  }
17
19
  exports.convertEncodedXmlIntoJson = convertEncodedXmlIntoJson;
20
+ function convertJsonIntoXML(data) {
21
+ return (0, jstoxml_1.toXML)(data);
22
+ }
23
+ exports.convertJsonIntoXML = convertJsonIntoXML;
18
24
  function removeXMLSpecialCharacters(str) {
19
25
  return he_1.default.decode(str);
20
26
  }