@mitre/inspec-objects 0.0.6 → 0.0.7

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,10 +1,15 @@
1
1
  import { ExecJSON } from "inspecjs";
2
+ export declare function objectifyDescriptions(descs: ExecJSON.ControlDescription[] | {
3
+ [key: string]: string | undefined;
4
+ } | null | undefined): {
5
+ [key: string]: string | undefined;
6
+ } | null | undefined;
2
7
  export default class Control {
3
8
  id?: string | null;
4
9
  title?: string | null;
5
10
  code?: string | null;
6
11
  desc?: string | null;
7
- descs?: ExecJSON.ControlDescription[] | {
12
+ descs?: {
8
13
  [key: string]: string | undefined;
9
14
  } | null;
10
15
  impact?: number;
@@ -1,9 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objectifyDescriptions = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
6
  const flat_1 = require("flat");
6
7
  const global_1 = require("../utilities/global");
8
+ function objectifyDescriptions(descs) {
9
+ if (Array.isArray(descs)) {
10
+ const descriptions = {};
11
+ descs.forEach((description) => {
12
+ descriptions[description.label] = description.data;
13
+ });
14
+ return descriptions;
15
+ }
16
+ return descs;
17
+ }
18
+ exports.objectifyDescriptions = objectifyDescriptions;
7
19
  class Control {
8
20
  constructor(data) {
9
21
  this.tags = {};
@@ -4,7 +4,7 @@ exports.processJSON = exports.processExecJSON = exports.processProfileJSON = exp
4
4
  const tslib_1 = require("tslib");
5
5
  const inspecjs_1 = require("inspecjs");
6
6
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
- const control_1 = tslib_1.__importDefault(require("../objects/control"));
7
+ const control_1 = tslib_1.__importStar(require("../objects/control"));
8
8
  const profile_1 = tslib_1.__importDefault(require("../objects/profile"));
9
9
  function processEvaluation(evaluationInput) {
10
10
  const topLevelProfile = evaluationInput.contains[0];
@@ -25,7 +25,7 @@ function processEvaluation(evaluationInput) {
25
25
  title: control.data.title,
26
26
  impact: control.data.impact,
27
27
  desc: control.data.desc,
28
- descs: control.hdf.wraps.descriptions,
28
+ descs: (0, control_1.objectifyDescriptions)(control.hdf.wraps.descriptions),
29
29
  tags: control.hdf.wraps.tags,
30
30
  }));
31
31
  });
@@ -52,7 +52,7 @@ function processProfileJSON(profileInput) {
52
52
  impact: control.impact,
53
53
  code: control.code,
54
54
  tags: control.tags,
55
- descs: control.descriptions,
55
+ descs: (0, control_1.objectifyDescriptions)(control.descriptions),
56
56
  }));
57
57
  });
58
58
  return profile;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitre/inspec-objects",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Typescript objects for normalizing between InSpec profiles and XCCDF benchmarks",
5
5
  "main": "lib/index.js",
6
6
  "publishConfig": {