oscal 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +15 -0
  3. data/.github/workflows/release.yml +24 -0
  4. data/.gitignore +11 -0
  5. data/.gitmodules +3 -0
  6. data/.hound.yml +5 -0
  7. data/.rubocop.yml +10 -0
  8. data/Gemfile +2 -0
  9. data/README.adoc +63 -0
  10. data/bin/console +30 -0
  11. data/bin/setup +8 -0
  12. data/exe/convert2oscalyaml.rb +560 -0
  13. data/lib/oscal/add.rb +25 -0
  14. data/lib/oscal/address.rb +21 -0
  15. data/lib/oscal/address_line.rb +10 -0
  16. data/lib/oscal/alter.rb +21 -0
  17. data/lib/oscal/back_matter.rb +19 -0
  18. data/lib/oscal/base64_object.rb +10 -0
  19. data/lib/oscal/base_class.rb +49 -0
  20. data/lib/oscal/catalog.rb +50 -10
  21. data/lib/oscal/choice.rb +10 -0
  22. data/lib/oscal/citation.rb +21 -0
  23. data/lib/oscal/combine.rb +10 -0
  24. data/lib/oscal/common_utils.rb +35 -0
  25. data/lib/oscal/constraint.rb +19 -0
  26. data/lib/oscal/control.rb +20 -31
  27. data/lib/oscal/custom.rb +21 -0
  28. data/lib/oscal/document_id.rb +10 -0
  29. data/lib/oscal/email_address.rb +10 -0
  30. data/lib/oscal/exclude_control.rb +21 -0
  31. data/lib/oscal/external_id.rb +10 -0
  32. data/lib/oscal/group.rb +26 -35
  33. data/lib/oscal/guideline.rb +10 -0
  34. data/lib/oscal/hash_object.rb +10 -0
  35. data/lib/oscal/import_object.rb +21 -0
  36. data/lib/oscal/include_control.rb +21 -0
  37. data/lib/oscal/insert_control.rb +21 -0
  38. data/lib/oscal/link.rb +10 -0
  39. data/lib/oscal/location.rb +30 -0
  40. data/lib/oscal/location_uuid.rb +10 -0
  41. data/lib/oscal/matching.rb +10 -0
  42. data/lib/oscal/member_of_organization.rb +10 -0
  43. data/lib/oscal/merge.rb +19 -0
  44. data/lib/oscal/metadata_block.rb +28 -14
  45. data/lib/oscal/modify.rb +21 -0
  46. data/lib/oscal/parameter.rb +22 -20
  47. data/lib/oscal/part.rb +13 -22
  48. data/lib/oscal/party.rb +35 -0
  49. data/lib/oscal/party_uuid.rb +10 -0
  50. data/lib/oscal/profile.rb +32 -7
  51. data/lib/oscal/property.rb +3 -25
  52. data/lib/oscal/remove.rb +10 -0
  53. data/lib/oscal/resource.rb +28 -0
  54. data/lib/oscal/responsible_party.rb +23 -0
  55. data/lib/oscal/revision.rb +22 -0
  56. data/lib/oscal/rlink.rb +19 -0
  57. data/lib/oscal/role.rb +21 -0
  58. data/lib/oscal/select.rb +19 -0
  59. data/lib/oscal/serializer.rb +17 -4
  60. data/lib/oscal/set_parameter.rb +30 -0
  61. data/lib/oscal/telephone_number.rb +10 -0
  62. data/lib/oscal/test.rb +10 -0
  63. data/lib/oscal/url.rb +10 -0
  64. data/lib/oscal/value.rb +36 -0
  65. data/lib/oscal/version.rb +1 -1
  66. data/lib/oscal/with_id.rb +39 -0
  67. data/lib/oscal.rb +1 -13
  68. data/oscal.gemspec +9 -11
  69. data/spec/oscal/catalog_spec.rb +39 -0
  70. data/spec/oscal_spec.rb +7 -0
  71. data/spec/spec_helper.rb +15 -0
  72. metadata +65 -9
  73. data/lib/oscal/component.rb +0 -14
  74. data/lib/oscal/prose.rb +0 -13
  75. data/lib/oscal/statement.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6c9dffa10602fbcd753774bb2705bfa2e16f2ff29bbed89e7a2283a6b0d7391
4
- data.tar.gz: dd31b313d847beb37d506adfedf853a588b977e06c49eb4fd973b064ffd2bcb6
3
+ metadata.gz: b3d2839d5707adc52e720080828918e04373d2399cbd138edd403055b1712cc0
4
+ data.tar.gz: 0fc05ead23c4745d188f9bf359c2594463867fd1cce5256a271cf93befef287e
5
5
  SHA512:
6
- metadata.gz: a8f32ccd54e26dbc258dd8d2523379b62e4cddb04283ac473abf1553b27c66d87cb68ce465ae1841afb37adcad9b67d537388f3b0f0abd7795767ee0bdbec072
7
- data.tar.gz: a963912423d5de00406411403949bb010309a07721e6b6de7d6362f30324d281ae05701cb8ca9f17c830d393210a4a1e0a649d77e86aabb25d58699316c592dd
6
+ metadata.gz: 91233436e998fe98ae7d84873ac7d8b68f9fc84ec6f7a7775533ee45922beaeb507c031ed88da4fe0ed71f34e76064861e6e3b0cb340acac23d25b3134cc323f
7
+ data.tar.gz: 957a56d62c3c43b5d22f4659b993acbd6e85ad344fe042fda702a3e07dda5fed576caf6ad0b742eb783597ac0e1165020af957a8d6c9699b0aad977910a910aa
@@ -0,0 +1,15 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ uses: metanorma/ci/.github/workflows/generic-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -0,0 +1,24 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ repository_dispatch:
14
+ types: [ do-release ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ secrets:
22
+ rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
23
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
24
+
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "spec/oscal-content"]
2
+ path = spec/oscal-content
3
+ url = https://github.com/usnistgov/oscal-content
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
+
14
+ gem "rubocop-performance", "~> 1.16"
data/README.adoc CHANGED
@@ -1,5 +1,15 @@
1
1
  = OSCAL in Ruby
2
2
 
3
+ == Purpose
4
+
5
+ This is an implementation of the OSCAL models, allowing the manipulation of
6
+ these models, as well as reading and writing of OSCAL serialization formats
7
+ (YAML, JSON, XML).
8
+
9
+ NOTE: This gem is used by the
10
+ https://github.com/metanorma/metanorma-plugin-oscal[Metanorma plugin for OSCAL].
11
+
12
+
3
13
  == Installation
4
14
 
5
15
  Install the gem:
@@ -20,6 +30,59 @@ gem 'oscal'
20
30
 
21
31
  TODO: Write usage instructions here
22
32
 
33
+ [source,ruby]
34
+ ----
35
+ > require 'oscal'
36
+ > x = Oscal::Catalog.load_from_yaml('spec/oscal-content/examples/catalog/yaml/basic-catalog.yaml')
37
+ =>
38
+ #<Oscal::Catalog:0x000000010b817e08
39
+ ...
40
+ > x.groups.first.groups.first.parts.first.prose
41
+ => "To establish a management framework to initiate and control the implementation and operation of information security within the organization."
42
+ ----
43
+
44
+ Get all controls
45
+
46
+ [source,ruby]
47
+ ----
48
+ > require 'oscal'
49
+ > x = Oscal::Catalog.load_from_yaml('spec/oscal-content/examples/catalog/yaml/basic-catalog.yaml')
50
+ =>
51
+ #<Oscal::Catalog:0x000000010b817e08
52
+ ...
53
+ > o = x.get_all_controls
54
+ > o.count
55
+ => 4
56
+ ----
57
+
58
+ Find object by id
59
+
60
+ [source,ruby]
61
+ ----
62
+ > require 'oscal'
63
+ > x = Oscal::Catalog.load_from_yaml('spec/oscal-content/examples/catalog/yaml/basic-catalog.yaml')
64
+ =>
65
+ #<Oscal::Catalog:0x000000010b817e08
66
+ ...
67
+ > p = x.find_object_by_id('s1.1_smt')
68
+ =>
69
+ #<Oscal::Part:0x000000014c0c4070 @id="s1.1_smt", ...>
70
+ ----
71
+
72
+ Find object by uuid
73
+
74
+ [source,ruby]
75
+ ----
76
+ > require 'oscal'
77
+ > x = Oscal::Catalog.load_from_yaml('spec/oscal-content/examples/catalog/yaml/basic-catalog.yaml')
78
+ =>
79
+ #<Oscal::Catalog:0x000000010b817e08
80
+ ...
81
+ > p = x.find_object_by_id('74c8ba1e-5cd4-4ad1-bbfd-d888e2f6c724', x, :uuid)
82
+ =>
83
+ #<Oscal::Catalog:0x000000014c0c5f38 @uuid="74c8ba1e-5cd4-4ad1-bbfd-d888e2f6c724", ...>
84
+ ----
85
+
23
86
  == Ruby library usage
24
87
 
25
88
  TODO: Write usage instructions here
data/bin/console ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "oscal"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+
16
+ def reload!(print = true)
17
+ puts 'Reloading ...' if print
18
+ # Main project directory.
19
+ root_dir = File.expand_path('..', __dir__)
20
+ # Directories within the project that should be reloaded.
21
+ reload_dirs = %w{lib}
22
+ # Loop through and reload every file in all relevant project directories.
23
+ reload_dirs.each do |dir|
24
+ Dir.glob("#{root_dir}/#{dir}/**/*.rb").each { |f| load(f) }
25
+ end
26
+ # Return true when complete.
27
+ true
28
+ end
29
+
30
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here