Skip to content

Commit

Permalink
Rename reporter to result2oscal
Browse files Browse the repository at this point in the history
Signed-off-by: Takumi Yanagawa <[email protected]>
  • Loading branch information
yana1205 committed Dec 7, 2023
1 parent 6ca8ef3 commit 4ca1c16
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cmd/ocm/result2oscal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/IBM/compliance-to-policy/cmd/ocm/result2oscal/options"
"github.com/IBM/compliance-to-policy/pkg"
"github.com/IBM/compliance-to-policy/pkg/c2pcr"
"github.com/IBM/compliance-to-policy/pkg/ocm/reporter"
"github.com/IBM/compliance-to-policy/pkg/ocm"
typec2pcr "github.com/IBM/compliance-to-policy/pkg/types/c2pcr"
)

Expand Down Expand Up @@ -69,7 +69,7 @@ func Run(options *options.Options) error {
panic(err)
}

r := reporter.NewReporter(c2pcrParsed)
r := ocm.NewResultToOscal(c2pcrParsed)
arRoot, err := r.Generate()
if err != nil {
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ocm/reporter/helper.go → pkg/ocm/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package reporter
package ocm

import (
typeconfigpolicy "github.com/IBM/compliance-to-policy/pkg/types/configurationpolicy"
Expand Down
15 changes: 6 additions & 9 deletions pkg/ocm/reporter/reporter.go → pkg/ocm/result2oscal.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package reporter
package ocm

import (
"fmt"
Expand All @@ -24,7 +24,6 @@ import (
"time"

"github.com/IBM/compliance-to-policy/pkg"
"go.uber.org/zap"
sigyaml "sigs.k8s.io/yaml"

"k8s.io/apimachinery/pkg/util/sets"
Expand All @@ -39,9 +38,7 @@ import (
typeutils "github.com/IBM/compliance-to-policy/pkg/types/utils"
)

var logger *zap.Logger = pkg.GetLogger("reporter")

type Reporter struct {
type ResultToOscal struct {
c2pParsed typec2pcr.C2PCRParsed
policies []*typepolicy.Policy
policySets []*typepolicy.PolicySet
Expand All @@ -61,8 +58,8 @@ const (
GenerationTypePolicyReport GenerationType = "policy-report"
)

func NewReporter(c2pParsed typec2pcr.C2PCRParsed) *Reporter {
r := Reporter{
func NewResultToOscal(c2pParsed typec2pcr.C2PCRParsed) *ResultToOscal {
r := ResultToOscal{
c2pParsed: c2pParsed,
policies: []*typepolicy.Policy{},
policySets: []*typepolicy.PolicySet{},
Expand All @@ -71,7 +68,7 @@ func NewReporter(c2pParsed typec2pcr.C2PCRParsed) *Reporter {
return &r
}

func (r *Reporter) Generate() (*typear.AssessmentResultsRoot, error) {
func (r *ResultToOscal) Generate() (*typear.AssessmentResultsRoot, error) {
traverseFunc := genTraverseFunc(
func(policy typepolicy.Policy) { r.policies = append(r.policies, &policy) },
func(policySet typepolicy.PolicySet) { r.policySets = append(r.policySets, &policySet) },
Expand Down Expand Up @@ -243,7 +240,7 @@ func (r *Reporter) Generate() (*typear.AssessmentResultsRoot, error) {
return &arRoot, nil
}

func (r *Reporter) GenerateReasonsFromRawPolicies(policy typepolicy.Policy) []Reason {
func (r *ResultToOscal) GenerateReasonsFromRawPolicies(policy typepolicy.Policy) []Reason {
reasons := []Reason{}
for _, status := range policy.Status.Status {
clusterName := status.ClusterName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package reporter
package ocm

import (
"os"
Expand All @@ -29,7 +29,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestReporter(t *testing.T) {
func TestResult2Oscal(t *testing.T) {

policyDir := pkg.PathFromPkgDirectory("./testdata/ocm/policies")
policyResultsDir := pkg.PathFromPkgDirectory("./testdata/ocm/policy-results")
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestReporter(t *testing.T) {
c2pcrParsed, err := c2pcrParser.Parse(c2pcrSpec)
assert.NoError(t, err, "Should not happen")

reporter := NewReporter(c2pcrParsed)
reporter := NewResultToOscal(c2pcrParsed)
arRoot, err := reporter.Generate()
assert.NoError(t, err, "Should not happen")

Expand Down

0 comments on commit 4ca1c16

Please sign in to comment.