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

Generate XML and JSON catalogs from processed profiles #61

Open
anweiss opened this issue Jan 21, 2019 · 3 comments
Open

Generate XML and JSON catalogs from processed profiles #61

anweiss opened this issue Jan 21, 2019 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@anweiss
Copy link
Contributor

anweiss commented Jan 21, 2019

In parallel to #12, we should also include the ability to generate XML and JSON catalogs from profiles that have been processed. This will require a somewhat of a refactor of how we parse prose since we'll need to support substituting <insert> elements in catalogs with the contents of <set-param> elements in profiles as part of this issue.

@minhaj10p going to assign you to this one since you've already implemented most of the processing code via #52. I'm thinking we can create two subcommands off of generate to support this. oscalkit generate code would be used for generating catalog source code as we're already doing via #12. oscalkit generate catalogs would be used for addressing this issue. Thoughts?

@anweiss anweiss added the enhancement New feature or request label Jan 21, 2019
@anweiss anweiss added this to the OSCAL 1.0 milestone Jan 21, 2019
@minhaj10p
Copy link
Contributor

minhaj10p commented Jan 23, 2019

@anweiss
Is this a good way to replace the Prose inserts?
Still need to figure out the recursive part manipulation strategy

// ReplaceInsertParams replaces insert parameters
func (p *Prose) ReplaceInsertParams(parameterID, parameterValue string) error {

	rs := fmt.Sprintf(`<insert param-id="%s">`, parameterID)
	regex, err := regexp.Compile(rs)
	if err != nil {
		return err
	}
	for i := range p.P {
		p.P[i].Raw = regex.ReplaceAllString(p.P[i].Raw, parameterValue)

	}
	for i := range p.OL {
		p.OL[i].Raw = regex.ReplaceAllString(p.OL[i].Raw, parameterValue)
		spew.Dump(p.OL[i].Raw)
	}
	for i := range p.Pre {
		p.Pre[i].Raw = regex.ReplaceAllString(p.Pre[i].Raw, parameterValue)
	}
	for i := range p.UL {
		p.UL[i].Raw = regex.ReplaceAllString(p.UL[i].Raw, parameterValue)
	}
	return nil
}

@anweiss
Copy link
Contributor Author

anweiss commented Jan 23, 2019

@minhaj10p I think this is a good approach. Regex is probably going to be the only suitable way to address this for now.

@minhaj10p
Copy link
Contributor

minhaj10p commented Jan 24, 2019

@anweiss I have added the Prose processing for nested part in the catalog in #63

I can append the integration of this in #58 once #63 gets approved and merged.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants