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

feat(deps): add support for OSCAL 1.1.3 as default #837

Merged
merged 4 commits into from
Dec 6, 2024
Merged
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
2 changes: 1 addition & 1 deletion demo/simple/oscal-component-opa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ component-definition:
title: Lula Demo
last-modified: '2022-09-13T12:00:00Z'
version: "20220913"
oscal-version: 1.1.1 # This version should remain one version behind latest version for `lula dev upgrade` demo
oscal-version: 1.1.2 # This version should remain one version behind latest version for `lula dev upgrade` demo
parties:
# Should be consistent across all of the packages, but where is ground truth?
- uuid: C18F4A9F-A402-415B-8D13-B51739D689FF
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"
"time"

oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/internal/tui"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
"github.com/defenseunicorns/lula/src/pkg/message"
Expand Down Expand Up @@ -106,8 +106,8 @@ func ConsoleCommand() *cobra.Command {
return consoleCmd
}

func GetModelsByFiles(inputFiles []string, setOutputFiles map[string]string) (map[string]*oscalTypes_1_1_2.OscalModels, map[string]string, error) {
var models = make(map[string]*oscalTypes_1_1_2.OscalModels)
func GetModelsByFiles(inputFiles []string, setOutputFiles map[string]string) (map[string]*oscalTypes.OscalModels, map[string]string, error) {
var models = make(map[string]*oscalTypes.OscalModels)
var modelFiles = make(map[string]string)

// Get the OSCAL models from the files
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/evaluate/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/defenseunicorns/go-oscal/src/pkg/files"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/cmd/common"
pkgCommon "github.com/defenseunicorns/lula/src/pkg/common"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
Expand Down Expand Up @@ -81,7 +81,7 @@ func EvaluateCommand() *cobra.Command {
return evaluateCmd
}

func EvaluateAssessments(assessmentMap map[string]*oscalTypes_1_1_2.AssessmentResults, target string, summary, machine bool) error {
func EvaluateAssessments(assessmentMap map[string]*oscalTypes.AssessmentResults, target string, summary, machine bool) error {
// Identify the threshold & latest for comparison
resultMap := oscal.FilterResults(assessmentMap)

Expand All @@ -103,7 +103,7 @@ func EvaluateAssessments(assessmentMap map[string]*oscalTypes_1_1_2.AssessmentRe

// Write each file back in the case of modification
for filePath, assessment := range assessmentMap {
model := oscalTypes_1_1_2.OscalCompleteSchema{
model := oscalTypes.OscalCompleteSchema{
AssessmentResults: assessment,
}

Expand Down Expand Up @@ -241,12 +241,12 @@ func evaluateTarget(target oscal.EvalResult, source string, summary, machine boo

// Read many filepaths into a map[filepath]*AssessmentResults
// Placing here until otherwise decided on value elsewhere
func readManyAssessmentResults(fileArray []string) (map[string]*oscalTypes_1_1_2.AssessmentResults, error) {
func readManyAssessmentResults(fileArray []string) (map[string]*oscalTypes.AssessmentResults, error) {
if len(fileArray) == 0 {
return nil, fmt.Errorf("no files provided for evaluation")
}

assessmentMap := make(map[string]*oscalTypes_1_1_2.AssessmentResults)
assessmentMap := make(map[string]*oscalTypes.AssessmentResults)
for _, fileString := range fileArray {
err := files.IsJsonOrYaml(fileString)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/cmd/common"
"github.com/defenseunicorns/lula/src/pkg/common/network"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
Expand Down Expand Up @@ -121,7 +121,7 @@ var generateComponentCmd = &cobra.Command{
message.Fatalf(err, "error creating component - %s\n", err.Error())
}

var model = oscalTypes_1_1_2.OscalModels{
var model = oscalTypes.OscalModels{
ComponentDefinition: comp,
}

Expand Down
6 changes: 3 additions & 3 deletions src/cmd/tools/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"
"path/filepath"

oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/spf13/cobra"

"github.com/defenseunicorns/lula/src/pkg/common"
Expand Down Expand Up @@ -121,7 +121,7 @@ func init() {
toolsCmd.AddCommand(PrintCommand())
}

func PrintResources(assessment *oscalTypes_1_1_2.AssessmentResults, observationUuid, assessmentDir, outputFile string) error {
func PrintResources(assessment *oscalTypes.AssessmentResults, observationUuid, assessmentDir, outputFile string) error {
if assessment == nil {
return fmt.Errorf("assessment is nil")
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func PrintResources(assessment *oscalTypes_1_1_2.AssessmentResults, observationU
return nil
}

func PrintValidation(component *oscalTypes_1_1_2.ComponentDefinition, assessment *oscalTypes_1_1_2.AssessmentResults, observationUuid, outputFile string) error {
func PrintValidation(component *oscalTypes.ComponentDefinition, assessment *oscalTypes.AssessmentResults, observationUuid, outputFile string) error {
if component == nil {
return fmt.Errorf("component definition is nil")
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"path/filepath"

oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/cmd/common"
"github.com/defenseunicorns/lula/src/pkg/common/composition"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
Expand Down Expand Up @@ -98,7 +98,7 @@ func ValidateCommand() *cobra.Command {
return fmt.Errorf("assessment results are nil")
}

var model = oscalTypes_1_1_2.OscalModels{
var model = oscalTypes.OscalModels{
AssessmentResults: assessmentResults,
}

Expand Down
4 changes: 2 additions & 2 deletions src/internal/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/exp/teatest"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
)

func OscalFromPath(t *testing.T, path string) *oscalTypes_1_1_2.OscalCompleteSchema {
func OscalFromPath(t *testing.T, path string) *oscalTypes.OscalCompleteSchema {
t.Helper()
path = filepath.Clean(path)
data, err := os.ReadFile(path)
Expand Down
10 changes: 5 additions & 5 deletions src/internal/tui/assessment_results/assessment-results.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"time"

"github.com/charmbracelet/lipgloss"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/internal/tui/common"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
pkgResult "github.com/defenseunicorns/lula/src/pkg/common/result"
Expand All @@ -26,9 +26,9 @@ var (
type result struct {
Uuid, Title string
Timestamp string
OscalResult *oscalTypes_1_1_2.Result
Findings *[]oscalTypes_1_1_2.Finding
Observations *[]oscalTypes_1_1_2.Observation
OscalResult *oscalTypes.Result
Findings *[]oscalTypes.Finding
Observations *[]oscalTypes.Observation
FindingsRows []table.Row
ObservationsRows []table.Row
FindingsMap map[string]table.Row
Expand All @@ -42,7 +42,7 @@ type summaryData struct {
NumObservationsSatisfied int
}

func GetResults(assessmentResults *oscalTypes_1_1_2.AssessmentResults) []result {
func GetResults(assessmentResults *oscalTypes.AssessmentResults) []result {
results := make([]result, 0)

if assessmentResults != nil {
Expand Down
12 changes: 6 additions & 6 deletions src/internal/tui/assessment_results/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/internal/tui/common"
"github.com/defenseunicorns/lula/src/internal/tui/component"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
Expand Down Expand Up @@ -43,7 +43,7 @@ type Model struct {
help common.HelpModel
keys keys
focus focus
oscalAssessment *oscalTypes_1_1_2.AssessmentResults
oscalAssessment *oscalTypes.AssessmentResults
results []result
resultsPicker common.PickerModel
selectedResult result
Expand All @@ -67,7 +67,7 @@ type ModelOpenMsg struct {
type ModelCloseMsg struct{}
type AssessmentUpdatedMsg struct{}

func NewAssessmentResultsModel(assessmentResults *oscalTypes_1_1_2.AssessmentResults) Model {
func NewAssessmentResultsModel(assessmentResults *oscalTypes.AssessmentResults) Model {
help := common.NewHelpModel(false)
help.OneLine = true
help.ShortHelp = shortHelpNoFocus
Expand Down Expand Up @@ -379,11 +379,11 @@ func (m *Model) Open(height, width int) {
m.updateSizing(height, width)
}

func (m *Model) GetAssessmentResults() *oscalTypes_1_1_2.AssessmentResults {
func (m *Model) GetAssessmentResults() *oscalTypes.AssessmentResults {
return m.oscalAssessment
}

func (m *Model) UpdateWithAssessmentResults(assessmentResults *oscalTypes_1_1_2.AssessmentResults) {
func (m *Model) UpdateWithAssessmentResults(assessmentResults *oscalTypes.AssessmentResults) {
var selectedResult result
m.oscalAssessment = assessmentResults

Expand All @@ -408,7 +408,7 @@ func (m *Model) UpdateWithAssessmentResults(assessmentResults *oscalTypes_1_1_2.
m.currentObservations = selectedResult.ObservationsRows
}

func (m *Model) MergeNewResults(newResults *oscalTypes_1_1_2.AssessmentResults) error {
func (m *Model) MergeNewResults(newResults *oscalTypes.AssessmentResults) error {
if newResults != nil {
if m.oscalAssessment == nil {
m.UpdateWithAssessmentResults(newResults)
Expand Down
12 changes: 6 additions & 6 deletions src/internal/tui/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ import (
"strings"

"github.com/charmbracelet/lipgloss"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/internal/tui/common"
pkgcommon "github.com/defenseunicorns/lula/src/pkg/common"
"github.com/defenseunicorns/lula/src/pkg/common/composition"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
)

type component struct {
OscalComponent *oscalTypes_1_1_2.DefinedComponent
OscalComponent *oscalTypes.DefinedComponent
Uuid, Name, Desc string
Frameworks []framework
}

type framework struct {
OscalFramework *oscalTypes_1_1_2.ControlImplementationSet
OscalFramework *oscalTypes.ControlImplementationSet
Uuid, Name string
Controls []control
}

type control struct {
OscalControl *oscalTypes_1_1_2.ImplementedRequirementControlImplementation
OscalControl *oscalTypes.ImplementedRequirementControlImplementation
Uuid, Name string
Validations []validationLink
}
Expand All @@ -36,7 +36,7 @@ func (i control) Description() string { return i.Uuid }
func (i control) FilterValue() string { return i.Name }

type validationLink struct {
OscalLink *oscalTypes_1_1_2.Link
OscalLink *oscalTypes.Link
Text string
Name string
Validation pkgcommon.Validation
Expand All @@ -46,7 +46,7 @@ func (i validationLink) Title() string { return i.Name }
func (i validationLink) Description() string { return i.Text }
func (i validationLink) FilterValue() string { return i.Name }

func GetComponents(oscalComponent *oscalTypes_1_1_2.ComponentDefinition) []component {
func GetComponents(oscalComponent *oscalTypes.ComponentDefinition) []component {
components := make([]component, 0)

if oscalComponent != nil {
Expand Down
10 changes: 5 additions & 5 deletions src/internal/tui/component/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/internal/tui/common"
)

Expand All @@ -25,7 +25,7 @@ type Model struct {
help common.HelpModel
keys keys
focus focus
oscalComponent *oscalTypes_1_1_2.ComponentDefinition
oscalComponent *oscalTypes.ComponentDefinition
components []component
selectedComponent component
componentPicker common.PickerModel
Expand Down Expand Up @@ -54,7 +54,7 @@ type ModelOpenMsg struct {
}
type ModelCloseMsg struct{}

func NewComponentDefinitionModel(oscalComponent *oscalTypes_1_1_2.ComponentDefinition) Model {
func NewComponentDefinitionModel(oscalComponent *oscalTypes.ComponentDefinition) Model {
var selectedComponent component
var selectedFramework framework
viewedControls := make([]blist.Item, 0)
Expand Down Expand Up @@ -444,7 +444,7 @@ func (m Model) mainView() string {

// UpdateWithComponentDefinition updates the model data given a component definition
// Useful when a new component definition is loaded (at init time or if component definition is generated)
func (m *Model) UpdateWithComponentDefinition(oscalComponent *oscalTypes_1_1_2.ComponentDefinition) {
func (m *Model) UpdateWithComponentDefinition(oscalComponent *oscalTypes.ComponentDefinition) {
var selectedComponent component
var selectedFramework framework
components := make([]component, 0)
Expand Down Expand Up @@ -501,7 +501,7 @@ func (m *Model) GetDimensions() (height, width int) {
}

// GetComponentDefinition returns the component definition model, used on save events
func (m *Model) GetComponentDefinition() *oscalTypes_1_1_2.ComponentDefinition {
func (m *Model) GetComponentDefinition() *oscalTypes.ComponentDefinition {
return m.oscalComponent
}

Expand Down
4 changes: 2 additions & 2 deletions src/internal/tui/component/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/internal/testhelpers"
"github.com/defenseunicorns/lula/src/internal/tui/common"
"github.com/defenseunicorns/lula/src/internal/tui/component"
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestEditComponentDefinitionModel(t *testing.T) {
model.UpdateDescription(testDescription)

// Create OSCAL model
mdl := &oscalTypes_1_1_2.OscalCompleteSchema{
mdl := &oscalTypes.OscalCompleteSchema{
ComponentDefinition: model.GetComponentDefinition(),
}

Expand Down
16 changes: 8 additions & 8 deletions src/internal/tui/component/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-3"
"github.com/defenseunicorns/lula/src/internal/tui/common"
"github.com/defenseunicorns/lula/src/pkg/common/oscal"
requirementstore "github.com/defenseunicorns/lula/src/pkg/common/requirement-store"
Expand All @@ -34,7 +34,7 @@ type ValidationCompleteMsg struct {
Err error
}
type ValidationDataMsg struct {
AssessmentResults *oscalTypes_1_1_2.AssessmentResults
AssessmentResults *oscalTypes.AssessmentResults
}
type ValidateCloseMsg struct{}

Expand All @@ -45,16 +45,16 @@ type ValidateModel struct {
validatable bool
target string
content string
oscalComponent *oscalTypes_1_1_2.ComponentDefinition
controlImplSet []oscalTypes_1_1_2.ControlImplementationSet
oscalComponent *oscalTypes.ComponentDefinition
controlImplSet []oscalTypes.ControlImplementationSet
validationStore *validationstore.ValidationStore
assessmentResults *oscalTypes_1_1_2.AssessmentResults
assessmentResults *oscalTypes.AssessmentResults
help common.HelpModel
height int
width int
}

func NewValidateModel(oscalComponent *oscalTypes_1_1_2.ComponentDefinition) ValidateModel {
func NewValidateModel(oscalComponent *oscalTypes.ComponentDefinition) ValidateModel {
help := common.NewHelpModel(true)
help.ShortHelp = []key.Binding{common.CommonKeys.Confirm, common.CommonKeys.Cancel}

Expand Down Expand Up @@ -208,15 +208,15 @@ func (m *ValidateModel) updateSizing(height, width int) {
m.width = common.Max(width, minimumWidth)
}

func (m *ValidateModel) RunValidations(runExecutable bool, target string) (*oscalTypes_1_1_2.AssessmentResults, error) {
func (m *ValidateModel) RunValidations(runExecutable bool, target string) (*oscalTypes.AssessmentResults, error) {
validator, err := validation.New(
validation.WithAllowExecution(runExecutable, true),
)
if err != nil {
return nil, err
}

results := make([]oscalTypes_1_1_2.Result, 0)
results := make([]oscalTypes.Result, 0)
if len(m.controlImplSet) > 0 {
findings, observations, _ := validator.ValidateOnControlImplementations(context.Background(), &m.controlImplSet, m.validationStore, target)
result, err := oscal.CreateResult(findings, observations)
Expand Down
Loading
Loading