diff --git a/.github/workflows/process-nist-oscal.yml b/.github/workflows/process-nist-oscal.yml index 88ffada..b75a5c4 100644 --- a/.github/workflows/process-nist-oscal.yml +++ b/.github/workflows/process-nist-oscal.yml @@ -37,4 +37,4 @@ jobs: - name: generate go code for NIST OSCAL run: | - ./gocomply_metaschema generate ./OSCAL/src/metaschema github.com/gocomply/oscalkit types/oscal || : + ./gocomply_metaschema generate ./OSCAL/src/metaschema github.com/gocomply/oscalkit types/oscal diff --git a/metaschema/generate.go b/metaschema/generate.go index d88fac7..70346cb 100644 --- a/metaschema/generate.go +++ b/metaschema/generate.go @@ -1,7 +1,6 @@ package metaschema import ( - "encoding/xml" "fmt" "io" "os" @@ -9,6 +8,7 @@ import ( "github.com/gocomply/metaschema/metaschema/parser" "github.com/gocomply/metaschema/metaschema/templates" + "github.com/gocomply/metaschema/pkg/xml_dtd" ) func Generate(metaschemaDir, goModule, outputDir string) error { @@ -46,7 +46,7 @@ func Generate(metaschemaDir, goModule, outputDir string) error { func decode(metaschemaDir, goModule string, r io.Reader) (*parser.Metaschema, error) { var meta parser.Metaschema - d := xml.NewDecoder(r) + d := xml_dtd.NewDecoder(r) if err := d.Decode(&meta); err != nil { return nil, fmt.Errorf("Error decoding metaschema: %s", err) diff --git a/pkg/xml_dtd/decoder.go b/pkg/xml_dtd/decoder.go new file mode 100644 index 0000000..d8dd035 --- /dev/null +++ b/pkg/xml_dtd/decoder.go @@ -0,0 +1,26 @@ +package xml_dtd + +import ( + "encoding/xml" + "io" +) + +type Decoder struct { + *xml.Decoder +} + +func NewDecoder(r io.Reader) *Decoder { + dtd := &Decoder{ + Decoder: xml.NewDecoder(r), + } + dtd.Entity = map[string]string{ + "allowed-values-control-group-property-name": "TODO-FIX-THIS", + "allowed-values-component_inventory-item_property-name": "TODO-FIX-THIS", + "allowed-values-component_component_property-name": "TODO-FIX-THIS", + } + return dtd +} + +func (d *Decoder) Decode(v interface{}) error { + return d.Decoder.Decode(v) +}