Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0355520
work in progress
georgedias Mar 1, 2024
ee70c3e
Completed filtered html report
georgedias Mar 1, 2024
11933bf
SonarCloud fix
georgedias Mar 1, 2024
15fcf8c
Merge branch 'master' into htmlFilteredReports
georgedias Mar 1, 2024
1716018
Removed copy package file
georgedias Mar 1, 2024
4f3d77f
Merge branch 'htmlFilteredReports' of github.com:mitre/heimdall2 into…
georgedias Mar 1, 2024
ebb6630
remove ssl certs from pr
em-c-rod Mar 4, 2024
ee2d83c
Revert "remove ssl certs from pr"
em-c-rod Mar 4, 2024
fb5cae2
try removing the certs again because the test may have errored for a …
em-c-rod Mar 4, 2024
ad7e902
reset yarn.lock to what master has and set the package.json setting b…
em-c-rod Mar 4, 2024
6fcd9f7
Merge branch 'master' into htmlFilteredReports
aaronlippold Mar 10, 2024
6d0d602
Added capability to filter reports on status and severity
georgedias Mar 14, 2024
c9da6b9
Sonar cloud fixes
georgedias Mar 14, 2024
16debd8
Update apps/frontend/src/components/global/ExportHTMLModal.vue
em-c-rod Mar 14, 2024
c685143
Update apps/frontend/src/components/global/ExportHTMLModal.vue
em-c-rod Mar 14, 2024
2eb1c5f
Update apps/frontend/src/components/global/ExportHTMLModal.vue
em-c-rod Mar 14, 2024
27d54f7
linting
em-c-rod Mar 14, 2024
ef73c42
Only display files that have selected controls
georgedias Mar 15, 2024
942b798
Merge branch 'htmlFilteredReports' of github.com:mitre/heimdall2 into…
georgedias Mar 15, 2024
9876542
Only display files that have selected controls
georgedias Mar 15, 2024
22455aa
Merge branch 'master' into htmlFilteredReports
georgedias Mar 15, 2024
a490685
Added wait cursor while loading files and generating HTML report
georgedias Mar 16, 2024
bccfbbc
Merge branch 'master' into htmlFilteredReports
em-c-rod Mar 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions apps/frontend/src/components/global/ExportHTMLModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,60 @@ export default class ExportHTMLModal extends Vue {
}

const files = [];
const filteredOn = this.filter.status;

for (const fileId of this.filter.fromFile) {
const file = InspecDataModule.allEvaluationFiles.find(
(f) => f.uniqueId === fileId
);

if (file) {
const data = file.evaluation;

/**
* NOTE: The filterControls array is used to specify which
* controls are selected.
* If we use the approach of filtering the content from the data object
* (e.g.
* data.data.profiles[0].controls =
* data.data.profiles[0].controls.filter((control) => {
* if (filteredControls.includes(control.id)) {
* return filteredControls.includes(control.id);
* }
* });
* )
* the contextualize object does not get updated and the results
* in data_store get out of sync, there is when utilizing the
* ".contains" it returns ann results where the file.evaluations
* returns the filtered controls.
*/
let filteredControls: string[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the way that this is implemented will not satisfy the issue where it was stated that we should be able to handle any of the filters that the user specifies. this will only filter on pass/fail/whatever.

const controls = FilteredDataModule.controls({

use this example for how to get all the filter-passing controls. it should also mean that we don't need basically all of what're currently lines 122-123 and 150-164 since it'll just be a simple assignment directly onto 'filteredControls' (which can also then be made const).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely unequivocally disagree that the implementations does not satisfy the requirements. It works on all possible filtered permutations, did you even tried, apparently not if you're making this statement.
"the way that this is implemented will not satisfy the issue where it was stated that we should be able to handle any of the filters that the user specifies. this will only filter on pass/fail/whatever."

Regarding the second opinion, the code that is being referenced (from the ExportCaat.vue) will not work. If you take a look at the reverse-html-mapper.ts it uses the file.data, which is the file.evaluation being set in ExportHTMLModule.vue and you are comparing to this code in the ExportCaat,vue const data = file?.evaluation ?? ''; now how does that filters the proper evaluations? it doesn't. The code on both are accomplishing different tasks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

image

Here I've filtered it down to a single control using the nist filters. The html export does not only include that single control. Consequently, it does not meet the requirement of the original ticket according to my reading of it. Like I said elsewhere, we should get @em-c-rod or @ejaronne's opinions on which of our interpretations is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w/r to your second paragraph, I'm only talking about extracting out the set of controls that pass the filtering. You can use the store to get that set I'm hoping.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a use case, but the ask for this is just to be able to show only the failed controls (aka filter on status). If this becomes an additional ask, we can make another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think it is relevant to consider severity filters here. Looking at severity filters as well was not explicitly the ask, but seems like it is paired in the same use case.

if (filteredOn!.length > 0) {
data.contains.map((profile) => {
profile.contains.map((result) => {
if (filteredOn?.includes(result.root.hdf.status)) {
filteredControls.push(result.data.id);
}
});
});
} else {
data.contains.map((profile) => {
profile.contains.map((result) => {
filteredControls.push(result.data.id);
});
});
}

const fileName = file.filename;
const fileID = file.uniqueId;
files.push({data, fileName, fileID});
files.push({data, fileName, fileID, filteredControls});
}
}

// Generate and export HTML file
const body = await new FromHDFToHTMLMapper(files, this.exportType).toHTML(
'/static/export/'
);

saveAs(
new Blob([s2ab(body)], {type: 'application/octet-stream'}),
`${this.exportType}_Report_${new Date().toString()}.html`.replace(
Expand Down
33 changes: 33 additions & 0 deletions certs/ssl_certificate.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-----BEGIN CERTIFICATE-----
MIIFozCCA4ugAwIBAgIUNg89YEYG6UyEAaGy+SK1LBb8zvIwDQYJKoZIhvcNAQEL
BQAwYTELMAkGA1UEBhMCVVMxEzARBgNVBAgMClNlbGZTaWduZWQxEzARBgNVBAcM
ClNlbGZTaWduZWQxEzARBgNVBAoMClNlbGZTaWduZWQxEzARBgNVBAsMClNlbGZT
aWduZWQwHhcNMjMxMTA1MjE1NTU3WhcNMjMxMTEyMjE1NTU3WjBhMQswCQYDVQQG
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fzRs/kmjGSWW7MwLcUnET7HNKrGjg/aIx9
VgwdWo8SVhDgPdlw5VIJvdG9N5vtICs7erFxryehgwjPhDhcgbLIhBUgOl2XCec/
Zi/6CgYw9ds1t79/oO720YHGzkQi5U5s8T8kyyOOZHFnqQotVdO/YapxRwYC26b4
KV8PBdC2/tlgW04xiJ9cmAhNr1GcRn4fr+0Y+HBDNIEXoE4c8DEGUHweJSMh3ET6
doWHEPomN5Sg//G0Byh3pLsgXxJSw1vcueyBY5HOnWR5Cpj/DRaKWY1D+xLN3P+l
Rq+1qVTCAOq/gdkgABjJnO4niOb2N80/RM4j8Yr2dxLVMLSUIX2EqbZ39PmmIN69
uHqHhvmoGK3yBToQeul3aq2oNwG921GlLSkwOrmtfDtsZGXlzyKgNkO1Aa5yVAWm
DFnt0bQp47k5smBWm7M5XTboZUq262jXRWz6EVXRl3GtdBFgjXRYTwoMcCCY1ACZ
fNNsCONBjudfZhuNxne2e5mJcA1EhgOOR2YyZLwQ1nYQXBfG6XrJqOUPwAySdPti
dWUqsW3n8L4RgxL0k8F7hGRYrQL17B7Uli70ruBxn9eQpY15T1bwFCYNSJubG5h/
DZ38BAkEmQ==
-----END CERTIFICATE-----
52 changes: 52 additions & 0 deletions certs/ssl_certificate_key.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCb6dwj2/6BrEt+
THmvJPNT9qRnU/al3M6HjgwAmM3kbkhYeR2+xrUF2vf0h9HRnKBrlHrdHqeq3oX5
W0uLmryLsrx/mDYBXny/bYxcfoAekBQCOac8PwkdHTREGHm1Z2c4fUZ0s6NnIexN
UHjhUg02qlYIDjYmLxq0EjxP/PNwIyrobC6vwnkdtC7s5EO6xyoU26YzXKeTkEVH
y/7yBRlDViZIIJBuxcOLk6ytnmxT4RAXt3Kt5stGp26Kn6MelGoTfzu3DlgB7lZh
jM8gzrrC61hzfYOH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Z/o45ZdsdZWcV
BDAfll03ognSFai8lfEXJsj8QoSPk9UCa0B/to3b5sVuhPSJUdD2gh7mEN2Gyv5r
4FliEBTqbxjRPTW2QzGl9aW1mL6SV2sUI3/0vNLBDo5zPofgc8x0SmGxJNDK+jqj
P1G2Gm1GPPG3sNgPLddPW/JOzc/wltu2WUnyqUJHqALJhIQJOzMtMCSzmKNjyWKl
CwTH2GvSQMLQlJKRg83cfq75Qf5m5lhCrgogB4WNBy/72BFsBHDXrA70S43GCGLp
Bmn3b5m3viVMxikNHgWBT5VWM+Mf5NG6GCnTTQOQGDcFWnEEmEnoUVCsDhhUQ190
dbMCggEAem5jqtMgTRitvqRhvGVZ+dbuQDtJ5oj/bUBWoJylKOQRKgm1SmkRj+tl
z+oYcLuOBFSD0RhlGrGwPF7KOpc5Hs8oNIHs9gsF0Z1KQgK767ll0dQ52WuetbtW
+GPBdIgSLFJRQfkjtsKCQvE2bOWitvOtGiuVFf9bLRGH7Clg8cHc58lakFruKm44
1ZmWSFplES7se6EcqvFHGzsHblIFd8FfCIvrhRGbf2GTOprwA655SyiWLXLf5g2M
ykaxCOUx+G7jCYtkGApY0xgEmPPUWja+tRPnkp26ikN2IQaJWdPbzkYB+rXQaTG6
SfixdHDoNGiIl7/gdJjaWXE9H6il0Q==
-----END PRIVATE KEY-----
4 changes: 2 additions & 2 deletions libs/hdf-converters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"files": [
"lib"
],
"main": "src/index.ts",
"main": "lib/index.js",
"publishConfig": {
"main": "lib/index.js"
},
Expand Down Expand Up @@ -75,4 +75,4 @@
"^.+\\.ts$": "ts-jest"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ type InputData = {
data: ContextualizedEvaluation | string;
fileName: string;
fileID: string;
filteredControls: string[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this optional? i don't think we expose filtered stuff in the saf cli so it'd be annoying to have to modify it to accept this new parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no problems making this optional, but I don't think this is used by the SAF CLI! Well at least, I was not under that impression.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mitre/saf#1689

work has stalled but the PR exists

};

type ProcessedData = {
data: ContextualizedEvaluation;
fileName: string;
fileID: string;
filteredControls: string[];
};

// All selectable export types for an HTML export
Expand Down Expand Up @@ -174,7 +176,12 @@ export class FromHDFToHTMLMapper {
}

this.addFiledata(
{data: file.data, fileName: file.fileName, fileID: file.fileID},
{
data: file.data,
fileName: file.fileName,
fileID: file.fileID,
filteredControls: file.filteredControls
},
exportType
);
}
Expand All @@ -201,7 +208,11 @@ export class FromHDFToHTMLMapper {
const allResultLevels: ContextualizedControl[] = [];
file.data.contains.map((profile) => {
profile.contains.map((result) => {
allResultLevels.push(result);
file.filteredControls.forEach((element) => {
if (element === result.data.id) {
allResultLevels.push(result);
}
});
});
});

Expand Down Expand Up @@ -310,7 +321,7 @@ export class FromHDFToHTMLMapper {
};

// Calculate & set compliance level and color from result statuses
// Set default complaince level and color
// Set default compliance level and color
this.outputData.compliance.level = '0.00%';
this.outputData.compliance.color = 'low';

Expand All @@ -324,7 +335,9 @@ export class FromHDFToHTMLMapper {
100
);
// Set compliance level
this.outputData.compliance.level = complianceLevel;
this.outputData.compliance.level = complianceLevel.includes('NaN')
? '0.00%'
: complianceLevel;
// Determine color of compliance level
// High compliance is green, medium is yellow, low is red
this.outputData.compliance.color = translateCompliance(complianceLevel);
Expand Down Expand Up @@ -495,7 +508,7 @@ export class FromHDFToHTMLMapper {
return text;
}

// Prompt HTML generation from data pulled from file during constructor intialization
// Prompt HTML generation from data pulled from file during constructor initialization
// Requires path to prompt location of needed files relative to function call location
async toHTML(path: string): Promise<string> {
// Pull export template + styles and create outputData object containing data to fill template with
Expand Down
6 changes: 4 additions & 2 deletions libs/inspecjs/src/compat_wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ export interface HDFControl {
*/
parsedNistRevision: NistRevision | null;

/** Get the start time of this control's run, as determiend by the time of the first test.
/**
* Get the start time of this control's run, as determined by the time of the first test.
* If no tests were run, (it is a profile-json or has no tests) returns undefined
*/
start_time?: string;

/** Get the results of this control's control segments as a list.
/**
* Get the results of this control's control segments as a list.
* If no tests were run, (this is a profile-json) returns undefined.
* Can be empty in the rare case that no control segments exist/were run.
*/
Expand Down
4 changes: 2 additions & 2 deletions libs/inspecjs/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Provides general utilities for articulating associations beteen evaluations, profiles, and controls.
* Provides general utilities for articulating associations between evaluations, profiles, and controls.
* Especially useful for handling overlay/wrapper profiles.
*/

Expand Down Expand Up @@ -206,7 +206,7 @@ export function contextualizeEvaluation(

// Link each contextualized control
for (const cc of allControls) {
// Behaviour changes based on if we have well-formed or malformed profile dependency
// Behavior changes based on if we have well-formed or malformed profile dependency
if (cc.sourcedFrom.extendsFrom.length || cc.sourcedFrom.extendedBy.length) {
// Our profile is a baseline! No need to continue - children will make connections for us
// If we aren't extended from something we just drop. Our children will make connections for us
Expand Down
Loading