Skip to content

Commit

Permalink
feat(console): assessment results generation (#744)
Browse files Browse the repository at this point in the history
* feat(console): assessment-results updates

* feat(console): assessment-results tables

* feat(console): assessment-results detail

* feat(console): added observation details, refactor

* feat(console): summary, table keys

* feat(console): validations detail

* fix: minor cleanups

* feat(console): add validation detail, reorg, tests

* fix: yaml dep

* fix: testdata

* feat(console): add support for multiple input files

* fix: test updates

* fix: doc updates

* fix: updated organization, small bugs

* fix: assessment updates

* feat(console): initial work on adding validate workflow

* feat(console): validate model

* feat(console): update validate model+validation workflow

* fix: minor cleanups

* feat(console): assessment results with compare

* feat(console): compare updates, tests

* fix: testdata

* fix: file save workflow

* fix: duplicate observations during compare

* fix: updated tests for consistency

* feat(console): view updates, small fixes

* feat(console): event cleanup, tests

* feat(console): validation execution

* feat(console): docs

* fix: assessment testdata update

* feat(console): event cleanup, tests, docs

* fix: testdata

* docs: cli docs

* docs: cleanup

* fix: handle race cond?

* fix: small mods in component

* fix: golangci-lint errs

* fix: styles consts

* fix: detail scale issues

* fix: spacing, testdata

* docs: clarity around write
  • Loading branch information
meganwolf0 authored Oct 22, 2024
1 parent fedb0c9 commit 6cb5933
Show file tree
Hide file tree
Showing 57 changed files with 3,209 additions and 865 deletions.
45 changes: 45 additions & 0 deletions demo/console/assessment-results-compare.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Output images/assessment-results-console-compare.gif

Require lula
Set FontSize 14
Set Width 1850
Set Height 925
Set Framerate 24
Set Padding 5

Hide
Type "lula console -f ./src/test/unit/common/oscal/valid-assessment-results-multi.yaml" Enter
Sleep 1s
Tab
Sleep 500ms
Show

# Select comparison result
Sleep 1s
Right
Sleep 500ms
Right
Sleep 500ms
Enter
Sleep 1s
Down
Sleep 500ms
Enter
Sleep 500ms

# Navigate to findings, observations
Right
Sleep 500ms
Right
Sleep 500ms
Down
Sleep 500ms
Up
Sleep 500ms
Left
Sleep 1s

# Show findings comparison detail
Type "d"
Sleep 2s

49 changes: 49 additions & 0 deletions demo/console/assessment-results.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Output images/assessment-results-console.gif

Require lula
Set FontSize 14
Set Width 1850
Set Height 925
Set Framerate 24
Set Padding 5

Hide
Type "lula console -f ./src/test/unit/common/oscal/valid-assessment-results-multi.yaml" Enter
Sleep 1s
Tab
Sleep 500ms
Show

# Show results picker
Sleep 1s
Right
Sleep 500ms
Enter
Sleep 1s
Down
Sleep 500ms
Enter
Sleep 500ms

# Navigate to findings, filter
Right
Sleep 500ms
Right
Sleep 500ms
Down
Sleep 500ms
Up
Sleep 500ms
Type "/"
Sleep 500ms
Type "ID-1"
Sleep 500ms
Enter
Sleep 1s

# Navigate to observations
Right
Sleep 500ms
Type "d"
Sleep 2s

41 changes: 41 additions & 0 deletions demo/console/component-validate.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Output images/component-defn-console-validate.gif

Require lula
Set FontSize 14
Set Width 1850
Set Height 925
Set Framerate 24
Set Padding 5

Hide
Type "lula console -f ./src/test/unit/common/oscal/valid-multi-component-validations.yaml -a tmp.yaml" Enter
Sleep 1s
Show

# Select the framework
Sleep 500ms
Right
Sleep 500ms
Right
Sleep 500ms
Enter
Sleep 500ms
Down
Sleep 500ms
Down
Sleep 500ms
Enter
Sleep 1s

# Run Validate
Ctrl+v
Sleep 2s
Enter
Sleep 6s

Hide
Ctrl+c
Sleep 50ms
Enter
Sleep 50ms
Type "rm tmp.yaml" Enter
39 changes: 39 additions & 0 deletions demo/console/component-validation-detail.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Output images/component-defn-console-validation-detail.gif

Require lula
Set FontSize 14
Set Width 1850
Set Height 925
Set Framerate 24
Set Padding 5

Hide
Type "lula console -f ./src/test/unit/common/oscal/valid-multi-component-validations.yaml" Enter
Sleep 1s
Show

# Navigate to a control and select
Right
Sleep 500ms
Right
Sleep 500ms
Right
Sleep 500ms
Enter
Sleep 1s
Right
Sleep 500ms
Right
Sleep 500ms
Right
Sleep 500ms
Type "d"
Sleep 1s
Down
Sleep 500ms
Down
Sleep 1s
Up
Sleep 500ms
Up
Sleep 1s
10 changes: 7 additions & 3 deletions docs/cli-commands/lula_console.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ To view multiple OSCAL models in the Console:
To specify an output file to save any changes made to the component definition:
lula console -f /path/to/oscal-component.yaml -c /path/to/output.yaml
To specify an output file to save component definition assessment results:
lula console -f /path/to/oscal-component.yaml -a /path/to/output.yaml
```

### Options

```
-c, --component-output string the path to the component definition output file
-h, --help help for console
-f, --input-files strings the path to the target OSCAL models, comma separated
-a, --assessment-output string the path to the assessment results output file
-c, --component-output string the path to the component definition output file
-h, --help help for console
-f, --input-files strings the path to the target OSCAL models, comma separated
```

### Options inherited from parent commands
Expand Down
49 changes: 47 additions & 2 deletions docs/console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,52 @@

The Lula Console is a text-based terminal user interface that allows users to interact with the OSCAL documents in a more intuitive and visual way.

See the sub-pages for more information on interacting with OSCAL models in the Console.
Currently, only the **Component Definition** and **Assessment Results** models are supported in the Console.

* See the sub-pages for more information on interacting with each specific OSCAL model in the Console.

>[!NOTE]
>The Console is currently in development and is subject to change.
>The Console is currently in development and views are subject to change.
## Usage

To open the Console with particular OSCAL models:
```shell
lula console -f /path/to/oscal-component.yaml,/path/to/oscal-component-2.yaml,/path/to/assessment-results.yaml
```
The `-f` (or `--input-files`) flag can be used to specify multiple OSCAL model file paths to be loaded into the Console.

### Writing to Output

#### Component Definition

The Console supports writing updated `remarks` and `description` fields to the `component-definition` model.

To include an output file to save any changes made to the component definition, use the `--component-output` or `-c`flag:
```shell
lula console -f /path/to/oscal-component.yaml -c /path/to/output.yaml
```

If no output file is specified and a single component definition is passed, the provided component definition will be overwritten. If multiple component definitions are passed and no output file is specified, the Console will default to `component.yaml` in the current working directory.

#### Assessment Results

The Console supports writing assessment results that are generated from the Component Definition `validate` execution.

To specify an output file to write assessment results, include `--assessment-output` or `-a`. If you provide no `-a`, but include a single assessment results file as inputs (via `--input-files`/`-f`), that will be used as the output file. If no assessment results file is provided (or multiple are provided), the Console will default to `assessment-results.yaml` in the current working directory.

Example of running console including the optionality to write assessment results to the provided file:
```shell
lula console -f /path/to/oscal-component.yaml -a /path/to/output.yaml
```

## Keys

The Console responds to the following keys for navigation and interaction (each sub-model has additional key response, see respective help views for more information):

| Key | Description |
|-----|-------------|
| `?` | Toggle help |
| `ctrl+c` | Quit |
| `tab` | Tab right between models |
| `shift+tab` | Tab left between models |
42 changes: 42 additions & 0 deletions docs/console/assessment-results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Assessment Results

The Assessment Result view provides the Console user with an interactive experience of the OSCAL Assessment Results model. The view supports navigation between the different results contained in the Assessment Results model, as well as the ability to view Findings and Observations in tabular and filterable formats. Additional `detail` views are available to view the raw OSCAL model data for selected Findings/Observations.

## Usage

The Assessment Results model supports the following views:
* [Result View](./assessment-results.md#result-view)
* [Result Comparison View](./assessment-results.md#result-comparison-view)

## Keys

The Assessment Results model responds to the following keys for navigation and interaction (some widgets have additional key response, see respective help views for more information):

| Key | Description |
|-----|-------------|
| `?` | Toggle help |
| `ctrl+c` | Quit |
| `tab` | Tab right between models |
| `shift+tab` | Tab left between models |
| ``/`h` | Navigate left across widgets in model|
| ``/`l` | Navigate right across widgets model |
| ``/`k` | Move up in table OR scroll up in panel |
| ``/`j` | Move down in table OR scroll up in panel |
| `/` | Filter table |
| `` | Select available item |
| `d` | Detail available item (findings and observations) |
| `esc` | Close OR esc filtering |

During console viewing, the top-right corner will display the help keys availble in the context of the selected widget. When an overlay is open, the help keys will be displayed in the overlay.

## Views

### Result View

<img align="right" src="../../images/assessment-results-console.gif" alt="assessment results console" style="width:100%; height:auto;">
<div style="clear: both;"></div>

### Result Comparison View

<img align="right" src="../../images/assessment-results-console-compare.gif" alt="assessment results console comparison" style="width:100%; height:auto;">
<div style="clear: both;"></div>
48 changes: 30 additions & 18 deletions docs/console/component-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@ The Component Definition view currently allows for a read and limited write expe

## Usage

To view an OSCAL Component Definition model in the Console:
```shell
lula console -f /path/to/oscal-component.yaml
```
The `oscal-component.yaml` will need to be a valid OSCAL model - to use with the Component Definition view, it must contain the `component-definition` top level key.

To include an output file to save any changes made to the component definition, use the `--component-output` or `-c`flag:
```shell
lula console -f /path/to/oscal-component.yaml -c /path/to/output.yaml
```

> [!Note]
> Several component definition models can be passed into the console, via `-f` in a comma-separated list. For multiple component definitions, the output file will default to `component.yaml` unless specified.
The Component Definition model supports the following views:
* [Read-Only Navigation](./component-definition.md#read-only-navigation)
* [Editing Remarks and Description](./component-definition.md#editing-remarks-and-description)
* [Validation Detail](./component-definition.md#validation-detail)

## Keys

Expand All @@ -28,13 +19,14 @@ The Component Definition model responds to the following keys for navigation and
| `ctrl+c` | Quit |
| `tab` | Tab right between models |
| `shift+tab` | Tab left between models |
| `/h` | Navigate left in model|
| `/l` | Navigate right in model |
| `/k` | Move up in list OR scroll up in panel |
| `/j` | Move down in list OR scroll up in panel |
| ``/`h` | Navigate left across widgets model|
| ``/`l` | Navigate right across widgets model |
| ``/`k` | Move up in list OR scroll up in panel |
| ``/`j` | Move down in list OR scroll up in panel |
| `/` | Filter list |
| `` | Select item |
| `e` | Edit available fields (remarks and description) |
| `d` | Detail available fields (validations) |
| `ctrl+s` | Save changes (Note: this may overwrite the original file if an output file unspecified) |
| `esc` | Cancel |

Expand All @@ -44,8 +36,28 @@ During console viewing, the top-right corner will display the help keys availble

### Read-Only Navigation

The model can be sorted by Component, Framework, and Control. Additional data/features provided by the Component Definition OSCAL Model are not currently supported for viewing in the Console.

<img align="right" src="../../images/component-defn-console-read.gif" alt="component definition console read" style="width:100%; height:auto;">
<div style="clear: both;"></div>

### Editing Remarks and Description

<img align="right" src="../../images/component-defn-console-edit.gif" alt="component definition console edit" style="width:100%; height:auto;">
Limited editing of the remarks and description is supported. Once changes are made, to be persisted back to the file, the data will need to be saved via the `ctrl+s` key.

<img align="right" src="../../images/component-defn-console-edit.gif" alt="component definition console edit" style="width:100%; height:auto;"><br>
<div style="clear: both;"></div>

### Validation Detail

The Validation Detail is a view that displays a somewhat curated version of the Lula Validation. It is intended to be a quick view of the validation, and is not a one-to-one representation.

<img align="right" src="../../images/component-defn-console-validation-detail.gif" alt="component definition console validation detail" style="width:100%; height:auto;">
<div style="clear: both;"></div>

### Validation Execution

A validation can be executed using the `ctrl+v` keycommand. This will run the validation ONLY for the currently active framework. This also will automatically run executable validations. Future work will be added to allow for more granular control over validation execution in the console.

<img align="right" src="../../images/component-defn-console-validate.gif" alt="component definition console validation detail" style="width:100%; height:auto;">
<div style="clear: both;"></div>
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/defenseunicorns/go-oscal v0.6.0
github.com/defenseunicorns/pkg/kubernetes v0.3.0
github.com/evertras/bubble-table v0.17.0
github.com/google/go-cmp v0.6.0
github.com/hashicorp/go-version v1.7.0
github.com/kyverno/kyverno-json v0.0.3
Expand Down Expand Up @@ -117,6 +118,7 @@ require (
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
Expand Down
Loading

0 comments on commit 6cb5933

Please sign in to comment.