Skip to content

Commit

Permalink
For usnistgov#452, modified copy-and-convert script to suppress chara…
Browse files Browse the repository at this point in the history
…cter-level post-processing in generated JSON; added unit tests for URIs to detect issues with solidus characters '/'
  • Loading branch information
wendellpiez committed Sep 20, 2019
1 parent 48fc8df commit e623feb
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build/ci-cd/copy-and-convert-content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ while IFS="|" read path format model converttoformats || [[ -n "$path" ]]; do
case $altformat in
json)
# Remove extra slashes
perl -pi -e 's,\\/,/,g' "${dest}"
# perl -pi -e 's,\\/,/,g' "${dest}"
# translate OSCAL mime types
perl -pi -e 's,(application/oscal\.[a-z]+\+)xml\",\1json\",g' "${dest}"
# relative content paths
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

{ "$schema" : "http://json-schema.org/draft-07/schema#",
"$id" : "http://csrc.nist.gov/ns/metaschema/unit-test/datatypes-uri-schema.json",
"$comment" : "Metaschema Unit Test: URIs: JSON Schema",
"type" : "object",
"definitions" :
{ "parent" :
{ "title" : "parent",
"description" : "parent assembly",
"$id" : "#/definitions/parent",
"type" : "object",
"properties" :
{ "uri-flag" :
{ "title" : "Universal Resource Identifier Flag",
"description" : "Per W3C",
"type" : "string",
"format" : "uri" },
"uri-reference-flag" :
{ "title" : "Universal Resource Identifier Reference Flag",
"description" : "Per W3C, can be a relative URI",
"type" : "string",
"format" : "uri-reference" },
"uri-fields" :
{ "anyOf" :
[
{ "$ref" : "#/definitions/uri-field" },

{ "type" : "array",
"items" :
{ "$ref" : "#/definitions/uri-field" },
"minItems" : 2 } ] },
"uri-reference-fields" :
{ "anyOf" :
[
{ "$ref" : "#/definitions/uri-reference-field" },

{ "type" : "array",
"items" :
{ "$ref" : "#/definitions/uri-reference-field" },
"minItems" : 2 } ] } },
"required" :
[ "uri-flag",
"uri-reference-flag" ],
"additionalProperties" : false },
"uri-field" :
{ "title" : "Universal Resource Identifier Flag",
"description" : "Per W3C",
"$id" : "#/definitions/uri-field",
"type" : "string",
"format" : "uri" },
"uri-reference-field" :
{ "title" : "Universal Resource Identifier Flag",
"description" : "Per W3C",
"$id" : "#/definitions/uri-reference-field",
"type" : "string",
"format" : "uri-reference" } },
"properties" :
{ "parent" :
{ "$ref" : "#/definitions/parent" } } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- OSCAL CATALOG METASCHEMA -->
<!-- validate with XSD and Schematron (linked) -->
<?xml-model href="../../lib/metaschema-check.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<?xml-stylesheet type="text/css" href="../../lib/metaschema-author.css"?>
<METASCHEMA xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://csrc.nist.gov/ns/oscal/metaschema/1.0 ../../lib/metaschema.xsd"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:o="http://csrc.nist.gov/ns/oscal/example"
root="parent">
<schema-name>Metaschema Unit Test: URIs</schema-name>
<schema-version>1.0-milestone1</schema-version>
<short-name>metaschema-datatypes-uri</short-name>
<namespace>http://csrc.nist.gov/ns/metaschema/unit-test/datatypes-uri</namespace>

<define-assembly name="parent">
<formal-name>parent</formal-name>
<description>parent assembly</description>
<flag name="uri-flag" as-type="uri" required="yes">
<formal-name>Universal Resource Identifier Flag</formal-name>
<description>Per W3C</description>
</flag>
<flag name="uri-reference-flag" as-type="uri-reference" required="yes">
<formal-name>Universal Resource Identifier Reference Flag</formal-name>
<description>Per W3C, can be a relative URI</description>
</flag>
<model>
<field ref="uri-field" max-occurs="unbounded">
<group-as name="uri-fields"/>
</field>
<field ref="uri-reference-field" max-occurs="unbounded">
<group-as name="uri-reference-fields"/>
</field>
</model>
</define-assembly>


<define-field name="uri-field" as-type="uri">
<formal-name>Universal Resource Identifier Flag</formal-name>
<description>Per W3C</description>
</define-field>

<define-field name="uri-reference-field" as-type="uri-reference">
<formal-name>Universal Resource Identifier Flag</formal-name>
<description>Per W3C</description>
</define-field>

</METASCHEMA>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"parent": {
"uri-flag": "//pages.nist.gov/OSCAL",
"uri-reference-flag": "c:\\OSCAL",
"uri-fields": [
"https://www.w3.org{}",
"https://www.w3.org/%%%%",
"http://www.nist.gov?x-y=z"
],
"uri-reference-fields": [ "(|)" ]

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": {
"uri-flag": "http://pages.nist.gov/OSCAL",
"uri-reference-flag": "OSCAL",
"uri-fields": [
"gopher://loc.gov",
"https://www.w3.org",
"http://www.nist.gov"
],
"uri-reference-fields": "myhomepage.html"
}
}

0 comments on commit e623feb

Please sign in to comment.