File tree Expand file tree Collapse file tree 4 files changed +88
-24
lines changed Expand file tree Collapse file tree 4 files changed +88
-24
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,30 @@ const componentA = new CDX.Models.Component(
3434bom . components . add ( componentA )
3535bom . metadata . component . dependencies . add ( componentA . bomRef )
3636
37+ const serializeSpec = CDX . Spec . Spec1dot4
38+
3739const jsonSerializer = new CDX . Serialize . JsonSerializer (
38- new CDX . Serialize . JSON . Normalize . Factory (
39- CDX . Spec . Spec1dot4 ) )
40- const serialized = jsonSerializer . serialize ( bom )
41- console . log ( serialized )
40+ new CDX . Serialize . JSON . Normalize . Factory ( serializeSpec ) )
41+ const serializedJson = jsonSerializer . serialize ( bom )
42+ console . log ( serializedJson )
43+ try {
44+ const jsonValidator = new CDX . Validation . JsonStrictValidator ( serializeSpec . version )
45+ jsonValidator . validate ( serializedJson )
46+ } catch ( err ) {
47+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
48+ console . error ( 'invalid SBOM' , err )
49+ }
50+ }
4251
4352const xmlSerializer = new CDX . Serialize . XmlSerializer (
44- new CDX . Serialize . XML . Normalize . Factory (
45- CDX . Spec . Spec1dot4 ) )
53+ new CDX . Serialize . XML . Normalize . Factory ( serializeSpec ) )
4654const serializedXML = xmlSerializer . serialize ( bom )
4755console . log ( serializedXML )
56+ try {
57+ const xmlValidator = new CDX . Validation . XmlValidator ( serializeSpec . version )
58+ xmlValidator . validate ( serializedXML )
59+ } catch ( err ) {
60+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
61+ console . error ( 'invalid SBOM' , err )
62+ }
63+ }
Original file line number Diff line number Diff line change @@ -34,14 +34,30 @@ const componentA = new CDX.Models.Component(
3434bom . components . add ( componentA )
3535bom . metadata . component . dependencies . add ( componentA . bomRef )
3636
37+ const serializeSpec = CDX . Spec . Spec1dot4
38+
3739const jsonSerializer = new CDX . Serialize . JsonSerializer (
38- new CDX . Serialize . JSON . Normalize . Factory (
39- CDX . Spec . Spec1dot4 ) )
40- const serialized = jsonSerializer . serialize ( bom )
41- console . log ( serialized )
40+ new CDX . Serialize . JSON . Normalize . Factory ( serializeSpec ) )
41+ const serializedJson = jsonSerializer . serialize ( bom )
42+ console . log ( serializedJson )
43+ try {
44+ const jsonValidator = new CDX . Validation . JsonStrictValidator ( serializeSpec . version )
45+ jsonValidator . validate ( serializedJson )
46+ } catch ( err ) {
47+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
48+ console . error ( 'invalid SBOM' , err )
49+ }
50+ }
4251
4352const xmlSerializer = new CDX . Serialize . XmlSerializer (
44- new CDX . Serialize . XML . Normalize . Factory (
45- CDX . Spec . Spec1dot4 ) )
53+ new CDX . Serialize . XML . Normalize . Factory ( serializeSpec ) )
4654const serializedXML = xmlSerializer . serialize ( bom )
4755console . log ( serializedXML )
56+ try {
57+ const xmlValidator = new CDX . Validation . XmlValidator ( serializeSpec . version )
58+ xmlValidator . validate ( serializedXML )
59+ } catch ( err ) {
60+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
61+ console . error ( 'invalid SBOM' , err )
62+ }
63+ }
Original file line number Diff line number Diff line change @@ -34,14 +34,30 @@ const componentA = new CDX.Models.Component(
3434bom . components . add ( componentA )
3535bom . metadata . component . dependencies . add ( componentA . bomRef )
3636
37+ const serializeSpec = CDX . Spec . Spec1dot4
38+
3739const jsonSerializer = new CDX . Serialize . JsonSerializer (
38- new CDX . Serialize . JSON . Normalize . Factory (
39- CDX . Spec . Spec1dot4 ) )
40- const serialized = jsonSerializer . serialize ( bom )
41- console . log ( serialized )
40+ new CDX . Serialize . JSON . Normalize . Factory ( serializeSpec ) )
41+ const serializedJson = jsonSerializer . serialize ( bom )
42+ console . log ( serializedJson )
43+ try {
44+ const jsonValidator = new CDX . Validation . JsonStrictValidator ( serializeSpec . version )
45+ jsonValidator . validate ( serializedJson )
46+ } catch ( err ) {
47+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
48+ console . error ( 'invalid SBOM' , err )
49+ }
50+ }
4251
4352const xmlSerializer = new CDX . Serialize . XmlSerializer (
44- new CDX . Serialize . XML . Normalize . Factory (
45- CDX . Spec . Spec1dot4 ) )
53+ new CDX . Serialize . XML . Normalize . Factory ( serializeSpec ) )
4654const serializedXML = xmlSerializer . serialize ( bom )
4755console . log ( serializedXML )
56+ try {
57+ const xmlValidator = new CDX . Validation . XmlValidator ( serializeSpec . version )
58+ xmlValidator . validate ( serializedXML )
59+ } catch ( err ) {
60+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
61+ console . error ( 'invalid SBOM' , err )
62+ }
63+ }
Original file line number Diff line number Diff line change @@ -34,14 +34,30 @@ const componentA = new CDX.Models.Component(
3434bom . components . add ( componentA )
3535bom . metadata . component . dependencies . add ( componentA . bomRef )
3636
37+ const serializeSpec = CDX . Spec . Spec1dot4
38+
3739const jsonSerializer = new CDX . Serialize . JsonSerializer (
38- new CDX . Serialize . JSON . Normalize . Factory (
39- CDX . Spec . Spec1dot4 ) )
40- const serialized = jsonSerializer . serialize ( bom )
41- console . log ( serialized )
40+ new CDX . Serialize . JSON . Normalize . Factory ( serializeSpec ) )
41+ const serializedJson = jsonSerializer . serialize ( bom )
42+ console . log ( serializedJson )
43+ try {
44+ const jsonValidator = new CDX . Validation . JsonStrictValidator ( serializeSpec . version )
45+ jsonValidator . validate ( serializedJson )
46+ } catch ( err ) {
47+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
48+ console . error ( 'invalid SBOM' , err )
49+ }
50+ }
4251
4352const xmlSerializer = new CDX . Serialize . XmlSerializer (
44- new CDX . Serialize . XML . Normalize . Factory (
45- CDX . Spec . Spec1dot4 ) )
53+ new CDX . Serialize . XML . Normalize . Factory ( serializeSpec ) )
4654const serializedXML = xmlSerializer . serialize ( bom )
4755console . log ( serializedXML )
56+ try {
57+ const xmlValidator = new CDX . Validation . XmlValidator ( serializeSpec . version )
58+ xmlValidator . validate ( serializedXML )
59+ } catch ( err ) {
60+ if ( ! ( err instanceof CDX . Validation . MissingOptionalDependencyError ) ) {
61+ console . error ( 'invalid SBOM' , err )
62+ }
63+ }
You can’t perform that action at this time.
0 commit comments