From c67b7171a5482f436815758639dec8816fb6e175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Luka=C5=A1=C3=ADk?= Date: Tue, 4 Feb 2020 16:59:54 +0100 Subject: [PATCH] Remove previous version of opencontrol2oscal generator --- types/oscal/opencontrol.go | 165 ------------------------------------- types/oscal/oscal.go | 52 ------------ 2 files changed, 217 deletions(-) delete mode 100644 types/oscal/opencontrol.go diff --git a/types/oscal/opencontrol.go b/types/oscal/opencontrol.go deleted file mode 100644 index ca930e29..00000000 --- a/types/oscal/opencontrol.go +++ /dev/null @@ -1,165 +0,0 @@ -package oscal - -// func convertOC(oc opencontrol.OpenControl, ocComponents []opencontrol.Component) (*OSCAL, error) { -// ocOSCAL := Implementation{} -// ocOSCAL.Title = oc.Name - -// ocOSCAL.Paragraphs = append(ocOSCAL.Paragraphs, P{ -// // OptionalClass: "description", -// Raw: oc.Metadata.Description, -// }) - -// for _, maintainer := range oc.Metadata.Maintainers { -// ocOSCAL.Props = append(ocOSCAL.Props, Prop{ -// OptionalClass: "maintainer", -// Value: maintainer, -// }) -// } - -// implementationProfiles := &Profiles{} - -// for _, cert := range oc.Certifications { -// implementationProfiles.Links = append(implementationProfiles.Links, Link{ -// Rel: "profile", -// Href: cert, -// }) -// } - -// if oc.Dependencies != nil { -// for _, cert := range oc.Dependencies.Certifications { -// implementationProfiles.Links = append(implementationProfiles.Links, Link{ -// Rel: "profile", -// Href: "../../FedRAMP/FedRAMP-MODERATE-crude", -// Value: parseOCCert(cert.URL), -// }) -// } -// } - -// ocOSCAL.Profiles = implementationProfiles -// ocOSCAL.Params = Params{} -// ocOSCAL.Components = Components{} - -// for _, ocComponent := range ocComponents { -// item := Item{} - -// item.Title = &Raw{Value: ocComponent.Name} -// item.Prose = &Prose{} - -// // Outputs "null" JSON value since this is self-closing XML tag -// item.Prose.P = append(item.Prose.P, P{ -// // OptionalClass: "description", -// }) - -// if ocComponent.ResponsibleRole != "" { -// item.Prose.P = append(item.Prose.P, P{ -// // OptionalClass: "responsibleRoles", -// Raw: ocComponent.ResponsibleRole, -// }) -// } - -// for _, ocSatisfy := range ocComponent.Satisfies { -// var part Part - -// part.OptionalClass = "satisfies" - -// key := strings.ToLower(ocSatisfy.ControlKey) -// r := strings.NewReplacer( -// " ", "", -// "-", ".", -// "(", ".", -// ")", "", -// ) -// key = fmt.Sprintf("#%s", r.Replace(key)) -// part.Links = append(part.Links, Link{ -// Rel: "satisfies", -// Href: key, -// // TODO: Value from linked "catalog" -// }) - -// part.Prose = &Prose{} -// for _, ocNarrative := range ocSatisfy.Narrative { -// raw := ocNarrative.Text -// if strings.HasSuffix(raw, "\n") { -// raw = strings.TrimSuffix(raw, "\n") -// } -// part.Prose.P = append(part.Prose.P, P{ -// // OptionalClass: "narrative", -// Raw: raw, -// }) -// } - -// for _, ocOrigin := range ocSatisfy.ControlOrigins { -// part.Props = append(part.Props, Prop{ -// OptionalClass: "origin", -// Value: ocOrigin, -// }) -// } - -// if ocSatisfy.ControlOrigin != "" { -// part.Props = append(part.Props, Prop{ -// OptionalClass: "origin", -// Value: ocSatisfy.ControlOrigin, -// }) -// } - -// for _, ocParameter := range ocSatisfy.Parameters { -// ocOSCAL.Params.SetParams = append(ocOSCAL.Params.SetParams, ImplementationParam{ -// ID: ocParameter.Key, -// Desc: Desc{ -// Raw: ocParameter.Text, -// }, -// }) -// } - -// for _, ocStatus := range ocSatisfy.ImplementationStatuses { -// part.Props = append(part.Props, Prop{ -// OptionalClass: "status", -// Value: ocStatus, -// }) -// } - -// if ocSatisfy.ImplementationStatus != "" { -// part.Props = append(part.Props, Prop{ -// OptionalClass: "status", -// Value: ocSatisfy.ImplementationStatus, -// }) -// } - -// item.Parts = append(item.Parts, part) -// } - -// for _, ocReference := range ocComponent.References { -// part := Part{ -// OptionalClass: "reference", -// Title: &Raw{Value: ocReference.Name}, -// } - -// part.Prose = &Prose{} -// part.Prose.P = append(part.Prose.P, P{ -// // OptionalClass: "description", -// }) - -// part.Links = append(part.Links, Link{ -// Value: ocReference.Path, -// }) - -// item.Parts = append(item.Parts, part) -// } - -// ocOSCAL.Components.Items = append(ocOSCAL.Components.Items, item) -// } - -// ocOSCAL.Profiles = implementationProfiles - -// return &OSCAL{Implementation: &ocOSCAL}, nil -// } - -// // Temporary mechanism for converting https://github.com/opencontrol/FedRAMP-Certifications -// // to path to OSCAL JSON -// func parseOCCert(url string) string { -// if path.Base(url) == "FedRAMP-Certifications" { -// return "FedRAMP MODERATE Baseline PROFILE" -// } - -// return "" -// } diff --git a/types/oscal/oscal.go b/types/oscal/oscal.go index dcad401a..e4474ea0 100644 --- a/types/oscal/oscal.go +++ b/types/oscal/oscal.go @@ -70,58 +70,6 @@ func (o *OSCAL) MarshalXML(e *xml.Encoder, start xml.StartElement) error { return nil } -// NewFromOC initializes an OSCAL type from raw docker data -// func NewFromOC(options dockerOptions) (*OSCAL, error) { -// ocFile, err := os.Open(options.dockerYAMLFilepath) -// if err != nil { -// return nil, err -// } -// defer ocFile.Close() - -// rawOC, err := ioutil.ReadAll(ocFile) -// if err != nil { -// return nil, err -// } - -// var oc docker.docker -// if err := yaml.Unmarshal(rawOC, &oc); err != nil { -// return nil, err -// } - -// ocComponentFileList := []string{} -// filepath.Walk(filepath.Join(options.dockersDir, "components/"), func(path string, f os.FileInfo, err error) error { -// if !f.IsDir() && (filepath.Ext(path) == ".yaml" || filepath.Ext(path) == ".yml") { -// absPath, err := filepath.Abs(path) -// if err != nil { -// return err -// } -// ocComponentFileList = append(ocComponentFileList, absPath) -// } - -// return nil -// }) - -// ocComponents := []docker.Component{} -// for _, ocComponentFilepath := range ocComponentFileList { -// ocComponentFile, err := os.Open(ocComponentFilepath) -// if err != nil { -// return nil, err -// } -// defer ocComponentFile.Close() - -// rawOCComponentFile, err := ioutil.ReadAll(ocComponentFile) - -// var ocComponent docker.Component -// if err := yaml.Unmarshal(rawOCComponentFile, &ocComponent); err != nil { -// return nil, err -// } - -// ocComponents = append(ocComponents, ocComponent) -// } - -// return convertOC(oc, ocComponents) -// } - // New returns a concrete OSCAL type from a reader func New(r io.Reader) (*OSCAL, error) { oscalBytes, err := ioutil.ReadAll(r)