Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Tidying up some of the core OSCAL methods #44

Merged
merged 4 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# oscalkit - OSCAL conversion utility
# Written in 2017 by Andrew Weiss <[email protected]>

# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain worldwide.
# This software is distributed without any warranty.

# You should have received a copy of the CC0 Public Domain Dedication along with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

Makefile
oscalkit
README.md
Expand Down
10 changes: 0 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# oscalkit - OSCAL conversion utility
# Written in 2017 by Andrew Weiss <[email protected]>

# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain worldwide.
# This software is distributed without any warranty.

# You should have received a copy of the CC0 Public Domain Dedication along with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

FROM golang:1.11-alpine AS builder
WORKDIR /go/src/github.com/docker/oscalkit
ARG VERSION
Expand Down
10 changes: 0 additions & 10 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# oscalkit - OSCAL conversion utility
# Written in 2017 by Andrew Weiss <[email protected]>

# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain worldwide.
# This software is distributed without any warranty.

# You should have received a copy of the CC0 Public Domain Dedication along with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

FROM golang:1.11 AS race-detector
WORKDIR /go/src/github.com/docker/oscalkit
COPY . .
Expand Down
10 changes: 0 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# oscalkit - OSCAL conversion utility
# Written in 2017 by Andrew Weiss <[email protected]>

# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain worldwide.
# This software is distributed without any warranty.

# You should have received a copy of the CC0 Public Domain Dedication along with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

GOOS := darwin
GOARCH := amd64
VERSION := 0.2.0
Expand Down
10 changes: 0 additions & 10 deletions cli/cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// oscalkit - OSCAL conversion utility
// Written in 2017 by Andrew Weiss <[email protected]>

// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.

// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

package cmd

import (
Expand Down
10 changes: 0 additions & 10 deletions cli/cmd/convert/convert.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// oscalkit - OSCAL conversion utility
// Written in 2017 by Andrew Weiss <[email protected]>

// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.

// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

package convert

import (
Expand Down
16 changes: 3 additions & 13 deletions cli/cmd/convert/opencontrol.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// oscalkit - OSCAL conversion utility
// Written in 2017 by Andrew Weiss <[email protected]>

// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.

// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

package convert

var includeXML bool
Expand Down Expand Up @@ -48,7 +38,7 @@ var includeXML bool
// }

// if includeXML {
// rawXMLOCOSCAL, err := ocOSCAL.RawXML(true)
// rawXMLOCOSCAL, err := ocOSCAL.XML(true)
// if err != nil {
// return cli.NewExitError(fmt.Sprintf("Error producing raw XML: %s", err), 1)
// }
Expand All @@ -58,7 +48,7 @@ var includeXML bool
// }

// if yaml {
// rawYAMLOCOSCAL, err := ocOSCAL.RawYAML()
// rawYAMLOCOSCAL, err := ocOSCAL.YAML()
// if err != nil {
// return cli.NewExitError(err, 1)
// }
Expand All @@ -67,7 +57,7 @@ var includeXML bool
// }
// }

// rawOCOSCAL, err := ocOSCAL.RawJSON(true)
// rawOCOSCAL, err := ocOSCAL.JSON(true)
// if err != nil {
// return cli.NewExitError(err, 1)
// }
Expand Down
37 changes: 6 additions & 31 deletions cli/cmd/convert/oscal.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// oscalkit - OSCAL conversion utility
// Written in 2017 by Andrew Weiss <[email protected]>

// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.

// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

package convert

import (
Expand Down Expand Up @@ -171,17 +161,12 @@ func convert(src io.Reader, dest io.Writer, outputFormat string) error {
case "json":
logrus.Debug("Converting to JSON")

oscal, err := oscal.New(src)
if err != nil {
return err
}

oscalJSON, err := oscal.RawJSON(true)
o, err := oscal.New(src)
if err != nil {
return err
}

if _, err := dest.Write(oscalJSON); err != nil {
if err := o.JSON(dest, true); err != nil {
return err
}

Expand All @@ -192,17 +177,12 @@ func convert(src io.Reader, dest io.Writer, outputFormat string) error {
case "xml":
logrus.Debug("Converting to XML")

oscal, err := oscal.New(src)
o, err := oscal.New(src)
if err != nil {
return err
}

oscalXML, err := oscal.RawXML(true)
if err != nil {
return err
}

if _, err := dest.Write(oscalXML); err != nil {
if err := o.XML(dest, true); err != nil {
return err
}

Expand All @@ -213,17 +193,12 @@ func convert(src io.Reader, dest io.Writer, outputFormat string) error {
case "yaml":
logrus.Debug("Converting to YAML")

oscal, err := oscal.New(src)
if err != nil {
return err
}

oscalYAML, err := oscal.RawYAML()
o, err := oscal.New(src)
if err != nil {
return err
}

if _, err := dest.Write(oscalYAML); err != nil {
if err := o.YAML(dest); err != nil {
return err
}

Expand Down
10 changes: 0 additions & 10 deletions cli/cmd/validate.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// oscalkit - OSCAL conversion utility
// Written in 2017 by Andrew Weiss <[email protected]>

// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.

// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

package cmd

import (
Expand Down
10 changes: 0 additions & 10 deletions cli/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// oscalkit - OSCAL conversion utility
// Written in 2017 by Andrew Weiss <[email protected]>

// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.

// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

package main

import (
Expand Down
6 changes: 5 additions & 1 deletion types/oscal/catalog/href.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func (h *Href) UnmarshalJSON(b []byte) error {
}

func (h *Href) MarshalJSON() ([]byte, error) {
return json.Marshal(h.String())
if h.URL != nil {
return json.Marshal(h.String())
}

return json.Marshal("")
}

func (h *Href) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
Expand Down
10 changes: 0 additions & 10 deletions types/oscal/catalog/prose.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// oscalkit - OSCAL conversion utility
// Written in 2017 by Andrew Weiss <[email protected]>

// To the extent possible under law, the author(s) have dedicated all copyright
// and related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.

// You should have received a copy of the CC0 Public Domain Dedication along with this software.
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

package catalog

import (
Expand Down
Loading