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(system-security-plan): initial creation of SSP Model #802

Merged
merged 8 commits into from
Nov 20, 2024
11 changes: 9 additions & 2 deletions src/pkg/common/oscal/complete-schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (

"github.com/defenseunicorns/go-oscal/src/pkg/files"
oscalTypes "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
"github.com/defenseunicorns/lula/src/internal/inject"
"github.com/defenseunicorns/lula/src/pkg/message"
yamlV3 "gopkg.in/yaml.v3"
"sigs.k8s.io/yaml"

"github.com/defenseunicorns/lula/src/internal/inject"
"github.com/defenseunicorns/lula/src/pkg/message"
)

type OSCALModel interface {
Expand Down Expand Up @@ -71,6 +72,12 @@ func WriteOscalModelNew(filePath string, model OSCALModel) error {
}
}

// Validate the model adheres to the OSCAL schema before writing
err = multiModelValidate(b.Bytes())
if err != nil {
return err
}

err = files.WriteOutput(b.Bytes(), filePath)
if err != nil {
return err
Expand Down
12 changes: 12 additions & 0 deletions src/pkg/common/oscal/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/defenseunicorns/go-oscal/src/pkg/uuid"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"

"github.com/defenseunicorns/lula/src/pkg/message"

meganwolf0 marked this conversation as resolved.
Show resolved Hide resolved
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -502,6 +503,17 @@ func FilterControlImplementations(componentDefinition *oscalTypes_1_1_2.Componen
return controlMap
}

func ComponentsToMap(componentDefinition *oscalTypes_1_1_2.ComponentDefinition) map[string]*oscalTypes_1_1_2.DefinedComponent {
components := make(map[string]*oscalTypes_1_1_2.DefinedComponent)

if componentDefinition != nil && componentDefinition.Components != nil {
for _, component := range *componentDefinition.Components {
components[component.UUID] = &component
}
}
return components
}

func MakeComponentDeterminstic(component *oscalTypes_1_1_2.ComponentDefinition) {
// sort components by title

Expand Down
Loading