emasser 3.4.1 → 3.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +8 -8
- data/.env-example +12 -12
- data/.github/release-drafter.yml +15 -15
- data/.github/workflows/codeql-analysis.yml +70 -70
- data/.github/workflows/draft-release.yml +15 -15
- data/.github/workflows/gh-pages.yml +32 -32
- data/.github/workflows/push-to-docker-mail.yml +28 -28
- data/.github/workflows/push-to-docker.yml +35 -35
- data/.github/workflows/release.yml +42 -42
- data/.github/workflows/rubocop.yml +23 -23
- data/.github/workflows/test-cli.yml +39 -72
- data/.gitignore +19 -19
- data/.mergify.yml +25 -25
- data/.rubocop.yml +83 -80
- data/.rubocop_todo.yml +27 -27
- data/CHANGELOG.md +16 -16
- data/Dockerfile +44 -44
- data/Gemfile +8 -8
- data/Gemfile.lock +108 -104
- data/LICENSE.md +15 -15
- data/README.md +178 -178
- data/Rakefile +18 -18
- data/_config.yml +1 -1
- data/docs/features.md +1501 -1436
- data/docs/redoc/index.html +1230 -1230
- data/emasser.gemspec +44 -44
- data/exe/emasser +5 -5
- data/lib/emasser/cli.rb +37 -37
- data/lib/emasser/configuration.rb +49 -49
- data/lib/emasser/constants.rb +26 -26
- data/lib/emasser/delete.rb +148 -148
- data/lib/emasser/errors.rb +14 -14
- data/lib/emasser/get.rb +1194 -949
- data/lib/emasser/help/approvalCac_post_mapper.md +20 -20
- data/lib/emasser/help/approvalPac_post_mapper.md +20 -20
- data/lib/emasser/help/artifacts_del_mapper.md +9 -9
- data/lib/emasser/help/artifacts_post_mapper.md +59 -59
- data/lib/emasser/help/artifacts_put_mapper.md +34 -34
- data/lib/emasser/help/cloudresource_post_mapper.md +62 -62
- data/lib/emasser/help/cmmc_get_mapper.md +4 -4
- data/lib/emasser/help/container_post_mapper.md +44 -44
- data/lib/emasser/help/controls_put_mapper.md +74 -74
- data/lib/emasser/help/milestone_del_mapper.md +11 -11
- data/lib/emasser/help/milestone_post_mapper.md +14 -14
- data/lib/emasser/help/milestone_put_mapper.md +23 -23
- data/lib/emasser/help/poam_del_mapper.md +5 -5
- data/lib/emasser/help/poam_post_mapper.md +93 -93
- data/lib/emasser/help/poam_put_mapper.md +107 -107
- data/lib/emasser/help/staticcode_clear_mapper.md +16 -16
- data/lib/emasser/help/staticcode_post_mapper.md +21 -21
- data/lib/emasser/help/testresults_post_mapper.md +21 -21
- data/lib/emasser/help.rb +11 -11
- data/lib/emasser/input_converters.rb +21 -21
- data/lib/emasser/options_parser.rb +20 -20
- data/lib/emasser/output_converters.rb +115 -111
- data/lib/emasser/post.rb +830 -830
- data/lib/emasser/put.rb +588 -588
- data/lib/emasser/version.rb +5 -5
- data/lib/emasser.rb +19 -19
- metadata +16 -10
@@ -1,111 +1,115 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module OutputConverters
|
4
|
-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
|
5
|
-
# rubocop:disable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
|
6
|
-
def to_output_hash(obj)
|
7
|
-
diplay_nulls = (ENV.fetch('EMASSER_CLI_DISPLAY_NULL', 'true').eql? 'true') ? true : false
|
8
|
-
diplay_datetime = (ENV.fetch('EMASSER_EPOCH_TO_DATETIME', 'false').eql? 'true') ? true : false
|
9
|
-
|
10
|
-
if obj.to_s.include? 'Error message'
|
11
|
-
begin
|
12
|
-
index = obj.to_s.index('Response body')+14
|
13
|
-
arr_obj = obj.to_s[index, obj.to_s.size - index]
|
14
|
-
JSON.pretty_generate(JSON.parse(arr_obj))
|
15
|
-
rescue
|
16
|
-
obj
|
17
|
-
end
|
18
|
-
else
|
19
|
-
obj = obj.to_body if obj.respond_to?(:to_body)
|
20
|
-
if !diplay_nulls
|
21
|
-
clean_obj = {}
|
22
|
-
data_obj = {}
|
23
|
-
obj.each do |key, value|
|
24
|
-
if key.to_s.include?('meta')
|
25
|
-
obj_entry = {}
|
26
|
-
obj_entry[:meta] = value
|
27
|
-
clean_obj.merge!(obj_entry)
|
28
|
-
elsif key.to_s.include?('data')
|
29
|
-
if value.is_a?(Array)
|
30
|
-
hash_array = []
|
31
|
-
value.each do |elements|
|
32
|
-
hash_array << elements.compact
|
33
|
-
end
|
34
|
-
data_obj['data'] = hash_array
|
35
|
-
else
|
36
|
-
data_obj['data'] = value.nil? ? value : value.compact
|
37
|
-
end
|
38
|
-
elsif key.to_s.include?('pagination')
|
39
|
-
pg_obj = {}
|
40
|
-
pg_obj[:pagination] = value
|
41
|
-
data_obj.merge!(pg_obj)
|
42
|
-
end
|
43
|
-
clean_obj.merge!(data_obj)
|
44
|
-
end
|
45
|
-
obj = clean_obj
|
46
|
-
end
|
47
|
-
|
48
|
-
if diplay_datetime
|
49
|
-
clean_obj = {}
|
50
|
-
data_obj = {}
|
51
|
-
obj.each do |key, value|
|
52
|
-
if key.to_s.include?('meta')
|
53
|
-
obj_entry = {}
|
54
|
-
obj_entry[:meta] = value
|
55
|
-
clean_obj.merge!(obj_entry)
|
56
|
-
elsif key.to_s.include?('data')
|
57
|
-
if value.is_a?(Array)
|
58
|
-
hash_array = []
|
59
|
-
value.each do |element|
|
60
|
-
datetime_obj = change_to_datetime(element)
|
61
|
-
hash_array << datetime_obj
|
62
|
-
end
|
63
|
-
data_obj['data'] = hash_array
|
64
|
-
else
|
65
|
-
data_obj['data'] = change_to_datetime(value)
|
66
|
-
end
|
67
|
-
elsif key.to_s.include?('pagination')
|
68
|
-
pg_obj = {}
|
69
|
-
pg_obj[:pagination] = value
|
70
|
-
data_obj.merge!(pg_obj)
|
71
|
-
end
|
72
|
-
clean_obj.merge!(data_obj)
|
73
|
-
end
|
74
|
-
obj = clean_obj
|
75
|
-
end
|
76
|
-
JSON.pretty_generate(obj)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
|
80
|
-
# rubocop:enable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
|
81
|
-
|
82
|
-
# rubocop:disable Style/IdenticalConditionalBranches
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
# rubocop:
|
109
|
-
|
110
|
-
|
111
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OutputConverters
|
4
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
|
5
|
+
# rubocop:disable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
|
6
|
+
def to_output_hash(obj)
|
7
|
+
diplay_nulls = (ENV.fetch('EMASSER_CLI_DISPLAY_NULL', 'true').eql? 'true') ? true : false
|
8
|
+
diplay_datetime = (ENV.fetch('EMASSER_EPOCH_TO_DATETIME', 'false').eql? 'true') ? true : false
|
9
|
+
|
10
|
+
if obj.to_s.include? 'Error message'
|
11
|
+
begin
|
12
|
+
index = obj.to_s.index('Response body')+14
|
13
|
+
arr_obj = obj.to_s[index, obj.to_s.size - index]
|
14
|
+
JSON.pretty_generate(JSON.parse(arr_obj))
|
15
|
+
rescue
|
16
|
+
obj
|
17
|
+
end
|
18
|
+
else
|
19
|
+
obj = obj.to_body if obj.respond_to?(:to_body)
|
20
|
+
if !diplay_nulls
|
21
|
+
clean_obj = {}
|
22
|
+
data_obj = {}
|
23
|
+
obj.each do |key, value|
|
24
|
+
if key.to_s.include?('meta')
|
25
|
+
obj_entry = {}
|
26
|
+
obj_entry[:meta] = value
|
27
|
+
clean_obj.merge!(obj_entry)
|
28
|
+
elsif key.to_s.include?('data')
|
29
|
+
if value.is_a?(Array)
|
30
|
+
hash_array = []
|
31
|
+
value.each do |elements|
|
32
|
+
hash_array << elements.compact
|
33
|
+
end
|
34
|
+
data_obj['data'] = hash_array
|
35
|
+
else
|
36
|
+
data_obj['data'] = value.nil? ? value : value.compact
|
37
|
+
end
|
38
|
+
elsif key.to_s.include?('pagination')
|
39
|
+
pg_obj = {}
|
40
|
+
pg_obj[:pagination] = value
|
41
|
+
data_obj.merge!(pg_obj)
|
42
|
+
end
|
43
|
+
clean_obj.merge!(data_obj)
|
44
|
+
end
|
45
|
+
obj = clean_obj
|
46
|
+
end
|
47
|
+
|
48
|
+
if diplay_datetime
|
49
|
+
clean_obj = {}
|
50
|
+
data_obj = {}
|
51
|
+
obj.each do |key, value|
|
52
|
+
if key.to_s.include?('meta')
|
53
|
+
obj_entry = {}
|
54
|
+
obj_entry[:meta] = value
|
55
|
+
clean_obj.merge!(obj_entry)
|
56
|
+
elsif key.to_s.include?('data')
|
57
|
+
if value.is_a?(Array)
|
58
|
+
hash_array = []
|
59
|
+
value.each do |element|
|
60
|
+
datetime_obj = change_to_datetime(element)
|
61
|
+
hash_array << datetime_obj
|
62
|
+
end
|
63
|
+
data_obj['data'] = hash_array
|
64
|
+
else
|
65
|
+
data_obj['data'] = change_to_datetime(value)
|
66
|
+
end
|
67
|
+
elsif key.to_s.include?('pagination')
|
68
|
+
pg_obj = {}
|
69
|
+
pg_obj[:pagination] = value
|
70
|
+
data_obj.merge!(pg_obj)
|
71
|
+
end
|
72
|
+
clean_obj.merge!(data_obj)
|
73
|
+
end
|
74
|
+
obj = clean_obj
|
75
|
+
end
|
76
|
+
JSON.pretty_generate(obj)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Style/TernaryParentheses
|
80
|
+
# rubocop:enable Style/IfWithBooleanLiteralBranches, Style/RescueStandardError, Metrics/BlockNesting
|
81
|
+
|
82
|
+
# rubocop:disable Style/IdenticalConditionalBranches
|
83
|
+
# rubocop:disable Performance/RedundantMatch, Performance/RegexpMatch
|
84
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
85
|
+
def change_to_datetime(obj)
|
86
|
+
if obj.nil? || obj.is_a?(String)
|
87
|
+
return obj
|
88
|
+
end
|
89
|
+
|
90
|
+
data_obj = {}
|
91
|
+
obj.each do |key, value|
|
92
|
+
obj_entry = {}
|
93
|
+
if value.is_a?(Array)
|
94
|
+
hash_array = []
|
95
|
+
value.each do |element|
|
96
|
+
hash_array << change_to_datetime(element)
|
97
|
+
end
|
98
|
+
obj_entry[key] = hash_array
|
99
|
+
data_obj.merge!(obj_entry)
|
100
|
+
else
|
101
|
+
if /(DATE|TIMESTAMP|LASTSEEN|TIME|ATD)/.match(key.to_s.upcase)
|
102
|
+
value = value.nil? ? value : Time.at(value.to_i)
|
103
|
+
end
|
104
|
+
obj_entry[key] = value
|
105
|
+
data_obj.merge!(obj_entry)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
# rubocop:disable Style/RedundantReturn
|
109
|
+
return data_obj
|
110
|
+
# rubocop:enable Style/RedundantReturn
|
111
|
+
end
|
112
|
+
# rubocop:enable Style/IdenticalConditionalBranches
|
113
|
+
# rubocop:enable Performance/RedundantMatch, Performance/RegexpMatch
|
114
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
115
|
+
end
|