Skip to content

Commit

Permalink
fix: updated create observation fcn and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
meganwolf0 committed Jun 13, 2024
1 parent ac24ce5 commit dc2b1d1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
11 changes: 6 additions & 5 deletions src/pkg/common/oscal/assessment-results.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,14 @@ func findAndSortResults(resultMap map[string]*oscalTypes_1_1_2.AssessmentResults
}

// Helper function to create observation
func CreateObservation(method string, descriptionPattern string, descriptionArgs ...any) oscalTypes_1_1_2.Observation {
func CreateObservation(method string, relevantEvidence *[]oscalTypes_1_1_2.RelevantEvidence, descriptionPattern string, descriptionArgs ...any) oscalTypes_1_1_2.Observation {
rfc3339Time := time.Now()
uuid := uuid.NewUUID()
return oscalTypes_1_1_2.Observation{
Collected: rfc3339Time,
Methods: []string{method},
UUID: uuid,
Description: fmt.Sprintf(descriptionPattern, descriptionArgs...),
Collected: rfc3339Time,
Methods: []string{method},
UUID: uuid,
Description: fmt.Sprintf(descriptionPattern, descriptionArgs...),
RelevantEvidence: relevantEvidence,
}
}
21 changes: 8 additions & 13 deletions src/pkg/common/validation-store/validation-store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package validationstore

import (
"fmt"
"time"

"github.com/defenseunicorns/go-oscal/src/pkg/uuid"
oscalTypes_1_1_2 "github.com/defenseunicorns/go-oscal/src/types/oscal-1-1-2"
Expand Down Expand Up @@ -136,20 +135,16 @@ func (v *ValidationStore) RunValidations(confirmExecution bool) []oscalTypes_1_1
}
}

observation := &oscalTypes_1_1_2.Observation{
Collected: time.Now(),
Methods: []string{"TEST"},
UUID: uuid.NewUUID(),
Description: fmt.Sprintf("[TEST]: %s - %s\n", k, val.Name),
RelevantEvidence: &[]oscalTypes_1_1_2.RelevantEvidence{
{
Description: fmt.Sprintf("Result: %s\n", val.Result.State),
Remarks: remarks,
},
// Create an observation
relevantEvidence := &[]oscalTypes_1_1_2.RelevantEvidence{
{
Description: fmt.Sprintf("Result: %s\n", val.Result.State),
Remarks: remarks,
},
}
v.observationMap[k] = observation
observations = append(observations, *observation)
observation := oscal.CreateObservation("TEST", relevantEvidence, "[TEST]: %s - %s\n", k, val.Name)
v.observationMap[k] = &observation
observations = append(observations, observation)
spinner.Successf("%s -> %s -> %s", spinnerMessage, completedText, val.Result.State)
}
return observations
Expand Down

0 comments on commit dc2b1d1

Please sign in to comment.