sbom-cyclonedx 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (368) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -0
  3. data/.gitlab-ci.yml +49 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +72 -0
  6. data/.vscode/settings.json +6 -0
  7. data/CHANGELOG.md +9 -0
  8. data/CODE_OF_CONDUCT.md +132 -0
  9. data/Gemfile +26 -0
  10. data/Gemfile.lock +179 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +39 -0
  13. data/Rakefile +36 -0
  14. data/Steepfile +14 -0
  15. data/bin/console +11 -0
  16. data/bin/rbs_spec +9 -0
  17. data/bin/setup +8 -0
  18. data/bom-1.6.schema.json +7334 -0
  19. data/lib/email_address_extension.rb +26 -0
  20. data/lib/sbom/cyclone_dx/enum.rb +2178 -0
  21. data/lib/sbom/cyclone_dx/field.rb +404 -0
  22. data/lib/sbom/cyclone_dx/pattern.rb +43 -0
  23. data/lib/sbom/cyclone_dx/record/advisory.rb +17 -0
  24. data/lib/sbom/cyclone_dx/record/annotation.rb +46 -0
  25. data/lib/sbom/cyclone_dx/record/attachment.rb +21 -0
  26. data/lib/sbom/cyclone_dx/record/base.rb +244 -0
  27. data/lib/sbom/cyclone_dx/record/cipher_suite.rb +23 -0
  28. data/lib/sbom/cyclone_dx/record/co2_measure.rb +18 -0
  29. data/lib/sbom/cyclone_dx/record/command.rb +18 -0
  30. data/lib/sbom/cyclone_dx/record/commit.rb +25 -0
  31. data/lib/sbom/cyclone_dx/record/component.rb +126 -0
  32. data/lib/sbom/cyclone_dx/record/component_data.rb +46 -0
  33. data/lib/sbom/cyclone_dx/record/component_evidence.rb +68 -0
  34. data/lib/sbom/cyclone_dx/record/component_identity_evidence.rb +36 -0
  35. data/lib/sbom/cyclone_dx/record/composition.rb +33 -0
  36. data/lib/sbom/cyclone_dx/record/condition.rb +20 -0
  37. data/lib/sbom/cyclone_dx/record/copyright.rb +16 -0
  38. data/lib/sbom/cyclone_dx/record/crypto_properties.rb +137 -0
  39. data/lib/sbom/cyclone_dx/record/data_governance.rb +21 -0
  40. data/lib/sbom/cyclone_dx/record/data_governance_responsible_party.rb +22 -0
  41. data/lib/sbom/cyclone_dx/record/declarations.rb +193 -0
  42. data/lib/sbom/cyclone_dx/record/definitions.rb +17 -0
  43. data/lib/sbom/cyclone_dx/record/dependency.rb +21 -0
  44. data/lib/sbom/cyclone_dx/record/diff.rb +18 -0
  45. data/lib/sbom/cyclone_dx/record/energy_consumption.rb +31 -0
  46. data/lib/sbom/cyclone_dx/record/energy_measure.rb +18 -0
  47. data/lib/sbom/cyclone_dx/record/energy_provider.rb +31 -0
  48. data/lib/sbom/cyclone_dx/record/environmental_consideration.rb +20 -0
  49. data/lib/sbom/cyclone_dx/record/event.rb +31 -0
  50. data/lib/sbom/cyclone_dx/record/external_reference.rb +25 -0
  51. data/lib/sbom/cyclone_dx/record/fairness_assessment.rb +22 -0
  52. data/lib/sbom/cyclone_dx/record/formula.rb +29 -0
  53. data/lib/sbom/cyclone_dx/record/graphic.rb +19 -0
  54. data/lib/sbom/cyclone_dx/record/graphics_collection.rb +19 -0
  55. data/lib/sbom/cyclone_dx/record/hash_data.rb +18 -0
  56. data/lib/sbom/cyclone_dx/record/identifiable_action.rb +21 -0
  57. data/lib/sbom/cyclone_dx/record/input.rb +34 -0
  58. data/lib/sbom/cyclone_dx/record/input_output_ml_parameter.rb +17 -0
  59. data/lib/sbom/cyclone_dx/record/issue.rb +36 -0
  60. data/lib/sbom/cyclone_dx/record/license.rb +90 -0
  61. data/lib/sbom/cyclone_dx/record/license_choice.rb +35 -0
  62. data/lib/sbom/cyclone_dx/record/metadata.rb +55 -0
  63. data/lib/sbom/cyclone_dx/record/model_card.rb +89 -0
  64. data/lib/sbom/cyclone_dx/record/note.rb +20 -0
  65. data/lib/sbom/cyclone_dx/record/organizational_contact.rb +26 -0
  66. data/lib/sbom/cyclone_dx/record/organizational_entity.rb +28 -0
  67. data/lib/sbom/cyclone_dx/record/output.rb +34 -0
  68. data/lib/sbom/cyclone_dx/record/parameter.rb +20 -0
  69. data/lib/sbom/cyclone_dx/record/patch.rb +23 -0
  70. data/lib/sbom/cyclone_dx/record/performance_metric.rb +30 -0
  71. data/lib/sbom/cyclone_dx/record/postal_address.rb +34 -0
  72. data/lib/sbom/cyclone_dx/record/property.rb +18 -0
  73. data/lib/sbom/cyclone_dx/record/rating.rb +27 -0
  74. data/lib/sbom/cyclone_dx/record/release_notes.rb +44 -0
  75. data/lib/sbom/cyclone_dx/record/resource_reference_choice.rb +22 -0
  76. data/lib/sbom/cyclone_dx/record/risk.rb +18 -0
  77. data/lib/sbom/cyclone_dx/record/root.rb +63 -0
  78. data/lib/sbom/cyclone_dx/record/secured_by.rb +20 -0
  79. data/lib/sbom/cyclone_dx/record/service.rb +54 -0
  80. data/lib/sbom/cyclone_dx/record/service_data.rb +32 -0
  81. data/lib/sbom/cyclone_dx/record/signature.rb +85 -0
  82. data/lib/sbom/cyclone_dx/record/standard.rb +72 -0
  83. data/lib/sbom/cyclone_dx/record/step.rb +24 -0
  84. data/lib/sbom/cyclone_dx/record/swid.rb +29 -0
  85. data/lib/sbom/cyclone_dx/record/task.rb +56 -0
  86. data/lib/sbom/cyclone_dx/record/tools.rb +20 -0
  87. data/lib/sbom/cyclone_dx/record/trigger.rb +48 -0
  88. data/lib/sbom/cyclone_dx/record/version.rb +24 -0
  89. data/lib/sbom/cyclone_dx/record/volume.rb +33 -0
  90. data/lib/sbom/cyclone_dx/record/vulnerability.rb +119 -0
  91. data/lib/sbom/cyclone_dx/record/vulnerability_source.rb +20 -0
  92. data/lib/sbom/cyclone_dx/record/workflow.rb +59 -0
  93. data/lib/sbom/cyclone_dx/record/workspace.rb +45 -0
  94. data/lib/sbom/cyclone_dx/record.rb +12 -0
  95. data/lib/sbom/cyclone_dx/validator/array_validator.rb +66 -0
  96. data/lib/sbom/cyclone_dx/validator/base_validator.rb +43 -0
  97. data/lib/sbom/cyclone_dx/validator/boolean_validator.rb +16 -0
  98. data/lib/sbom/cyclone_dx/validator/date_time_validator.rb +29 -0
  99. data/lib/sbom/cyclone_dx/validator/email_address_validator.rb +31 -0
  100. data/lib/sbom/cyclone_dx/validator/float_validator.rb +30 -0
  101. data/lib/sbom/cyclone_dx/validator/integer_validator.rb +30 -0
  102. data/lib/sbom/cyclone_dx/validator/record_validator.rb +26 -0
  103. data/lib/sbom/cyclone_dx/validator/string_validator.rb +33 -0
  104. data/lib/sbom/cyclone_dx/validator/union_validator.rb +39 -0
  105. data/lib/sbom/cyclone_dx/validator/uri_validator.rb +32 -0
  106. data/lib/sbom/cyclone_dx/validator.rb +32 -0
  107. data/lib/sbom/cyclone_dx/version.rb +7 -0
  108. data/lib/sbom/cyclone_dx.rb +39 -0
  109. data/rbs_collection.lock.yaml +288 -0
  110. data/rbs_collection.yaml +31 -0
  111. data/sbom-cyclone_dx.gemspec +32 -0
  112. data/sig/email_address_extension.rbs +14 -0
  113. data/sig/sbom/cyclone_dx/enum.rbs +93 -0
  114. data/sig/sbom/cyclone_dx/field.rbs +434 -0
  115. data/sig/sbom/cyclone_dx/pattern.rbs +24 -0
  116. data/sig/sbom/cyclone_dx/record/advisory.rbs +19 -0
  117. data/sig/sbom/cyclone_dx/record/annotation.rbs +63 -0
  118. data/sig/sbom/cyclone_dx/record/attachment.rbs +24 -0
  119. data/sig/sbom/cyclone_dx/record/base.rbs +62 -0
  120. data/sig/sbom/cyclone_dx/record/cipher_suite.rbs +24 -0
  121. data/sig/sbom/cyclone_dx/record/co2_measure.rbs +14 -0
  122. data/sig/sbom/cyclone_dx/record/command.rbs +19 -0
  123. data/sig/sbom/cyclone_dx/record/commit.rbs +34 -0
  124. data/sig/sbom/cyclone_dx/record/component.rbs +203 -0
  125. data/sig/sbom/cyclone_dx/record/component_data.rbs +73 -0
  126. data/sig/sbom/cyclone_dx/record/component_evidence.rbs +115 -0
  127. data/sig/sbom/cyclone_dx/record/component_identity_evidence.rbs +53 -0
  128. data/sig/sbom/cyclone_dx/record/composition.rbs +39 -0
  129. data/sig/sbom/cyclone_dx/record/condition.rbs +24 -0
  130. data/sig/sbom/cyclone_dx/record/copyright.rbs +14 -0
  131. data/sig/sbom/cyclone_dx/record/crypto_properties.rbs +268 -0
  132. data/sig/sbom/cyclone_dx/record/data_governance.rbs +24 -0
  133. data/sig/sbom/cyclone_dx/record/data_governance_responsible_party.rbs +19 -0
  134. data/sig/sbom/cyclone_dx/record/declarations.rbs +352 -0
  135. data/sig/sbom/cyclone_dx/record/definitions.rbs +14 -0
  136. data/sig/sbom/cyclone_dx/record/dependency.rbs +24 -0
  137. data/sig/sbom/cyclone_dx/record/diff.rbs +19 -0
  138. data/sig/sbom/cyclone_dx/record/energy_consumption.rbs +39 -0
  139. data/sig/sbom/cyclone_dx/record/energy_measure.rbs +14 -0
  140. data/sig/sbom/cyclone_dx/record/energy_provider.rbs +39 -0
  141. data/sig/sbom/cyclone_dx/record/environmental_consideration.rbs +19 -0
  142. data/sig/sbom/cyclone_dx/record/event.rbs +44 -0
  143. data/sig/sbom/cyclone_dx/record/external_reference.rbs +29 -0
  144. data/sig/sbom/cyclone_dx/record/fairness_assessment.rbs +29 -0
  145. data/sig/sbom/cyclone_dx/record/formula.rbs +34 -0
  146. data/sig/sbom/cyclone_dx/record/graphic.rbs +19 -0
  147. data/sig/sbom/cyclone_dx/record/graphics_collection.rbs +19 -0
  148. data/sig/sbom/cyclone_dx/record/hash_data.rbs +19 -0
  149. data/sig/sbom/cyclone_dx/record/identifiable_action.rbs +24 -0
  150. data/sig/sbom/cyclone_dx/record/input.rbs +44 -0
  151. data/sig/sbom/cyclone_dx/record/input_output_ml_parameter.rbs +14 -0
  152. data/sig/sbom/cyclone_dx/record/issue.rbs +53 -0
  153. data/sig/sbom/cyclone_dx/record/license.rbs +134 -0
  154. data/sig/sbom/cyclone_dx/record/license_choice.rbs +39 -0
  155. data/sig/sbom/cyclone_dx/record/metadata.rbs +82 -0
  156. data/sig/sbom/cyclone_dx/record/model_card.rbs +143 -0
  157. data/sig/sbom/cyclone_dx/record/note.rbs +19 -0
  158. data/sig/sbom/cyclone_dx/record/organizational_contact.rbs +29 -0
  159. data/sig/sbom/cyclone_dx/record/organizational_entity.rbs +34 -0
  160. data/sig/sbom/cyclone_dx/record/output.rbs +44 -0
  161. data/sig/sbom/cyclone_dx/record/parameter.rbs +24 -0
  162. data/sig/sbom/cyclone_dx/record/patch.rbs +24 -0
  163. data/sig/sbom/cyclone_dx/record/performance_metric.rbs +43 -0
  164. data/sig/sbom/cyclone_dx/record/postal_address.rbs +44 -0
  165. data/sig/sbom/cyclone_dx/record/property.rbs +19 -0
  166. data/sig/sbom/cyclone_dx/record/rating.rbs +39 -0
  167. data/sig/sbom/cyclone_dx/record/release_notes.rbs +64 -0
  168. data/sig/sbom/cyclone_dx/record/resource_reference_choice.rbs +19 -0
  169. data/sig/sbom/cyclone_dx/record/risk.rbs +19 -0
  170. data/sig/sbom/cyclone_dx/record/root.rbs +84 -0
  171. data/sig/sbom/cyclone_dx/record/secured_by.rbs +19 -0
  172. data/sig/sbom/cyclone_dx/record/service.rbs +99 -0
  173. data/sig/sbom/cyclone_dx/record/service_data.rbs +44 -0
  174. data/sig/sbom/cyclone_dx/record/signature.rbs +130 -0
  175. data/sig/sbom/cyclone_dx/record/standard.rbs +132 -0
  176. data/sig/sbom/cyclone_dx/record/step.rbs +29 -0
  177. data/sig/sbom/cyclone_dx/record/swid.rbs +44 -0
  178. data/sig/sbom/cyclone_dx/record/task.rbs +84 -0
  179. data/sig/sbom/cyclone_dx/record/tools.rbs +19 -0
  180. data/sig/sbom/cyclone_dx/record/trigger.rbs +69 -0
  181. data/sig/sbom/cyclone_dx/record/version.rbs +24 -0
  182. data/sig/sbom/cyclone_dx/record/volume.rbs +49 -0
  183. data/sig/sbom/cyclone_dx/record/vulnerability.rbs +209 -0
  184. data/sig/sbom/cyclone_dx/record/vulnerability_source.rbs +19 -0
  185. data/sig/sbom/cyclone_dx/record/workflow.rbs +94 -0
  186. data/sig/sbom/cyclone_dx/record/workspace.rbs +69 -0
  187. data/sig/sbom/cyclone_dx/record.rbs +161 -0
  188. data/sig/sbom/cyclone_dx/type.rbs +16 -0
  189. data/sig/sbom/cyclone_dx/validator/array_validator.rbs +31 -0
  190. data/sig/sbom/cyclone_dx/validator/base_validator.rbs +21 -0
  191. data/sig/sbom/cyclone_dx/validator/boolean_validator.rbs +9 -0
  192. data/sig/sbom/cyclone_dx/validator/date_time_validator.rbs +10 -0
  193. data/sig/sbom/cyclone_dx/validator/email_address_validator.rbs +10 -0
  194. data/sig/sbom/cyclone_dx/validator/float_validator.rbs +12 -0
  195. data/sig/sbom/cyclone_dx/validator/integer_validator.rbs +12 -0
  196. data/sig/sbom/cyclone_dx/validator/record_validator.rbs +12 -0
  197. data/sig/sbom/cyclone_dx/validator/string_validator.rbs +14 -0
  198. data/sig/sbom/cyclone_dx/validator/union_validator.rbs +24 -0
  199. data/sig/sbom/cyclone_dx/validator/uri_validator.rbs +10 -0
  200. data/sig/sbom/cyclone_dx/validator.rbs +66 -0
  201. data/sig/sbom/cyclone_dx.rbs +13 -0
  202. data/sig/types.rbs +45 -0
  203. data/spec/email_address_extension_spec.rb +27 -0
  204. data/spec/factories/factory_helper.rb +78 -0
  205. data/spec/factories/record/advisory_factory.rb +11 -0
  206. data/spec/factories/record/annotation_factory.rb +63 -0
  207. data/spec/factories/record/attachment_factory.rb +9 -0
  208. data/spec/factories/record/cipher_suite_factory.rb +26 -0
  209. data/spec/factories/record/co2_measure_factory.rb +9 -0
  210. data/spec/factories/record/command_factory.rb +10 -0
  211. data/spec/factories/record/commit_factory.rb +13 -0
  212. data/spec/factories/record/component_data_factory.rb +28 -0
  213. data/spec/factories/record/component_evidence_factory.rb +44 -0
  214. data/spec/factories/record/component_factory.rb +102 -0
  215. data/spec/factories/record/component_identity_evidence_factory.rb +25 -0
  216. data/spec/factories/record/composition_factory.rb +20 -0
  217. data/spec/factories/record/condition_factory.rb +11 -0
  218. data/spec/factories/record/copyright_factory.rb +9 -0
  219. data/spec/factories/record/crypto_properties_factory.rb +191 -0
  220. data/spec/factories/record/data_governance_factory.rb +11 -0
  221. data/spec/factories/record/data_governance_responsible_party_factory.rb +31 -0
  222. data/spec/factories/record/declarations_factory.rb +145 -0
  223. data/spec/factories/record/definitions_factory.rb +9 -0
  224. data/spec/factories/record/dependency_factory.rb +12 -0
  225. data/spec/factories/record/diff_factory.rb +24 -0
  226. data/spec/factories/record/energy_consumption_factory.rb +15 -0
  227. data/spec/factories/record/energy_measure_factory.rb +9 -0
  228. data/spec/factories/record/energy_provider_factory.rb +15 -0
  229. data/spec/factories/record/environmental_consideration_factory.rb +10 -0
  230. data/spec/factories/record/event_factory.rb +15 -0
  231. data/spec/factories/record/external_reference_factory.rb +13 -0
  232. data/spec/factories/record/fairness_assessment_factory.rb +12 -0
  233. data/spec/factories/record/formula_factory.rb +13 -0
  234. data/spec/factories/record/graphic_factory.rb +10 -0
  235. data/spec/factories/record/graphics_collection_factory.rb +10 -0
  236. data/spec/factories/record/hash_data_factory.rb +10 -0
  237. data/spec/factories/record/identifiable_action_factory.rb +11 -0
  238. data/spec/factories/record/input_factory.rb +36 -0
  239. data/spec/factories/record/input_output_ml_parameter_factory.rb +9 -0
  240. data/spec/factories/record/issue_factory.rb +22 -0
  241. data/spec/factories/record/license_choice_factory.rb +23 -0
  242. data/spec/factories/record/license_factory.rb +99 -0
  243. data/spec/factories/record/metadata_factory.rb +38 -0
  244. data/spec/factories/record/model_card_factory.rb +59 -0
  245. data/spec/factories/record/note_factory.rb +11 -0
  246. data/spec/factories/record/organizational_contact_factory.rb +12 -0
  247. data/spec/factories/record/organizational_entity_factory.rb +13 -0
  248. data/spec/factories/record/output_factory.rb +32 -0
  249. data/spec/factories/record/parameter_factory.rb +11 -0
  250. data/spec/factories/record/patch_factory.rb +12 -0
  251. data/spec/factories/record/performance_metric_factory.rb +20 -0
  252. data/spec/factories/record/postal_address_factory.rb +14 -0
  253. data/spec/factories/record/property_factory.rb +11 -0
  254. data/spec/factories/record/rating_factory.rb +14 -0
  255. data/spec/factories/record/release_notes_factory.rb +20 -0
  256. data/spec/factories/record/resource_reference_choice_factory.rb +27 -0
  257. data/spec/factories/record/risk_factory.rb +10 -0
  258. data/spec/factories/record/root_factory.rb +23 -0
  259. data/spec/factories/record/secured_by_factory.rb +10 -0
  260. data/spec/factories/record/service_data_factory.rb +16 -0
  261. data/spec/factories/record/service_factory.rb +27 -0
  262. data/spec/factories/record/signature_factory.rb +50 -0
  263. data/spec/factories/record/standard_factory.rb +37 -0
  264. data/spec/factories/record/step_factory.rb +12 -0
  265. data/spec/factories/record/swid_factory.rb +16 -0
  266. data/spec/factories/record/task_factory.rb +24 -0
  267. data/spec/factories/record/tools_factory.rb +10 -0
  268. data/spec/factories/record/trigger_factory.rb +21 -0
  269. data/spec/factories/record/version_factory.rb +19 -0
  270. data/spec/factories/record/volume_factory.rb +16 -0
  271. data/spec/factories/record/vulnerability_factory.rb +70 -0
  272. data/spec/factories/record/vulnerability_source_factory.rb +10 -0
  273. data/spec/factories/record/workflow_factory.rb +26 -0
  274. data/spec/factories/record/workspace_factory.rb +21 -0
  275. data/spec/factories/record_factory.rb +159 -0
  276. data/spec/fixtures/cipher_info.yml +948 -0
  277. data/spec/fixtures/purl_data.yml +0 -0
  278. data/spec/sbom/cyclone_dx/enum_spec.rb +30 -0
  279. data/spec/sbom/cyclone_dx/field_spec.rb +104 -0
  280. data/spec/sbom/cyclone_dx/pattern_spec.rb +18 -0
  281. data/spec/sbom/cyclone_dx/record/advisory_spec.rb +14 -0
  282. data/spec/sbom/cyclone_dx/record/annotation_spec.rb +31 -0
  283. data/spec/sbom/cyclone_dx/record/attachment_spec.rb +14 -0
  284. data/spec/sbom/cyclone_dx/record/base_spec.rb +363 -0
  285. data/spec/sbom/cyclone_dx/record/cipher_suite_spec.rb +14 -0
  286. data/spec/sbom/cyclone_dx/record/co2_measure_spec.rb +14 -0
  287. data/spec/sbom/cyclone_dx/record/command_spec.rb +14 -0
  288. data/spec/sbom/cyclone_dx/record/commit_spec.rb +14 -0
  289. data/spec/sbom/cyclone_dx/record/component_data_spec.rb +14 -0
  290. data/spec/sbom/cyclone_dx/record/component_evidence_spec.rb +14 -0
  291. data/spec/sbom/cyclone_dx/record/component_identity_evidence_spec.rb +14 -0
  292. data/spec/sbom/cyclone_dx/record/component_spec.rb +14 -0
  293. data/spec/sbom/cyclone_dx/record/composition_spec.rb +14 -0
  294. data/spec/sbom/cyclone_dx/record/condition_spec.rb +14 -0
  295. data/spec/sbom/cyclone_dx/record/copyright_spec.rb +14 -0
  296. data/spec/sbom/cyclone_dx/record/crypto_properties_spec.rb +14 -0
  297. data/spec/sbom/cyclone_dx/record/data_governance_responsible_party_spec.rb +19 -0
  298. data/spec/sbom/cyclone_dx/record/data_governance_spec.rb +14 -0
  299. data/spec/sbom/cyclone_dx/record/declarations_spec.rb +14 -0
  300. data/spec/sbom/cyclone_dx/record/definitions_spec.rb +14 -0
  301. data/spec/sbom/cyclone_dx/record/dependency_spec.rb +14 -0
  302. data/spec/sbom/cyclone_dx/record/diff_spec.rb +14 -0
  303. data/spec/sbom/cyclone_dx/record/energy_consumption_spec.rb +14 -0
  304. data/spec/sbom/cyclone_dx/record/energy_measure_spec.rb +14 -0
  305. data/spec/sbom/cyclone_dx/record/energy_provider_spec.rb +14 -0
  306. data/spec/sbom/cyclone_dx/record/environmental_consideration_spec.rb +14 -0
  307. data/spec/sbom/cyclone_dx/record/event_spec.rb +14 -0
  308. data/spec/sbom/cyclone_dx/record/external_reference_spec.rb +14 -0
  309. data/spec/sbom/cyclone_dx/record/fairness_assessment_spec.rb +14 -0
  310. data/spec/sbom/cyclone_dx/record/formula_spec.rb +14 -0
  311. data/spec/sbom/cyclone_dx/record/graphic_spec.rb +14 -0
  312. data/spec/sbom/cyclone_dx/record/graphics_collection_spec.rb +14 -0
  313. data/spec/sbom/cyclone_dx/record/hash_data_spec.rb +14 -0
  314. data/spec/sbom/cyclone_dx/record/identifiable_action_spec.rb +14 -0
  315. data/spec/sbom/cyclone_dx/record/input_output_ml_parameter_spec.rb +14 -0
  316. data/spec/sbom/cyclone_dx/record/input_spec.rb +14 -0
  317. data/spec/sbom/cyclone_dx/record/issue_spec.rb +14 -0
  318. data/spec/sbom/cyclone_dx/record/license_choice_spec.rb +26 -0
  319. data/spec/sbom/cyclone_dx/record/license_spec.rb +14 -0
  320. data/spec/sbom/cyclone_dx/record/metadata_spec.rb +14 -0
  321. data/spec/sbom/cyclone_dx/record/model_card_spec.rb +14 -0
  322. data/spec/sbom/cyclone_dx/record/note_spec.rb +14 -0
  323. data/spec/sbom/cyclone_dx/record/organizational_contact_spec.rb +14 -0
  324. data/spec/sbom/cyclone_dx/record/organizational_entity_spec.rb +14 -0
  325. data/spec/sbom/cyclone_dx/record/output_spec.rb +14 -0
  326. data/spec/sbom/cyclone_dx/record/parameter_spec.rb +14 -0
  327. data/spec/sbom/cyclone_dx/record/patch_spec.rb +14 -0
  328. data/spec/sbom/cyclone_dx/record/performance_metric_spec.rb +14 -0
  329. data/spec/sbom/cyclone_dx/record/postal_address_spec.rb +14 -0
  330. data/spec/sbom/cyclone_dx/record/property_spec.rb +14 -0
  331. data/spec/sbom/cyclone_dx/record/rating_spec.rb +14 -0
  332. data/spec/sbom/cyclone_dx/record/release_notes_spec.rb +14 -0
  333. data/spec/sbom/cyclone_dx/record/resource_reference_choice_spec.rb +14 -0
  334. data/spec/sbom/cyclone_dx/record/risk_spec.rb +14 -0
  335. data/spec/sbom/cyclone_dx/record/root_spec.rb +14 -0
  336. data/spec/sbom/cyclone_dx/record/secured_by_spec.rb +14 -0
  337. data/spec/sbom/cyclone_dx/record/service_data_spec.rb +14 -0
  338. data/spec/sbom/cyclone_dx/record/service_spec.rb +14 -0
  339. data/spec/sbom/cyclone_dx/record/signature_spec.rb +26 -0
  340. data/spec/sbom/cyclone_dx/record/standard_spec.rb +14 -0
  341. data/spec/sbom/cyclone_dx/record/step_spec.rb +14 -0
  342. data/spec/sbom/cyclone_dx/record/swid_spec.rb +14 -0
  343. data/spec/sbom/cyclone_dx/record/task_spec.rb +14 -0
  344. data/spec/sbom/cyclone_dx/record/tools_spec.rb +14 -0
  345. data/spec/sbom/cyclone_dx/record/trigger_spec.rb +14 -0
  346. data/spec/sbom/cyclone_dx/record/version_spec.rb +14 -0
  347. data/spec/sbom/cyclone_dx/record/volume_spec.rb +14 -0
  348. data/spec/sbom/cyclone_dx/record/vulnerability_source_spec.rb +14 -0
  349. data/spec/sbom/cyclone_dx/record/vulnerability_spec.rb +14 -0
  350. data/spec/sbom/cyclone_dx/record/workflow_spec.rb +14 -0
  351. data/spec/sbom/cyclone_dx/record/workspace_spec.rb +14 -0
  352. data/spec/sbom/cyclone_dx/record_spec.rb +7 -0
  353. data/spec/sbom/cyclone_dx/validator/array_validator_spec.rb +184 -0
  354. data/spec/sbom/cyclone_dx/validator/base_validator_spec.rb +71 -0
  355. data/spec/sbom/cyclone_dx/validator/boolean_validator_spec.rb +26 -0
  356. data/spec/sbom/cyclone_dx/validator/date_time_validator_spec.rb +28 -0
  357. data/spec/sbom/cyclone_dx/validator/email_address_validator_spec.rb +23 -0
  358. data/spec/sbom/cyclone_dx/validator/float_validator_spec.rb +71 -0
  359. data/spec/sbom/cyclone_dx/validator/integer_validator_spec.rb +71 -0
  360. data/spec/sbom/cyclone_dx/validator/record_validator_spec.rb +35 -0
  361. data/spec/sbom/cyclone_dx/validator/string_validator_spec.rb +94 -0
  362. data/spec/sbom/cyclone_dx/validator/union_validator_spec.rb +65 -0
  363. data/spec/sbom/cyclone_dx/validator/uri_validator_spec.rb +21 -0
  364. data/spec/sbom/cyclone_dx/validator_spec.rb +38 -0
  365. data/spec/sbom/cyclone_dx/version_spec.rb +9 -0
  366. data/spec/sbom/cyclone_dx_spec.rb +7 -0
  367. data/spec/spec_helper.rb +39 -0
  368. metadata +377 -6
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+ require_relative "component"
5
+ require_relative "service"
6
+
7
+ # Tools - The tool(s) used to identify, confirm, or score the vulnerability.
8
+ module SBOM
9
+ module CycloneDX
10
+ module Record
11
+ # Schema name: Tools
12
+ class Tools < Base
13
+ # Components - A list of software and hardware components used as tools.
14
+ prop :components, :array, items: Component, unique: true
15
+ # Services - A list of services used as tools. This may include microservices, function-as-a-service, and other types of network or intra-process services.
16
+ prop :services, :array, items: Service, unique: true
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../enum"
4
+ require_relative "../pattern"
5
+ require_relative "base"
6
+ require_relative "condition"
7
+ require_relative "event"
8
+ require_relative "input"
9
+ require_relative "output"
10
+ require_relative "property"
11
+ require_relative "resource_reference_choice"
12
+
13
+ # Trigger - Represents a resource that can conditionally activate (or fire) tasks based upon associated events and their data.
14
+ module SBOM
15
+ module CycloneDX
16
+ module Record
17
+ # Schema name: Trigger
18
+ class Trigger < Base
19
+ # BOM Reference - An optional identifier which can be used to reference the trigger elsewhere in the BOM. Every bom-ref must be unique within the BOM. Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid conflicts with BOM-Links.
20
+ prop :bom_ref, :string, pattern: Pattern::REF_LINK, json_name: "bom-ref", required: true
21
+ # Unique Identifier (UID) - The unique identifier for the resource instance within its deployment context.
22
+ prop :uid, :string, required: true
23
+ # Name - The name of the resource instance.
24
+ prop :name, :string
25
+ # Description - A description of the resource instance.
26
+ prop :description, :string
27
+ # Resource references - References to component or service resources that are used to realize the resource instance.
28
+ prop :resource_references, :array, items: ResourceReferenceChoice, unique: true
29
+ # Type - The source type of event which caused the trigger to fire.
30
+ prop :type, :string, enum: Enum::TRIGGER_TYPE, required: true
31
+ # Event - The event data that caused the associated trigger to activate.
32
+ prop :event, Event
33
+ # Conditions - A list of conditions used to determine if a trigger should be activated.
34
+ prop :conditions, :array, items: Condition, unique: true
35
+ # Time activated - The date and time (timestamp) when the trigger was activated.
36
+ prop :time_activated, :date_time
37
+ # Inputs - Represents resources and data brought into a task at runtime by executor or task commands
38
+ # Example: "a `configuration` file which was declared as a local `component` or `externalReference`"
39
+ prop :inputs, :array, items: Input, unique: true
40
+ # Outputs - Represents resources and data output from a task at runtime by executor or task commands
41
+ # Examples: "a log file or metrics data produced by the task"
42
+ prop :outputs, :array, items: Output, unique: true
43
+ # Properties - Provides the ability to document properties in a name-value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. Unlike key-value stores, properties support duplicate names, each potentially having different values. Property names of interest to the general public are encouraged to be registered in the [CycloneDX Property Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy). Formal registration is optional.
44
+ prop :properties, :array, items: Property
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../enum"
4
+ require_relative "base"
5
+
6
+ # Version
7
+ module SBOM
8
+ module CycloneDX
9
+ module Record
10
+ # Schema name: Version
11
+ class Version < Base
12
+ # Version - A single version of a component or service.
13
+ prop :version, :string, max_length: 1024
14
+ # Version Range - A version range specified in Package URL Version Range syntax (vers) which is defined at https://github.com/package-url/purl-spec/blob/master/VERSION-RANGE-SPEC.rst
15
+ # TODO: Validate syntax
16
+ prop :range, :string, max_length: 4096, min_length: 1
17
+ # Status - The vulnerability status for the version or range of versions.
18
+ prop :status, :string, enum: Enum::AFFECTED_STATUS
19
+
20
+ validate :version, :range, presence: :any
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../enum"
4
+ require_relative "base"
5
+ require_relative "property"
6
+
7
+ # Volume - An identifiable, logical unit of data storage tied to a physical device.
8
+ module SBOM
9
+ module CycloneDX
10
+ module Record
11
+ # Schema name: Volume
12
+ class Volume < Base
13
+ # Unique Identifier (UID) - The unique identifier for the volume instance within its deployment context.
14
+ prop :uid, :string
15
+ # Name - The name of the volume instance
16
+ prop :name, :string
17
+ # Mode - The mode for the volume instance.
18
+ prop :mode, :string, enum: Enum::VOLUME_MODE, default: "filesystem"
19
+ # Path - The underlying path created from the actual volume.
20
+ prop :path, :string
21
+ # Size allocated - The allocated size of the volume accessible to the associated workspace. This should include the scalar size as well as IEC standard unit in either decimal or binary form.
22
+ # Examples: "10GB", "2Ti", "1Pi"
23
+ prop :size_allocated, :string
24
+ # Persistent - Indicates if the volume persists beyond the life of the resource it is associated with.
25
+ prop :persistent, :boolean
26
+ # Remote - Indicates if the volume is remotely (i.e., network) attached.
27
+ prop :remote, :boolean
28
+ # Properties - Provides the ability to document properties in a name-value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. Unlike key-value stores, properties support duplicate names, each potentially having different values. Property names of interest to the general public are encouraged to be registered in the [CycloneDX Property Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy). Formal registration is optional.
29
+ prop :properties, :array, items: Property
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../enum"
4
+ require_relative "../pattern"
5
+ require_relative "base"
6
+ require_relative "advisory"
7
+ require_relative "attachment"
8
+ require_relative "organizational_contact"
9
+ require_relative "organizational_entity"
10
+ require_relative "property"
11
+ require_relative "rating"
12
+ require_relative "tools"
13
+ require_relative "version"
14
+ require_relative "vulnerability_source"
15
+
16
+ # Vulnerability - Defines a weakness in a component or service that could be exploited or triggered by a threat source.
17
+ module SBOM
18
+ module CycloneDX
19
+ module Record
20
+ # Schema name: Vulnerability
21
+ class Vulnerability < Base
22
+ # Schema name: Analysis
23
+ class Analysis < Base
24
+ prop :state, :string, enum: Enum::IMPACT_ANALYSIS_STATE
25
+ prop :justification, :string, enum: Enum::IMPACT_ANALYSIS_JUSTIFICATION
26
+ # Response - A response to the vulnerability by the manufacturer, supplier, or project responsible for the affected component or service. More than one response is allowed. Responses are strongly encouraged for vulnerabilities where the analysis state is exploitable.
27
+ prop :response, :array, items: [:string, enum: Enum::RESPONSE]
28
+ # Detail - Detailed description of the impact including methods used during assessment. If a vulnerability is not exploitable, this field should include specific details on why the component or service is not impacted by this vulnerability.
29
+ prop :detail, :string
30
+ # First Issued - The date and time (timestamp) when the analysis was first issued.
31
+ prop :first_issued, :date_time
32
+ # Last Updated - The date and time (timestamp) when the analysis was last updated.
33
+ prop :last_updated, :date_time
34
+ end
35
+
36
+ # Schema name: Affects
37
+ class Affects < Base
38
+ # Reference - References a component or service by the objects bom-ref
39
+ prop :ref, :string, pattern: Pattern::REF_OR_CDX_URN, required: true
40
+ # Versions - Zero or more individual versions or range of versions.
41
+ prop :versions, :array, items: Version
42
+ end
43
+
44
+ # Schema name: Credits
45
+ class Credits < Base
46
+ # Organizations - The organizations credited with vulnerability discovery.
47
+ prop :organizations, :array, items: OrganizationalEntity
48
+ # Individuals - The individuals, not associated with organizations, that are credited with vulnerability discovery.
49
+ prop :individuals, :array, items: OrganizationalContact
50
+ end
51
+
52
+ # Schema name: ProofOfConcept
53
+ class ProofOfConcept < Base
54
+ # Steps to Reproduce - Precise steps to reproduce the vulnerability.
55
+ prop :reproduction_steps, :string
56
+ # Environment - A description of the environment in which reproduction was possible.
57
+ prop :environment, :string
58
+ # Supporting Material - Supporting material that helps in reproducing or understanding how reproduction is possible. This may include screenshots, payloads, and PoC exploit code.
59
+ prop :supporting_material, :array, items: Attachment
60
+ end
61
+
62
+ # Schema name: Reference
63
+ class Reference < Base
64
+ # ID - An identifier that uniquely identifies the vulnerability.
65
+ # Examples: "CVE-2021-39182", "GHSA-35m5-8cvj-8783", "SNYK-PYTHON-ENROCRYPT-1912876"
66
+ prop :id, :string, required: true
67
+ # The source that published the vulnerability.
68
+ prop :source, VulnerabilitySource, required: true
69
+ end
70
+
71
+ # BOM Reference - An optional identifier which can be used to reference the vulnerability elsewhere in the BOM. Every bom-ref must be unique within the BOM. Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid conflicts with BOM-Links.
72
+ prop :bom_ref, :string, pattern: Pattern::REF_LINK, json_name: "bom-ref"
73
+ # ID - The identifier that uniquely identifies the vulnerability.
74
+ # Examples: "CVE-2021-39182", "GHSA-35m5-8cvj-8783", "SNYK-PYTHON-ENROCRYPT-1912876"
75
+ prop :id, :string
76
+ # The source that published the vulnerability.
77
+ prop :source, VulnerabilitySource
78
+ # References - Zero or more pointers to vulnerabilities that are the equivalent of the vulnerability specified. Often times, the same vulnerability may exist in multiple sources of vulnerability intelligence, but have different identifiers. References provide a way to correlate vulnerabilities across multiple sources of vulnerability intelligence.
79
+ prop :references, :array, items: Reference
80
+ # Ratings - List of vulnerability ratings
81
+ prop :ratings, :array, items: Rating
82
+ # CWEs - List of Common Weaknesses Enumerations (CWEs) codes that describes this vulnerability.
83
+ # Contains integer representations of Common Weaknesses Enumerations (CWE). For example 399 (of https://cwe.mitre.org/data/definitions/399.html)
84
+ # Example: [399]
85
+ prop :cwes, :array, items: [:integer, minimum: 1]
86
+ # Description - A description of the vulnerability as provided by the source.
87
+ prop :description, :string
88
+ # Details - If available, an in-depth description of the vulnerability as provided by the source organization. Details often include information useful in understanding root cause.
89
+ prop :detail, :string
90
+ # Recommendation - Recommendations of how the vulnerability can be remediated or mitigated.
91
+ prop :recommendation, :string
92
+ # Workarounds - A bypass, usually temporary, of the vulnerability that reduces its likelihood and/or impact. Workarounds often involve changes to configuration or deployments.
93
+ prop :workaround, :string
94
+ # Proof of Concept - Evidence used to reproduce the vulnerability.
95
+ prop :proof_of_concept, ProofOfConcept
96
+ # Advisories - Published advisories of the vulnerability if provided.
97
+ prop :advisories, :array, items: Advisory
98
+ # Created - The date and time (timestamp) when the vulnerability record was created in the vulnerability database.
99
+ prop :created, :date_time
100
+ # Published - The date and time (timestamp) when the vulnerability record was first published.
101
+ prop :published, :date_time
102
+ # Updated - The date and time (timestamp) when the vulnerability record was last updated.
103
+ prop :updated, :date_time
104
+ # Rejected - The date and time (timestamp) when the vulnerability record was rejected (if applicable).
105
+ prop :rejected, :date_time
106
+ # Credits - Individuals or organizations credited with the discovery of the vulnerability.
107
+ prop :credits, Credits
108
+ # Tools - The tool(s) used to identify, confirm, or score the vulnerability.
109
+ prop :tools, Tools
110
+ # Impact Analysis - An assessment of the impact and exploitability of the vulnerability.
111
+ prop :analysis, Analysis
112
+ # Affects - The components or services that are affected by the vulnerability.
113
+ prop :affects, :array, items: Affects, unique: true
114
+ # Properties - Provides the ability to document properties in a name-value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. Unlike key-value stores, properties support duplicate names, each potentially having different values. Property names of interest to the general public are encouraged to be registered in the [CycloneDX Property Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy). Formal registration is optional.
115
+ prop :properties, :array, items: Property
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+
5
+ # Source - The source of vulnerability information. This is often the organization that published the vulnerability.
6
+ module SBOM
7
+ module CycloneDX
8
+ module Record
9
+ # Schema name: VulnerabilitySource
10
+ class VulnerabilitySource < Base
11
+ # URL - The url of the vulnerability documentation as provided by the source.
12
+ # Example: "https://nvd.nist.gov/vuln/detail/CVE-2021-39182"
13
+ prop :url, :string # Oddly, the schema does not validate the URL format here
14
+ # Name - The name of the source.
15
+ # Examples: "NVD", "National Vulnerability Database", "OSS Index", "VulnDB", "GitHub Advisories"
16
+ prop :name, :string
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../enum"
4
+ require_relative "../pattern"
5
+ require_relative "base"
6
+ require_relative "dependency"
7
+ require_relative "input"
8
+ require_relative "output"
9
+ require_relative "property"
10
+ require_relative "resource_reference_choice"
11
+ require_relative "step"
12
+ require_relative "task"
13
+ require_relative "trigger"
14
+ require_relative "workspace"
15
+
16
+ # Workflow - A specialized orchestration task.
17
+ module SBOM
18
+ module CycloneDX
19
+ module Record
20
+ # Schema name: Workflow
21
+ class Workflow < Base
22
+ # BOM Reference - An optional identifier which can be used to reference the workflow elsewhere in the BOM. Every bom-ref must be unique within the BOM. Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid conflicts with BOM-Links.
23
+ prop :bom_ref, :string, pattern: Pattern::REF_LINK, json_name: "bom-ref", required: true
24
+ # Unique Identifier (UID) - The unique identifier for the resource instance within its deployment context.
25
+ prop :uid, :string, required: true
26
+ # Name - The name of the resource instance.
27
+ prop :name, :string
28
+ # Description - A description of the resource instance.
29
+ prop :description, :string
30
+ # Resource references - References to component or service resources that are used to realize the resource instance.
31
+ prop :resource_references, :array, items: ResourceReferenceChoice, unique: true
32
+ # Tasks - The tasks that comprise the workflow.
33
+ prop :tasks, :array, items: Task, unique: true
34
+ # Task dependency graph - The graph of dependencies between tasks within the workflow.
35
+ prop :task_dependencies, :array, items: Dependency, unique: true
36
+ # Task types - Indicates the types of activities performed by the set of workflow tasks.
37
+ prop :task_types, :array, items: [:string, enum: Enum::TASK_TYPE], required: true
38
+ # Trigger - The trigger that initiated the task.
39
+ prop :trigger, Trigger
40
+ # Steps - The sequence of steps for the task.
41
+ prop :steps, :array, items: Step, unique: true
42
+ # Inputs - Represents resources and data brought into a task at runtime by executor or task commands
43
+ prop :inputs, :array, items: Input, unique: true
44
+ # Outputs - Represents resources and data output from a task at runtime by executor or task commands
45
+ prop :outputs, :array, items: Output, unique: true
46
+ # Time start - The date and time (timestamp) when the task started.
47
+ prop :time_start, :date_time
48
+ # Time end - The date and time (timestamp) when the task ended.
49
+ prop :time_end, :date_time
50
+ # Workspaces - A set of named filesystem or data resource shareable by workflow tasks.
51
+ prop :workspaces, :array, items: Workspace, unique: true
52
+ # Runtime topology - A graph of the component runtime topology for workflow's instance.
53
+ prop :runtime_topology, :array, items: Dependency, unique: true
54
+ # Properties - Provides the ability to document properties in a name-value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. Unlike key-value stores, properties support duplicate names, each potentially having different values. Property names of interest to the general public are encouraged to be registered in the [CycloneDX Property Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy). Formal registration is optional.
55
+ prop :properties, :array, items: Property
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../enum"
4
+ require_relative "../pattern"
5
+ require_relative "base"
6
+ require_relative "resource_reference_choice"
7
+ require_relative "property"
8
+ require_relative "volume"
9
+
10
+ # Workspace - A named filesystem or data resource shareable by workflow tasks.
11
+ module SBOM
12
+ module CycloneDX
13
+ module Record
14
+ # Schema name: Workspace
15
+ class Workspace < Base
16
+ # BOM Reference - An optional identifier which can be used to reference the workspace elsewhere in the BOM. Every bom-ref must be unique within the BOM. Value SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid conflicts with BOM-Links.
17
+ prop :bom_ref, :string, pattern: Pattern::REF_LINK, json_name: "bom-ref", required: true
18
+ # Unique Identifier (UID) - The unique identifier for the resource instance within its deployment context.
19
+ prop :uid, :string, required: true
20
+ # Name - The name of the resource instance.
21
+ prop :name, :string
22
+ # Aliases - The names for the workspace as referenced by other workflow tasks. Effectively, a name mapping so other tasks can use their own local name in their steps.
23
+ prop :aliases, :array, items: :string
24
+ # Description - A description of the resource instance.
25
+ prop :description, :string
26
+ # Resource references - References to component or service resources that are used to realize the resource instance.
27
+ prop :resource_references, :array, items: ResourceReferenceChoice, unique: true
28
+ # Access mode - Describes the read-write access control for the workspace relative to the owning resource instance.
29
+ prop :access_mode, :string, enum: Enum::ACCESS_MODE
30
+ # Mount path - A path to a location on disk where the workspace will be available to the associated task's steps.
31
+ prop :mount_path, :string
32
+ # Managed data type - The name of a domain-specific data type the workspace represents.
33
+ # Examples: "ConfigMap", "Secret"
34
+ prop :managed_data_type, :string
35
+ # Volume request - Identifies the reference to the request for a specific volume type and parameters.
36
+ # Example: "a kubernetes Persistent Volume Claim (PVC) name"
37
+ prop :volume_request, :string
38
+ # Volume - Information about the actual volume instance allocated to the workspace.
39
+ prop :volume, Volume
40
+ # Properties - Provides the ability to document properties in a name-value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. Unlike key-value stores, properties support duplicate names, each potentially having different values. Property names of interest to the general public are encouraged to be registered in the [CycloneDX Property Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy). Formal registration is optional.
41
+ prop :properties, :array, items: Property
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir[File.join(__dir__ || ".", "record", "*.rb")].each do |file|
4
+ require_relative file
5
+ end
6
+
7
+ module SBOM
8
+ module CycloneDX
9
+ module Record
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative("base_validator")
4
+ require_relative("record_validator")
5
+ require_relative("../validator")
6
+
7
+ module SBOM
8
+ module CycloneDX
9
+ # TODO: Add helpful errors
10
+ module Validator
11
+ class ArrayValidator < BaseValidator
12
+ def initialize(items:, unique: false, required: false)
13
+ super(Array, required: required)
14
+
15
+ @unique = unique
16
+ @items_validator =
17
+ case items
18
+ when :array, :boolean, :date_time, :email_address, :float, :integer, :string, :uri
19
+ Validator.for(items, required: true)
20
+ # when Proc
21
+ # proc_validator(items)
22
+ when Array
23
+ Validator.for(items.first, required: true, **items.last)
24
+ when Class
25
+ raise "Unsupported items type: #{items}" unless items < Record::Base
26
+
27
+ RecordValidator.new(type: items, required: true)
28
+ else
29
+ raise ArgumentError, "Unsupported items type: #{items}"
30
+ end
31
+ end
32
+
33
+ def validate(value)
34
+ rv = super
35
+ return rv unless value.is_a?(Array)
36
+
37
+ rv << "Unique array contains non-unique values" if @unique && value.uniq.length != value.length
38
+ value.each { |item| rv += @items_validator.validate(item) }
39
+ rv
40
+ end
41
+
42
+ def raw_types
43
+ @items_validator.raw_types
44
+ end
45
+
46
+ private
47
+
48
+ def validator_method(klass)
49
+ proc { |item| klass.validate(item) } #: ^(untyped) -> Array[String]
50
+ end
51
+
52
+ def proc_validator(validator)
53
+ lambda do |item|
54
+ rv = validator.call(item)
55
+ case rv
56
+ when Array then rv.map(&:to_s)
57
+ when true then []
58
+ when false then ["#{item} is invalid"]
59
+ else [rv.to_s]
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SBOM
4
+ module CycloneDX
5
+ # TODO: Add helpful errors
6
+ module Validator
7
+ class BaseValidator
8
+ MISSING_REQUIRED = "Required property is missing or nil"
9
+ INVALID_TYPE = "Invalid type `%s`, expected: %s"
10
+
11
+ def initialize(*types, required: false)
12
+ raise "Abstract class BaseValidator cannot be instantiated" unless self.class < BaseValidator
13
+
14
+ @types = types
15
+ @required = required
16
+ end
17
+
18
+ def valid?(value)
19
+ validate(value).empty?
20
+ end
21
+
22
+ def validate(value) # rubocop:disable Metrics/CyclomaticComplexity
23
+ errors = [] #: Array[String]
24
+
25
+ errors << MISSING_REQUIRED if required? && value.nil?
26
+ return errors if errors.any?
27
+ return errors if @types.any? { |type| value.is_a?(type) }
28
+ return errors if value.nil? && !required?
29
+
30
+ errors << format(INVALID_TYPE, value.class.name, @types.join(", "))
31
+ end
32
+
33
+ def required?
34
+ @required
35
+ end
36
+
37
+ def raw_types
38
+ @types
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base_validator"
4
+
5
+ module SBOM
6
+ module CycloneDX
7
+ # TODO: Add helpful errors
8
+ module Validator
9
+ class BooleanValidator < BaseValidator
10
+ def initialize(required: false)
11
+ super(TrueClass, FalseClass, required: required)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require_relative "base_validator"
5
+
6
+ module SBOM
7
+ module CycloneDX
8
+ # TODO: Add helpful errors
9
+ module Validator
10
+ class DateTimeValidator < BaseValidator
11
+ def initialize(required: false)
12
+ super(DateTime, Time, String, required: required)
13
+ end
14
+
15
+ def validate(value)
16
+ rv = super
17
+ return rv unless value.is_a?(String)
18
+
19
+ begin
20
+ DateTime.iso8601(value)
21
+ rv
22
+ rescue ArgumentError, TypeError
23
+ rv << "Invalid ISO8601 date-time"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base_validator"
4
+ require_relative("../../../email_address_extension")
5
+
6
+ module SBOM
7
+ module CycloneDX
8
+ # TODO: Add helpful errors
9
+ module Validator
10
+ class EmailAddressValidator < BaseValidator
11
+ def initialize(required: false)
12
+ super(EmailAddress::Address, String, required: required)
13
+ end
14
+
15
+ def validate(value)
16
+ rv = super
17
+ return rv unless value.is_a?(EmailAddress::Address) || value.is_a?(String)
18
+
19
+ begin
20
+ to_validate = value.is_a?(EmailAddress::Address) ? value : EmailAddress::Address.new(value)
21
+ return rv if to_validate.valid?
22
+ rescue NoMethodError
23
+ # Do nothing, all errors handled below
24
+ end
25
+
26
+ rv << "Invalid email address"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base_validator"
4
+
5
+ module SBOM
6
+ module CycloneDX
7
+ # TODO: Add helpful errors
8
+ module Validator
9
+ class FloatValidator < BaseValidator
10
+ def initialize(maximum: nil, minimum: nil, required: false)
11
+ if maximum && minimum && maximum < minimum
12
+ raise ArgumentError, "maximum must be greater than or equal to minimum"
13
+ end
14
+
15
+ super(Float, required: required)
16
+
17
+ @range = (minimum..maximum)
18
+ end
19
+
20
+ def validate(value)
21
+ rv = super
22
+ return rv unless value.is_a?(Float)
23
+
24
+ rv << "Value is not within range" unless @range.cover?(value)
25
+ rv
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base_validator"
4
+
5
+ module SBOM
6
+ module CycloneDX
7
+ # TODO: Add helpful errors
8
+ module Validator
9
+ class IntegerValidator < BaseValidator
10
+ def initialize(maximum: nil, minimum: nil, required: false)
11
+ if maximum && minimum && maximum < minimum
12
+ raise ArgumentError, "maximum must be greater than or equal to minimum"
13
+ end
14
+
15
+ super(Integer, required: required)
16
+
17
+ @range = (minimum..maximum)
18
+ end
19
+
20
+ def validate(value)
21
+ rv = super
22
+ return rv unless value.is_a?(Integer)
23
+
24
+ rv << "Value is not within range" unless @range.cover?(value)
25
+ rv
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end