oscal 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/Dockerfile +19 -0
  3. data/.docker/Makefile +43 -0
  4. data/.docker/docker-compose.yml +14 -0
  5. data/.docker/readme.md +61 -0
  6. data/.github/workflows/rake.yml +15 -0
  7. data/.github/workflows/release.yml +24 -0
  8. data/.gitignore +13 -0
  9. data/.gitmodules +3 -0
  10. data/.hound.yml +5 -0
  11. data/.rspec +0 -1
  12. data/.rubocop.yml +10 -0
  13. data/.ruby-version +1 -0
  14. data/Gemfile +4 -0
  15. data/LICENSE +25 -0
  16. data/Makefile +1 -0
  17. data/README.adoc +66 -0
  18. data/Rakefile +13 -6
  19. data/bin/console +30 -0
  20. data/bin/rspec +27 -0
  21. data/bin/setup +8 -0
  22. data/docker-compose.yml +1 -0
  23. data/exe/convert2oscalyaml.rb +560 -0
  24. data/lib/oscal/add.rb +26 -0
  25. data/lib/oscal/address.rb +22 -0
  26. data/lib/oscal/address_line.rb +11 -0
  27. data/lib/oscal/alter.rb +22 -0
  28. data/lib/oscal/assembly.rb +119 -0
  29. data/lib/oscal/assessment_plan.rb +28 -0
  30. data/lib/oscal/assessment_result.rb +230 -0
  31. data/lib/oscal/attribute_type_hash.rb +80 -0
  32. data/lib/oscal/back_matter.rb +20 -0
  33. data/lib/oscal/base64_object.rb +11 -0
  34. data/lib/oscal/base_class.rb +50 -0
  35. data/lib/oscal/catalog.rb +51 -10
  36. data/lib/oscal/choice.rb +11 -0
  37. data/lib/oscal/citation.rb +22 -0
  38. data/lib/oscal/combine.rb +11 -0
  39. data/lib/oscal/common_utils.rb +35 -0
  40. data/lib/oscal/constraint.rb +20 -0
  41. data/lib/oscal/control.rb +20 -30
  42. data/lib/oscal/custom.rb +22 -0
  43. data/lib/oscal/datatypes.rb +50 -0
  44. data/lib/oscal/document_id.rb +11 -0
  45. data/lib/oscal/email_address.rb +11 -0
  46. data/lib/oscal/exclude_control.rb +22 -0
  47. data/lib/oscal/external_id.rb +11 -0
  48. data/lib/oscal/group.rb +26 -34
  49. data/lib/oscal/guideline.rb +11 -0
  50. data/lib/oscal/hash_object.rb +11 -0
  51. data/lib/oscal/import_object.rb +22 -0
  52. data/lib/oscal/include_control.rb +22 -0
  53. data/lib/oscal/insert_control.rb +22 -0
  54. data/lib/oscal/link.rb +11 -0
  55. data/lib/oscal/list.rb +160 -0
  56. data/lib/oscal/location.rb +31 -0
  57. data/lib/oscal/location_uuid.rb +11 -0
  58. data/lib/oscal/logger.rb +8 -0
  59. data/lib/oscal/matching.rb +11 -0
  60. data/lib/oscal/member_of_organization.rb +11 -0
  61. data/lib/oscal/merge.rb +20 -0
  62. data/lib/oscal/metadata_block.rb +28 -13
  63. data/lib/oscal/modify.rb +22 -0
  64. data/lib/oscal/parameter.rb +22 -19
  65. data/lib/oscal/parsing_functions.rb +19 -0
  66. data/lib/oscal/part.rb +14 -22
  67. data/lib/oscal/party.rb +36 -0
  68. data/lib/oscal/party_uuid.rb +11 -0
  69. data/lib/oscal/profile.rb +33 -7
  70. data/lib/oscal/property.rb +4 -25
  71. data/lib/oscal/remove.rb +11 -0
  72. data/lib/oscal/resource.rb +29 -0
  73. data/lib/oscal/responsible_party.rb +24 -0
  74. data/lib/oscal/revision.rb +23 -0
  75. data/lib/oscal/rlink.rb +20 -0
  76. data/lib/oscal/role.rb +22 -0
  77. data/lib/oscal/select.rb +20 -0
  78. data/lib/oscal/serializer.rb +17 -4
  79. data/lib/oscal/set_parameter.rb +31 -0
  80. data/lib/oscal/telephone_number.rb +11 -0
  81. data/lib/oscal/test.rb +11 -0
  82. data/lib/oscal/url.rb +11 -0
  83. data/lib/oscal/value.rb +37 -0
  84. data/lib/oscal/version.rb +1 -1
  85. data/lib/oscal/with_id.rb +40 -0
  86. data/lib/oscal.rb +1 -13
  87. data/oscal.gemspec +9 -11
  88. data/spec/oscal/catalog_spec.rb +40 -0
  89. data/spec/oscal_spec.rb +7 -0
  90. data/spec/sample_inputs/import-ap.json +4 -0
  91. data/spec/spec_helper.rb +15 -0
  92. metadata +84 -10
  93. data/lib/oscal/component.rb +0 -14
  94. data/lib/oscal/prose.rb +0 -13
  95. data/lib/oscal/statement.rb +0 -12
data/lib/oscal.rb CHANGED
@@ -1,18 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "oscal/version"
4
- require_relative "oscal/serializer"
5
- require_relative "oscal/catalog"
6
- require_relative "oscal/component"
7
- require_relative "oscal/control"
8
- require_relative "oscal/group"
9
- require_relative "oscal/part"
10
- require_relative "oscal/parameter"
11
- require_relative "oscal/metadata_block"
12
- require_relative "oscal/profile"
13
- require_relative "oscal/property"
14
- require_relative "oscal/prose"
15
- require_relative "oscal/statement"
3
+ Dir[File.join(__dir__, "oscal", "*.rb")].each { |file| require file }
16
4
 
17
5
  module Oscal
18
6
  class Error < StandardError; end
data/oscal.gemspec CHANGED
@@ -5,28 +5,26 @@ require_relative "lib/oscal/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "oscal"
7
7
  spec.version = Oscal::VERSION
8
- spec.authors = ["Ronald Tse"]
9
- spec.email = ["ronald.tse@ribose.com"]
8
+ spec.authors = ["Ribose Inc."]
9
+ spec.email = ["open.source@ribose.com"]
10
10
 
11
11
  spec.summary = "Interact with OSCAL models"
12
12
  spec.description = "Ruby library and parser for OSCAL models"
13
13
  spec.homepage = "https://github.com/metanorma/oscal-ruby/"
14
- spec.required_ruby_version = ">= 2.7.0"
14
+ spec.license = "BSD-2-Clause"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = "https://github.com/metanorma/oscal-ruby/"
18
18
  spec.metadata["changelog_uri"] = "https://github.com/metanorma/oscal-ruby/CHANGELOG"
19
19
 
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(__dir__) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
- end
20
+ spec.files = `git ls-files`.split("\n")
21
+ spec.executables = `git ls-files -- exe/*`.split("\n").map do |f|
22
+ File.basename(f)
26
23
  end
27
- spec.bindir = "exe"
28
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
+ spec.bindir = "exe"
29
25
  spec.require_paths = ["lib"]
26
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
30
27
 
31
28
  spec.add_dependency "yaml"
29
+ spec.metadata["rubygems_mfa_required"] = "true"
32
30
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Oscal::Catalog do
4
+ let(:subject) do
5
+ Oscal::Catalog.load_from_yaml(
6
+ "spec/oscal-content/examples/catalog/yaml/basic-catalog.yaml",
7
+ )
8
+ end
9
+
10
+ it "parses oscal-content YAML" do
11
+ expect(subject.class).to be Oscal::Catalog
12
+ expect(subject.groups.first.groups.first.controls.first.parts.first.prose).to eq(
13
+ "To establish a management framework to initiate and " \
14
+ "control the implementation and operation of information security " \
15
+ "within the organization.",
16
+ )
17
+ end
18
+
19
+ it "gets all controls" do
20
+ expect(subject.class).to be Oscal::Catalog
21
+ expect(subject.get_all_controls.count).to eq(4)
22
+ end
23
+
24
+ it "find object by id" do
25
+ obj = subject.find_object_by_id("s2.1_smt")
26
+ expect(obj.to_s).to match(/Oscal::Part/)
27
+ expect(obj.prose).to eq(
28
+ "To limit access to information and information processing facilities.",
29
+ )
30
+ end
31
+
32
+ it "find object by uuid" do
33
+ uuid = "74c8ba1e-5cd4-4ad1-bbfd-d888e2f6c724"
34
+ obj = subject.find_object_by_id(
35
+ uuid, subject, :uuid
36
+ )
37
+ expect(obj.to_s).to match(/Oscal::Catalog/)
38
+ expect(obj.uuid).to eq(uuid)
39
+ end
40
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Oscal do
4
+ it "has a version number" do
5
+ expect(Oscal::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ {
2
+ "href": "../3-implementation/ssp.oscal.xml",
3
+ "remarks": "These are valid remarks."
4
+ }
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "oscal"
4
+
5
+ RSpec.configure do |config|
6
+ # Enable flags like --only-failures and --next-failure
7
+ config.example_status_persistence_file_path = ".rspec_status"
8
+
9
+ # Disable RSpec exposing methods globally on `Module` and `main`
10
+ config.disable_monkey_patching!
11
+
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oscal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ronald Tse
7
+ - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-20 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml
@@ -26,38 +26,112 @@ dependencies:
26
26
  version: '0'
27
27
  description: Ruby library and parser for OSCAL models
28
28
  email:
29
- - ronald.tse@ribose.com
30
- executables: []
29
+ - open.source@ribose.com
30
+ executables:
31
+ - convert2oscalyaml.rb
31
32
  extensions: []
32
33
  extra_rdoc_files: []
33
34
  files:
35
+ - ".docker/Dockerfile"
36
+ - ".docker/Makefile"
37
+ - ".docker/docker-compose.yml"
38
+ - ".docker/readme.md"
39
+ - ".github/workflows/rake.yml"
40
+ - ".github/workflows/release.yml"
41
+ - ".gitignore"
42
+ - ".gitmodules"
43
+ - ".hound.yml"
34
44
  - ".rspec"
45
+ - ".rubocop.yml"
46
+ - ".ruby-version"
35
47
  - CODE_OF_CONDUCT.md
36
48
  - Gemfile
49
+ - LICENSE
50
+ - Makefile
37
51
  - README.adoc
38
52
  - Rakefile
53
+ - bin/console
54
+ - bin/rspec
55
+ - bin/setup
56
+ - docker-compose.yml
57
+ - exe/convert2oscalyaml.rb
39
58
  - lib/oscal.rb
59
+ - lib/oscal/add.rb
60
+ - lib/oscal/address.rb
61
+ - lib/oscal/address_line.rb
62
+ - lib/oscal/alter.rb
63
+ - lib/oscal/assembly.rb
64
+ - lib/oscal/assessment_plan.rb
65
+ - lib/oscal/assessment_result.rb
66
+ - lib/oscal/attribute_type_hash.rb
67
+ - lib/oscal/back_matter.rb
68
+ - lib/oscal/base64_object.rb
69
+ - lib/oscal/base_class.rb
40
70
  - lib/oscal/catalog.rb
41
- - lib/oscal/component.rb
71
+ - lib/oscal/choice.rb
72
+ - lib/oscal/citation.rb
73
+ - lib/oscal/combine.rb
74
+ - lib/oscal/common_utils.rb
75
+ - lib/oscal/constraint.rb
42
76
  - lib/oscal/control.rb
77
+ - lib/oscal/custom.rb
78
+ - lib/oscal/datatypes.rb
79
+ - lib/oscal/document_id.rb
80
+ - lib/oscal/email_address.rb
81
+ - lib/oscal/exclude_control.rb
82
+ - lib/oscal/external_id.rb
43
83
  - lib/oscal/group.rb
84
+ - lib/oscal/guideline.rb
85
+ - lib/oscal/hash_object.rb
86
+ - lib/oscal/import_object.rb
87
+ - lib/oscal/include_control.rb
88
+ - lib/oscal/insert_control.rb
89
+ - lib/oscal/link.rb
90
+ - lib/oscal/list.rb
91
+ - lib/oscal/location.rb
92
+ - lib/oscal/location_uuid.rb
93
+ - lib/oscal/logger.rb
94
+ - lib/oscal/matching.rb
95
+ - lib/oscal/member_of_organization.rb
96
+ - lib/oscal/merge.rb
44
97
  - lib/oscal/metadata_block.rb
98
+ - lib/oscal/modify.rb
45
99
  - lib/oscal/parameter.rb
100
+ - lib/oscal/parsing_functions.rb
46
101
  - lib/oscal/part.rb
102
+ - lib/oscal/party.rb
103
+ - lib/oscal/party_uuid.rb
47
104
  - lib/oscal/profile.rb
48
105
  - lib/oscal/property.rb
49
- - lib/oscal/prose.rb
106
+ - lib/oscal/remove.rb
107
+ - lib/oscal/resource.rb
108
+ - lib/oscal/responsible_party.rb
109
+ - lib/oscal/revision.rb
110
+ - lib/oscal/rlink.rb
111
+ - lib/oscal/role.rb
112
+ - lib/oscal/select.rb
50
113
  - lib/oscal/serializer.rb
51
- - lib/oscal/statement.rb
114
+ - lib/oscal/set_parameter.rb
115
+ - lib/oscal/telephone_number.rb
116
+ - lib/oscal/test.rb
117
+ - lib/oscal/url.rb
118
+ - lib/oscal/value.rb
52
119
  - lib/oscal/version.rb
120
+ - lib/oscal/with_id.rb
53
121
  - oscal.gemspec
54
122
  - sig/oscal.rbs
123
+ - spec/oscal/catalog_spec.rb
124
+ - spec/oscal_spec.rb
125
+ - spec/sample_inputs/import-ap.json
126
+ - spec/spec_helper.rb
55
127
  homepage: https://github.com/metanorma/oscal-ruby/
56
- licenses: []
128
+ licenses:
129
+ - BSD-2-Clause
57
130
  metadata:
58
131
  homepage_uri: https://github.com/metanorma/oscal-ruby/
59
132
  source_code_uri: https://github.com/metanorma/oscal-ruby/
60
133
  changelog_uri: https://github.com/metanorma/oscal-ruby/CHANGELOG
134
+ rubygems_mfa_required: 'true'
61
135
  post_install_message:
62
136
  rdoc_options: []
63
137
  require_paths:
@@ -73,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
147
  - !ruby/object:Gem::Version
74
148
  version: '0'
75
149
  requirements: []
76
- rubygems_version: 3.3.7
150
+ rubygems_version: 3.4.10
77
151
  signing_key:
78
152
  specification_version: 4
79
153
  summary: Interact with OSCAL models
@@ -1,14 +0,0 @@
1
- module Oscal
2
- class Component
3
- attr_accessor :id, :name, :type, :description, :properties
4
-
5
- def initialize(id, name, type, description, properties)
6
- @id = id
7
- @name = name
8
- @type = type
9
- @description = description
10
- @properties = properties
11
- end
12
- end
13
-
14
- end
data/lib/oscal/prose.rb DELETED
@@ -1,13 +0,0 @@
1
- require_relative "serializer"
2
-
3
- module Oscal
4
- class Prose
5
- include Serializer
6
-
7
- attr_serializable :value, :media_type
8
-
9
- def to_xml(builder)
10
- builder.prose(value, {'media-type' => media_type})
11
- end
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- module Oscal
2
- class Statement
3
- attr_accessor :description, :prose, :properties
4
-
5
- def initialize(description, prose, properties)
6
- @description = description
7
- @prose = prose
8
- @properties = properties
9
- end
10
- end
11
-
12
- end