Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display and filter user defined guidance mappings #6083

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
69 changes: 69 additions & 0 deletions CalvinREADME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Features:

1. Settings gear in results table that now contains all sliders affecting results table view options, and additionally contains options for uploading, displaying, and removing user guidance mappings from cci's or 800-53's to other tags. (Uploadable formats: csv or json)
2. Basic ability to filter results based on guidance mappings (currently only works if mapping is uploaded and enabled prior to upload of results)

## How basic functionality (displaying guidance mappings) works:

### ToggleDiv.vue
The primary component added is ToggleDiv.vue (heimdall2\apps\frontend\src\components\global\tags\ToggleDiv.vue), which is added into the results table in ControlTable.vue. Additionally, many of the sliders that affected the view options for the results table and their corresponding methods have been moved into ToggleDiv.vue.

The template for ToggleDiv.vue consists of a settings gear (mdi-cog) button that when clicked opens a modal (v-dialog) box with two tabs. The first tab contains all of the sliders that were previously on the top row of the results table. The second tab contains sliders with the ability to toggle on and off the visibility of cci chips and 800-53 chips in the results table, in addition to instructions for how to upload guidance mappings from cci's or 800-53's as a CSV or a JSON in an accordion menu. If a mapping is uploaded, another slider will apear on the tab to toggle on and off that mapping.

### saved_mappings.ts

Upon uploading a properly formatted csv or json file with a user guidance mapping, the resulting mapping is stored as a dictionary in saved_mappings.ts (heimdall2\apps\frontend\src\store\saved_mappings.ts). If, for example, the user submits a mapping with the name "XYZ", then a dictionary consisting of the mappings would be stored in the mappings object as key: CCI->XYZ value: thedictionary or key: 800-53->XYZ value: thedictionary. The dictionary itself will have keys being CCI's or 800-53's and values being arrays of what tags those keys map to.

In total then, if a mapping was uploaded from CCIs to user guidance XYZ, then you could access a chosen CCI's mapped tags as follows:
mappings[CCI->XYZ][chosenCCI] = [XYZTag1, XYZtag2, ...]

Additionally, in saved_mappings.ts, when a mapping is uploaded a dictionary mapping all of the mapping's tags to their descriptions is saved in the descriptions variable, in a similar process.
descriptions[CCI->XYZ][XYZTag1] = "Description for XYZTag1".

The process of adding and removing files in the togglediv automatically removes both of these dictionaries.

### selected_tags.ts

selected_tags.ts (heimdall2\apps\frontend\src\store\selected_tags.ts) is another element of the store, that contains information about which sliders appear in the modal, and which ones are selected. Note that the sliders were originally checkboxes, hence the naming scheme. The defaultcheckboxes element contains the two default sliders that appear, being cci and 800-53 for enabling and disabling their chips on the modal. All additional sliders are calculated based on the mappings stored in saved_mappings.ts and combined with the default sliders in the combinedCheckboxes getter. Note that even though the mapping has an id of CCI->XYZ or 800-53->XYZ, the label for the slider will simply be XYZ. Additionally, the list of sliders that that are checked at any given time is the checkedValues variable, which can be accessed via getter.

### Additional Changes:

-Changed the name of the "800-53 Controls & CCIs" column in the results table to "Guidance Mappings"
-In ControlRowHeader.vue, set v-chips for the mapped tags to appear if the slider is enabled by accessing the selected_mappings


## How filtering works:

Note: Currently, at this time, filtering only works if a mapping is uploaded and the slider for it is enabled, and then a profile or evaluation is uploaded. I will explain why and how this can be changed. Additionally, it is not necessarily the most efficient process at this time.

### inspecjs / context.ts

In context.ts, I added an interface called userGuidance<mappings>, which requires that an object extending that interfaces contains a property called "has", and "has" is set to mappings. I then made it so that both contextualizedEvaluation and contextualizedProfile extend this interface, being userGuidance<string[]>, thus guaranteeing each "has:" an array of strings. I then changed the contextualizeProfile() and contextualizeEvaluation() methods to include an additional argument, being an array of strings, which the has parameter is then set to. This did necessitate some changes be made to all uses of contextualizeProfile() and contextualizeEvaluation() throughout the program, typically passing in an empty array as this parameter. However, in report_intake.ts, that was not the case.

### report_intake.ts

In report_intake.ts, I simply made it so that when an inspec file is parsed as a profile or an evaluation, that it gets the list of enabled sliders in the togglediv, and passes the array of enabled sliders into contextualizeProfile() and contextualizeEvaluation() to ensure that each profile created is set with the list of enabled checkboxes as it's "has" parameter. NOTE: At this time, this is the only place where the "has" parameter is set. As a result, this is why filtering only works whenever a mapping is loaded and enabled prior to the upload of an inspec file.

### search.ts

Added another option to be searched for when the string typed into the search bar is parsed, being "guidance". In the event that "guidance" is parsed as the option in the string, then it verifies that the search is correctly formatted (guidance:mappingName:mappingID), and additionally verifies that mappingName is enabled in the toggleDiv modal. In the event that these conditions are true, then "mappingName:mappingID" is added to the mappingGuidanceFilter: string[] field of the ISearchState, a new variable I added to it.

### results.vue

As a result of adding the field discussed previously to search.ts, I had to modify get all_filter() and get treemap_full_filter() in results.vue to include mappingSearchTerm: SearchModule.mappingGuidanceFilter. mappingSearchTerm is a field I defined in data_filters.ts, the final.file necessary for the filtering process.

### data_filters.ts

In the Filter interface in data_filters, I added another conditional parameter "mappingSearchTerm?: string[]". This parameter can be set to hold guidance mappings to search for as defined in search.ts's "mappingGuidanceFilter", as mappingSearchTerm is set to equal mappingGuidanceFilter in results.vue. As noted previously, the elements of mappingSearchTerm will be of the form "XYZ:tagID", where XYZ is the name of a guidance mapping uploaded by a user, and tagID is an id used in that guidance mapping.

The primary change made to this file deals with the controls() getter, which determines which controls meet the filtering conditions based on the Filter interface's parameters. In this getter, I added an additional check to see that if the mappingSearchTerm is defined, in which case I call the contains_mapping function on each control to determine whether it should be filtered or not. This function effectively searches the saved_mappings for a CCI or 800-53 that maps to the mappingSearchTerm, and then verifies whether or not that CCI or 800-53 is associated with a control. This is very likely not the most efficient way of doing this (could potentially save the CCI's or 800-53's that map to the mappingSearchTerm somewhere rather than looping through for each control)


### Additional changes:

Edited SearchHelpModal.vue to include instructions for how to filter by guidance mappings
Edited all instances of contextualizeProfile and contextualizeEvaluation including in:
(fileparse.ts, reverse-asff-mapper.ts, transformers.ts, global.ts, context.spec.ts)


#### Feel free to contact me at [email protected] or 619-922-2486 if you have questions
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,4 @@ pre {
.right {
margin-left: -1px;
}
</style>
</style>
Loading
Loading