emasser 3.4.1 → 3.12.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 +66 -16
- data/Dockerfile +44 -44
- data/Gemfile +8 -8
- data/Gemfile.lock +108 -104
- data/LICENSE.md +15 -15
- data/README.md +179 -178
- data/Rakefile +18 -18
- data/_config.yml +1 -1
- data/docs/features.md +1677 -1437
- 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 +22 -26
- data/lib/emasser/delete.rb +210 -148
- data/lib/emasser/errors.rb +14 -14
- data/lib/emasser/get.rb +1401 -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 +125 -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,125 @@
|
|
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/
|
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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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/RedundantReturn
|
83
|
+
# rubocop:disable Style/IdenticalConditionalBranches
|
84
|
+
# rubocop:disable Metrics/BlockNesting, Style/RescueStandardError
|
85
|
+
# rubocop:disable Performance/RedundantMatch, Performance/RegexpMatch
|
86
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
87
|
+
def change_to_datetime(obj)
|
88
|
+
if obj.nil? || obj.is_a?(String)
|
89
|
+
return obj
|
90
|
+
end
|
91
|
+
|
92
|
+
data_obj = {}
|
93
|
+
obj.each do |key, value|
|
94
|
+
obj_entry = {}
|
95
|
+
if value.is_a?(Array)
|
96
|
+
hash_array = []
|
97
|
+
value.each do |element|
|
98
|
+
hash_array << change_to_datetime(element)
|
99
|
+
end
|
100
|
+
obj_entry[key] = hash_array
|
101
|
+
data_obj.merge!(obj_entry)
|
102
|
+
else
|
103
|
+
date_value = value
|
104
|
+
if /(DATE|TIMESTAMP|LASTSEEN|TIME|ATD)/.match(key.to_s.upcase)
|
105
|
+
begin
|
106
|
+
date_value = Integer(value)
|
107
|
+
if date_value > 100000000
|
108
|
+
date_value = value.nil? ? value : Time.at(date_value)
|
109
|
+
end
|
110
|
+
rescue
|
111
|
+
date_value
|
112
|
+
end
|
113
|
+
end
|
114
|
+
obj_entry[key] = date_value
|
115
|
+
data_obj.merge!(obj_entry)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
return data_obj
|
119
|
+
end
|
120
|
+
# rubocop:enable Style/RedundantReturn
|
121
|
+
# rubocop:enable Style/IdenticalConditionalBranches
|
122
|
+
# rubocop:enable Metrics/BlockNesting, Style/RescueStandardError
|
123
|
+
# rubocop:enable Performance/RedundantMatch, Performance/RegexpMatch
|
124
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
125
|
+
end
|