compliance 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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/compliance/attest.rb +86 -0
- data/bake/compliance.rb +18 -43
- data/lib/compliance/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f821883f9be036f7d0c4b4b4c46a54cfb4d9c65f03d2a8e09a739d595d69cb4
|
4
|
+
data.tar.gz: e89f86fc987e18cae6643dd593f2388dd1f5822238eb4d72356735478626eb44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d31ba046177f99b0bb31f11f5760e0b875dd4c1150c7cbca1a4bccca7bd3f07165a247a8fe24af28601e66632043fb5cca994baea85a14d98cb4f5d97b159371
|
7
|
+
data.tar.gz: 6502b0285c36ca163ff3e2f573a7072552bbae42047f54417b03688e2d2b60fd386ef548bfd8d03a98a904c27968d07d2d7e286b3bd2a6576372261370153faa
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2024, by Samuel Williams.
|
5
|
+
|
6
|
+
def initialize(...)
|
7
|
+
super
|
8
|
+
|
9
|
+
require 'compliance'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Attest to a requirement.
|
13
|
+
# @parameter id [String] The unique identifier for the attestation, matching the requirement.
|
14
|
+
# @parameter description [String] A description of how the requirement is satisfied.
|
15
|
+
# @parameter by [String] The entity attesting to the requirement.
|
16
|
+
def attest(id, description: nil, by: nil)
|
17
|
+
compliance_root = Compliance::Document.path(context.root)
|
18
|
+
|
19
|
+
if File.exist?(compliance_root)
|
20
|
+
document = Compliance::Document.load(compliance_root)
|
21
|
+
else
|
22
|
+
document = Compliance::Document.new
|
23
|
+
end
|
24
|
+
|
25
|
+
attestation = self.attestation_for(id, document)
|
26
|
+
|
27
|
+
if description
|
28
|
+
attestation.metadata[:description] = description
|
29
|
+
end
|
30
|
+
|
31
|
+
if by
|
32
|
+
attestation.metadata[:by] = by
|
33
|
+
end
|
34
|
+
|
35
|
+
File.write(compliance_root, JSON.pretty_generate(document))
|
36
|
+
|
37
|
+
return attestation
|
38
|
+
end
|
39
|
+
|
40
|
+
def all(description: nil, by: nil)
|
41
|
+
compliance_root = Compliance::Document.path(context.root)
|
42
|
+
|
43
|
+
if File.exist?(compliance_root)
|
44
|
+
document = Compliance::Document.load(compliance_root)
|
45
|
+
else
|
46
|
+
document = Compliance::Document.new
|
47
|
+
end
|
48
|
+
|
49
|
+
policy = self.policy
|
50
|
+
|
51
|
+
policy.requirements.each do |id, requirement|
|
52
|
+
attestation = self.attestation_for(id, document)
|
53
|
+
|
54
|
+
if description
|
55
|
+
attestation.metadata[:description] = description
|
56
|
+
end
|
57
|
+
|
58
|
+
if by
|
59
|
+
attestation.metadata[:by] = by
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
File.write(compliance_root, JSON.pretty_generate(document))
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# Load the default compliance policy.
|
69
|
+
def policy
|
70
|
+
loader = Compliance::Loader.default([context.root])
|
71
|
+
|
72
|
+
return Compliance::Policy.default(loader)
|
73
|
+
end
|
74
|
+
|
75
|
+
def attestation_for(id, document)
|
76
|
+
document.attestations.each do |attestation|
|
77
|
+
if attestation.id == id
|
78
|
+
return attestation
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
attestation = Compliance::Attestation.new(id: id)
|
83
|
+
document.attestations << attestation
|
84
|
+
|
85
|
+
return attestation
|
86
|
+
end
|
data/bake/compliance.rb
CHANGED
@@ -25,6 +25,24 @@ def list
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
# Show a specific requirement and any associated attestations.
|
29
|
+
# @parameter id [String] The unique identifier for the requirement.
|
30
|
+
def show(id)
|
31
|
+
policy = self.policy
|
32
|
+
|
33
|
+
requirement = policy.requirements[id]
|
34
|
+
|
35
|
+
if requirement
|
36
|
+
$stdout.puts "Requirement: #{requirement.id}"
|
37
|
+
$stdout.puts JSON.pretty_generate(requirement)
|
38
|
+
end
|
39
|
+
|
40
|
+
policy.attestations[id]&.each do |attestations|
|
41
|
+
$stdout.puts "Attestation: #{attestation.id}"
|
42
|
+
$stdout.puts JSON.pretty_generate(attestation)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
28
46
|
# Check compliance with the policy.
|
29
47
|
def check
|
30
48
|
policy = self.policy
|
@@ -46,46 +64,3 @@ def check
|
|
46
64
|
return results
|
47
65
|
end
|
48
66
|
end
|
49
|
-
|
50
|
-
# Attest to a requirement.
|
51
|
-
# @parameter id [String] The unique identifier for the attestation, matching the requirement.
|
52
|
-
# @parameter description [String] A description of how the requirement is satisfied.
|
53
|
-
# @parameter by [String] The entity attesting to the requirement.
|
54
|
-
def attest(id, description: nil, by: nil)
|
55
|
-
compliance_root = Compliance::Document.path(context.root)
|
56
|
-
|
57
|
-
if File.exist?(compliance_root)
|
58
|
-
document = Compliance::Document.load(compliance_root)
|
59
|
-
else
|
60
|
-
document = Compliance::Document.new
|
61
|
-
end
|
62
|
-
|
63
|
-
attestation = self.attestation_for(id, document)
|
64
|
-
|
65
|
-
if description
|
66
|
-
attestation.metadata[:description] = description
|
67
|
-
end
|
68
|
-
|
69
|
-
if by
|
70
|
-
attestation.metadata[:by] = by
|
71
|
-
end
|
72
|
-
|
73
|
-
File.write(compliance_root, JSON.pretty_generate(document))
|
74
|
-
|
75
|
-
return attestation
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def attestation_for(id, document)
|
81
|
-
document.attestations.each do |attestation|
|
82
|
-
if attestation.id == id
|
83
|
-
return attestation
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
attestation = Compliance::Attestation.new(id: id)
|
88
|
-
document.attestations << attestation
|
89
|
-
|
90
|
-
return attestation
|
91
|
-
end
|
data/lib/compliance/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compliance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- bake/compliance.rb
|
63
|
+
- bake/compliance/attest.rb
|
63
64
|
- lib/compliance.rb
|
64
65
|
- lib/compliance/attestation.rb
|
65
66
|
- lib/compliance/document.rb
|
metadata.gz.sig
CHANGED
Binary file
|