From dc2b1d1beea2873f18b8c2aeb084b75ffef318b9 Mon Sep 17 00:00:00 2001 From: Megan Wolf Date: Thu, 13 Jun 2024 13:06:21 -0400 Subject: [PATCH] fix: updated create observation fcn and usage --- src/pkg/common/oscal/assessment-results.go | 11 +++++----- .../validation-store/validation-store.go | 21 +++++++------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/pkg/common/oscal/assessment-results.go b/src/pkg/common/oscal/assessment-results.go index 62693210..2e029b3c 100644 --- a/src/pkg/common/oscal/assessment-results.go +++ b/src/pkg/common/oscal/assessment-results.go @@ -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, } } diff --git a/src/pkg/common/validation-store/validation-store.go b/src/pkg/common/validation-store/validation-store.go index a3cf6427..e512a697 100644 --- a/src/pkg/common/validation-store/validation-store.go +++ b/src/pkg/common/validation-store/validation-store.go @@ -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" @@ -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