@mitre/inspec-objects 0.0.8 → 0.0.9

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.
@@ -2,4 +2,7 @@ import Profile from '../objects/profile';
2
2
  import { ProfileDiff } from '../types/diff';
3
3
  export declare function removeNewlines(control?: Record<string, unknown>): Record<string, unknown>;
4
4
  export declare function simplifyDiff(diffData: Record<string, unknown>): Record<string, unknown>;
5
- export declare function diffProfile(fromProfile: Profile, toProfile: Profile): ProfileDiff;
5
+ export declare function diffProfile(fromProfile: Profile, toProfile: Profile): {
6
+ simplified: ProfileDiff;
7
+ originalDiff: Record<string, unknown>;
8
+ };
@@ -45,6 +45,11 @@ function diffProfile(fromProfile, toProfile) {
45
45
  removedControlIDs: [],
46
46
  changedControls: {}
47
47
  };
48
+ const originalDiff = {
49
+ addedControlIDs: [],
50
+ removedControlIDs: [],
51
+ changedControls: {}
52
+ };
48
53
  const fromControlIDs = fromProfile.controls.map((control) => control.id).sort();
49
54
  const toControlIDs = toProfile.controls.map((control) => control.id).sort();
50
55
  // Find new controls
@@ -52,9 +57,11 @@ function diffProfile(fromProfile, toProfile) {
52
57
  controlIDDiff === null || controlIDDiff === void 0 ? void 0 : controlIDDiff.forEach((diffValue) => {
53
58
  if (diffValue[0] === '-') {
54
59
  profileDiff.removedControlIDs.push(diffValue[1]);
60
+ originalDiff.removedControlIDs.push(diffValue[1]);
55
61
  }
56
62
  else if (diffValue[0] === '+') {
57
63
  profileDiff.addedControlIDs.push(diffValue[1]);
64
+ originalDiff.addedControlIDs.push(diffValue[1]);
58
65
  }
59
66
  });
60
67
  // Add new controls to changedControls
@@ -62,6 +69,7 @@ function diffProfile(fromProfile, toProfile) {
62
69
  const newControl = toProfile.controls.find((control) => addedControl === control.id);
63
70
  if (newControl) {
64
71
  profileDiff.changedControls[addedControl] = newControl;
72
+ originalDiff.changedControls[addedControl] = newControl;
65
73
  }
66
74
  });
67
75
  // Find changed controls
@@ -71,9 +79,10 @@ function diffProfile(fromProfile, toProfile) {
71
79
  const controlDiff = lodash_1.default.omit((0, json_diff_1.diff)(fromControl, toControl), 'code__deleted');
72
80
  if (controlDiff) {
73
81
  profileDiff.changedControls[toControl.id] = simplifyDiff(controlDiff);
82
+ originalDiff.changedControls[toControl.id] = controlDiff;
74
83
  }
75
84
  }
76
85
  }
77
- return profileDiff;
86
+ return { simplified: profileDiff, originalDiff: originalDiff };
78
87
  }
79
88
  exports.diffProfile = diffProfile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mitre/inspec-objects",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Typescript objects for normalizing between InSpec profiles and XCCDF benchmarks",
5
5
  "main": "lib/index.js",
6
6
  "publishConfig": {