oscal 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) 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/.gitignore +2 -0
  7. data/.rspec +0 -1
  8. data/.rubocop.yml +1 -1
  9. data/.ruby-version +1 -0
  10. data/Gemfile +2 -0
  11. data/LICENSE +25 -0
  12. data/Makefile +1 -0
  13. data/README.adoc +3 -0
  14. data/Rakefile +13 -6
  15. data/bin/console +2 -2
  16. data/bin/rspec +27 -0
  17. data/docker-compose.yml +1 -0
  18. data/lib/oscal/add.rb +5 -4
  19. data/lib/oscal/address.rb +3 -2
  20. data/lib/oscal/address_line.rb +1 -0
  21. data/lib/oscal/alter.rb +3 -2
  22. data/lib/oscal/assembly.rb +119 -0
  23. data/lib/oscal/assessment_plan.rb +28 -0
  24. data/lib/oscal/assessment_result.rb +230 -0
  25. data/lib/oscal/attribute_type_hash.rb +80 -0
  26. data/lib/oscal/back_matter.rb +2 -1
  27. data/lib/oscal/base64_object.rb +1 -0
  28. data/lib/oscal/base_class.rb +5 -4
  29. data/lib/oscal/catalog.rb +8 -7
  30. data/lib/oscal/choice.rb +1 -0
  31. data/lib/oscal/citation.rb +3 -2
  32. data/lib/oscal/combine.rb +1 -0
  33. data/lib/oscal/common_utils.rb +1 -1
  34. data/lib/oscal/constraint.rb +2 -1
  35. data/lib/oscal/control.rb +6 -5
  36. data/lib/oscal/custom.rb +3 -2
  37. data/lib/oscal/datatypes.rb +50 -0
  38. data/lib/oscal/document_id.rb +1 -0
  39. data/lib/oscal/email_address.rb +1 -0
  40. data/lib/oscal/exclude_control.rb +3 -2
  41. data/lib/oscal/external_id.rb +1 -0
  42. data/lib/oscal/group.rb +9 -8
  43. data/lib/oscal/guideline.rb +1 -0
  44. data/lib/oscal/hash_object.rb +1 -0
  45. data/lib/oscal/import_object.rb +3 -2
  46. data/lib/oscal/include_control.rb +3 -2
  47. data/lib/oscal/insert_control.rb +3 -2
  48. data/lib/oscal/link.rb +1 -0
  49. data/lib/oscal/list.rb +160 -0
  50. data/lib/oscal/location.rb +8 -7
  51. data/lib/oscal/location_uuid.rb +1 -0
  52. data/lib/oscal/logger.rb +8 -0
  53. data/lib/oscal/matching.rb +1 -0
  54. data/lib/oscal/member_of_organization.rb +1 -0
  55. data/lib/oscal/merge.rb +2 -1
  56. data/lib/oscal/metadata_block.rb +11 -10
  57. data/lib/oscal/modify.rb +3 -2
  58. data/lib/oscal/parameter.rb +8 -7
  59. data/lib/oscal/parsing_functions.rb +19 -0
  60. data/lib/oscal/part.rb +4 -3
  61. data/lib/oscal/party.rb +11 -10
  62. data/lib/oscal/party_uuid.rb +1 -0
  63. data/lib/oscal/profile.rb +7 -6
  64. data/lib/oscal/property.rb +1 -0
  65. data/lib/oscal/remove.rb +1 -0
  66. data/lib/oscal/resource.rb +7 -6
  67. data/lib/oscal/responsible_party.rb +11 -10
  68. data/lib/oscal/revision.rb +4 -3
  69. data/lib/oscal/rlink.rb +2 -1
  70. data/lib/oscal/role.rb +3 -2
  71. data/lib/oscal/select.rb +2 -1
  72. data/lib/oscal/set_parameter.rb +8 -7
  73. data/lib/oscal/telephone_number.rb +1 -0
  74. data/lib/oscal/test.rb +1 -0
  75. data/lib/oscal/url.rb +1 -0
  76. data/lib/oscal/value.rb +5 -4
  77. data/lib/oscal/version.rb +1 -1
  78. data/lib/oscal/with_id.rb +2 -1
  79. data/lib/oscal.rb +1 -1
  80. data/spec/oscal/catalog_spec.rb +5 -4
  81. data/spec/sample_inputs/import-ap.json +4 -0
  82. metadata +21 -3
@@ -3,24 +3,25 @@ require_relative "base_class"
3
3
  module Oscal
4
4
  class SetParameter < Oscal::BaseClass
5
5
  KEY = %i(param_id klass depneds_on props links label usage
6
- constraints guidelines values select)
6
+ constraints guidelines values select)
7
7
 
8
8
  attr_accessor *KEY
9
+
9
10
  attr_serializable *KEY
10
11
 
11
12
  def set_value(key_name, val)
12
13
  case key_name
13
- when 'props'
14
+ when "props"
14
15
  Property.wrap(val)
15
- when 'links'
16
+ when "links"
16
17
  Link.wrap(val)
17
- when 'constraints'
18
+ when "constraints"
18
19
  Constraint.wrap(val)
19
- when 'guidelines'
20
+ when "guidelines"
20
21
  Guideline.wrap(val)
21
- when 'values'
22
+ when "values"
22
23
  Value.wrap(val)
23
- when 'select'
24
+ when "select"
24
25
  Select.wrap(val)
25
26
  else
26
27
  val
@@ -5,6 +5,7 @@ module Oscal
5
5
  KEY = %i(type number)
6
6
 
7
7
  attr_accessor *KEY
8
+
8
9
  attr_serializable *KEY
9
10
  end
10
11
  end
data/lib/oscal/test.rb CHANGED
@@ -5,6 +5,7 @@ module Oscal
5
5
  KEY = %i(expression remarks)
6
6
 
7
7
  attr_accessor *KEY
8
+
8
9
  attr_serializable *KEY
9
10
  end
10
11
  end
data/lib/oscal/url.rb CHANGED
@@ -5,6 +5,7 @@ module Oscal
5
5
  KEY = %i(val)
6
6
 
7
7
  attr_accessor *KEY
8
+
8
9
  attr_serializable *KEY
9
10
  end
10
11
  end
data/lib/oscal/value.rb CHANGED
@@ -6,6 +6,7 @@ module Oscal
6
6
 
7
7
  KEY = %i(val)
8
8
  attr_accessor *KEY
9
+
9
10
  attr_serializable *KEY
10
11
 
11
12
  def self.wrap(obj)
@@ -17,13 +18,13 @@ module Oscal
17
18
  end
18
19
  end
19
20
 
20
- def initialize(options={})
21
+ def initialize(options = {})
21
22
  unless options.is_a? Hash
22
- options = {'val' => options}
23
+ options = { "val" => options }
23
24
  end
24
25
 
25
- options.each_pair.each do |key,val|
26
- key_name = key.gsub('-','_')
26
+ options.each_pair.each do |key, val|
27
+ key_name = key.gsub("-", "_")
27
28
 
28
29
  unless KEY.include?(key_name.to_sym)
29
30
  raise UnknownAttributeError.new("Unknown key `#{key}` in Value")
data/lib/oscal/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Oscal
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/oscal/with_id.rb CHANGED
@@ -7,6 +7,7 @@ module Oscal
7
7
  KEY = %i(val)
8
8
 
9
9
  attr_accessor *KEY
10
+
10
11
  attr_serializable *KEY
11
12
 
12
13
  def self.wrap(obj)
@@ -22,7 +23,7 @@ module Oscal
22
23
  klass = self.class
23
24
 
24
25
  unless options.is_a? Hash
25
- options = {KEY.first.to_s => options}
26
+ options = { KEY.first.to_s => options }
26
27
  end
27
28
 
28
29
  options.each_pair.each do |key, val|
data/lib/oscal.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Dir[File.join(__dir__, 'oscal', '*.rb')].each { |file| require file }
3
+ Dir[File.join(__dir__, "oscal", "*.rb")].each { |file| require file }
4
4
 
5
5
  module Oscal
6
6
  class Error < StandardError; end
@@ -9,7 +9,7 @@ RSpec.describe Oscal::Catalog do
9
9
 
10
10
  it "parses oscal-content YAML" do
11
11
  expect(subject.class).to be Oscal::Catalog
12
- expect(subject.groups.first.groups.first.parts.first.prose).to eq(
12
+ expect(subject.groups.first.groups.first.controls.first.parts.first.prose).to eq(
13
13
  "To establish a management framework to initiate and " \
14
14
  "control the implementation and operation of information security " \
15
15
  "within the organization.",
@@ -22,14 +22,15 @@ RSpec.describe Oscal::Catalog do
22
22
  end
23
23
 
24
24
  it "find object by id" do
25
- obj = subject.find_object_by_id('s2.1_smt')
25
+ obj = subject.find_object_by_id("s2.1_smt")
26
26
  expect(obj.to_s).to match(/Oscal::Part/)
27
27
  expect(obj.prose).to eq(
28
- "To limit access to information and information processing facilities.")
28
+ "To limit access to information and information processing facilities.",
29
+ )
29
30
  end
30
31
 
31
32
  it "find object by uuid" do
32
- uuid = '74c8ba1e-5cd4-4ad1-bbfd-d888e2f6c724'
33
+ uuid = "74c8ba1e-5cd4-4ad1-bbfd-d888e2f6c724"
33
34
  obj = subject.find_object_by_id(
34
35
  uuid, subject, :uuid
35
36
  )
@@ -0,0 +1,4 @@
1
+ {
2
+ "href": "../3-implementation/ssp.oscal.xml",
3
+ "remarks": "These are valid remarks."
4
+ }
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.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-14 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
@@ -32,6 +32,10 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - ".docker/Dockerfile"
36
+ - ".docker/Makefile"
37
+ - ".docker/docker-compose.yml"
38
+ - ".docker/readme.md"
35
39
  - ".github/workflows/rake.yml"
36
40
  - ".github/workflows/release.yml"
37
41
  - ".gitignore"
@@ -39,18 +43,27 @@ files:
39
43
  - ".hound.yml"
40
44
  - ".rspec"
41
45
  - ".rubocop.yml"
46
+ - ".ruby-version"
42
47
  - CODE_OF_CONDUCT.md
43
48
  - Gemfile
49
+ - LICENSE
50
+ - Makefile
44
51
  - README.adoc
45
52
  - Rakefile
46
53
  - bin/console
54
+ - bin/rspec
47
55
  - bin/setup
56
+ - docker-compose.yml
48
57
  - exe/convert2oscalyaml.rb
49
58
  - lib/oscal.rb
50
59
  - lib/oscal/add.rb
51
60
  - lib/oscal/address.rb
52
61
  - lib/oscal/address_line.rb
53
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
54
67
  - lib/oscal/back_matter.rb
55
68
  - lib/oscal/base64_object.rb
56
69
  - lib/oscal/base_class.rb
@@ -62,6 +75,7 @@ files:
62
75
  - lib/oscal/constraint.rb
63
76
  - lib/oscal/control.rb
64
77
  - lib/oscal/custom.rb
78
+ - lib/oscal/datatypes.rb
65
79
  - lib/oscal/document_id.rb
66
80
  - lib/oscal/email_address.rb
67
81
  - lib/oscal/exclude_control.rb
@@ -73,14 +87,17 @@ files:
73
87
  - lib/oscal/include_control.rb
74
88
  - lib/oscal/insert_control.rb
75
89
  - lib/oscal/link.rb
90
+ - lib/oscal/list.rb
76
91
  - lib/oscal/location.rb
77
92
  - lib/oscal/location_uuid.rb
93
+ - lib/oscal/logger.rb
78
94
  - lib/oscal/matching.rb
79
95
  - lib/oscal/member_of_organization.rb
80
96
  - lib/oscal/merge.rb
81
97
  - lib/oscal/metadata_block.rb
82
98
  - lib/oscal/modify.rb
83
99
  - lib/oscal/parameter.rb
100
+ - lib/oscal/parsing_functions.rb
84
101
  - lib/oscal/part.rb
85
102
  - lib/oscal/party.rb
86
103
  - lib/oscal/party_uuid.rb
@@ -105,6 +122,7 @@ files:
105
122
  - sig/oscal.rbs
106
123
  - spec/oscal/catalog_spec.rb
107
124
  - spec/oscal_spec.rb
125
+ - spec/sample_inputs/import-ap.json
108
126
  - spec/spec_helper.rb
109
127
  homepage: https://github.com/metanorma/oscal-ruby/
110
128
  licenses:
@@ -129,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
147
  - !ruby/object:Gem::Version
130
148
  version: '0'
131
149
  requirements: []
132
- rubygems_version: 3.3.7
150
+ rubygems_version: 3.4.10
133
151
  signing_key:
134
152
  specification_version: 4
135
153
  summary: Interact with OSCAL models