varanus 0.5.1 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c52ba9ede6f495a05841bacfbf3046cb41b45cd8bb1d4ef8a1c7491e735644
4
- data.tar.gz: 921e5bd93bf8caa0378ba15f45276b8100c19239d28e3e22b68e3ae76fa85da1
3
+ metadata.gz: 0b74f92a4981ac8294eb1fe84c4361f1dc3a175be3735f7d485f7b5edd9963aa
4
+ data.tar.gz: 5a38ba280217b30fe842a99786acf761f081d135f1180cb3950bfbab5f50904a
5
5
  SHA512:
6
- metadata.gz: c2cf7fd0e7ec49ec4b9f6bdef82aae9f7cf8d05f0343cce7d8595dfd6a975cf0fc983045997ec0f6cbc8425b8935ff66bc3a7846cd321a55789508cb4ee03fce
7
- data.tar.gz: c02ba0dfc6a9132204d50f3bc1453b878c73f34ca981ead6ffd29c35bc91fe637922085ac28ceb831fa0b22fe5fe1a3b61679314b99255e00774346689dc31d8
6
+ metadata.gz: 02ece0e219a9f47fe84ec8faaf406194f13082a1797793c23760643b8547140307fc243550e7d36d1d8412ca586850d0535a419a2dc50a9b7b90a4e4f660af67
7
+ data.tar.gz: 80435d29c565a99a191a85938ae4a505b01c68a38c608d063e9c10809d4eae1c2a8cad9872a9cc3f5b518a9e1084e7c625a40f287e66e1c17900ae659200095c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### Version 0.6.0 (2020-02-01)
2
+ * Add Varanus::SSL#report
3
+ * Varanus::Reports (Varanus#reports) is now deprecated.
4
+
1
5
  ### Version 0.5.1 (2021-01-28)
2
6
  * Varanus::SSL::CSR - support EC certs
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- varanus (0.5.1)
4
+ varanus (0.6.0)
5
5
  faraday
6
6
  faraday_middleware
7
7
  savon (~> 2.0)
data/lib/varanus.rb CHANGED
@@ -47,8 +47,7 @@ class Varanus
47
47
  @organization ||= Organization.new(self)
48
48
  end
49
49
 
50
- # Retrieve Reports instance
51
- # @return [Varanus::Reports]
50
+ # DEPRECATED
52
51
  def reports
53
52
  @reports ||= Reports.new(self)
54
53
  end
@@ -18,20 +18,19 @@ class Varanus::Reports
18
18
  @varanus = varanus
19
19
  end
20
20
 
21
+ # DEPRECATED: Please use Varanus::Domain#list_with_info instead.
21
22
  def domains
23
+ warn 'DEPRECATION WARNING: Varanus::Reports#domains is deprecated. ' \
24
+ 'Use Varanus::Domain#list_with_info instead'
22
25
  r = soap_call :get_domain_report, {}
23
26
  format_results r[:report_row_domains]
24
27
  end
25
28
 
26
- # Return report on SSL request
27
- # @param [opts] [Hash]
28
- # @option opts [String, Array] :orgs Name(s) of organizations (departments) to limit
29
- # the report to. If this is unset, results from all departments are returned.
30
- # @option opts [Symbol] :status (:any) One of :any, :requested, :downloaded, :revoked,
31
- # :expired, :pending_download, :not_enrolled. :downloaded and :pending_download
32
- # mean the cert has been enrolled/signed.
33
- # @return [Array<Hash>]
29
+ # DEPRECATED: Please use Varanus::SSL#report instead.
34
30
  def ssl opts = {}
31
+ warn 'DEPRECATION WARNING: Varanus::Reports#ssl is deprecated. ' \
32
+ 'Use Varanus::SSL#report instead'
33
+
35
34
  msg = { organizationNames: nil, certificateStatus: 0 }
36
35
 
37
36
  msg[:organizationNames] = Array(opts[:orgs]).join(',') if opts.include? :orgs
data/lib/varanus/ssl.rb CHANGED
@@ -3,6 +3,23 @@
3
3
  # An connection to the SSL/TSL API. This should not be initialized directly. Instead,
4
4
  # use Varanus#ssl
5
5
  class Varanus::SSL < Varanus::RestResource
6
+ # rubocop:disable Style/MutableConstant
7
+ # These constants are frozen, rubocop is failing to detect the freeze.
8
+ # See https://github.com/rubocop-hq/rubocop/issues/4406
9
+ REPORT_CERT_STATUS = { any: 0, requested: 1, issued: 2, revoked: 3, expired: 4 }
10
+ REPORT_CERT_STATUS.default_proc = proc { |_h, k|
11
+ raise ArgumentError, "Unknown certificateStatus: #{k.inspect}"
12
+ }
13
+ REPORT_CERT_STATUS.freeze
14
+
15
+ REPORT_CERT_DATE_ATTR = { revocation_date: 2, expiration_date: 3, request_date: 4,
16
+ issue_date: 5 }
17
+ REPORT_CERT_DATE_ATTR.default_proc = proc { |_h, k|
18
+ raise ArgumentError, "Unknown certificateDateAttribute: #{k.inspect}"
19
+ }
20
+ REPORT_CERT_DATE_ATTR.freeze
21
+ # rubocop:enable Style/MutableConstant
22
+
6
23
  # Returns the option from #certificate_types that best matches the csr.
7
24
  # @param csr [Varanus::SSL::CSR]
8
25
  # @return [Hash] The option from {#certificate_types} that best matches the csr
@@ -60,10 +77,31 @@ class Varanus::SSL < Varanus::RestResource
60
77
  get("ssl/v1/#{id}")
61
78
  end
62
79
 
80
+ # List certs ids and serial numbers
63
81
  def list opts = {}
64
82
  get_with_size_and_position('ssl/v1', opts)
65
83
  end
66
84
 
85
+ # Return a report (list) of SSL certs based on the options.
86
+ # The report includes a full set of details about the certs, not just the id/cn/serial
87
+ # +opts+ can include:
88
+ # (all are optional)
89
+ # - :organizationIds - Array - ids of organization/departments to include certs for
90
+ # - :certificateStatus - :any, :requested, :issued, :revoked, or :expired
91
+ # - :certificateDateAttribute - Specifies what fields :from and/or :to refer to.
92
+ # Can be: :revocation_date, :expiration_date,
93
+ # :request_date, or :issue_date
94
+ # - :from - Date - based on :certificateDateAttribute
95
+ # - :to - Date - based on :certificateDateAttribute
96
+ def report opts = { certificateStatus: :any }
97
+ # Default is to request any certificate status since the API call will fail if no
98
+ # options are passed
99
+ opts = { certificateStatus: :any } if opts.empty?
100
+ opts = _parse_report_opts(opts)
101
+
102
+ post('report/v1/ssl-certificates', opts)['reports']
103
+ end
104
+
67
105
  # Revoke an ssl cert
68
106
  # @param id [Integer] As returned by {#sign}
69
107
  # @param reason [String] Reason for revoking. Sectigo's API will return an error if it
@@ -130,4 +168,24 @@ class Varanus::SSL < Varanus::RestResource
130
168
  term ||= certificate_types.find { |ct| ct['id'] == cert_type_id }['terms'].min
131
169
  term
132
170
  end
171
+
172
+ def _parse_report_opts user_opts
173
+ api_opts = {}
174
+ user_opts.each do |key, val|
175
+ case key
176
+ when :organizationIds, :certificateRequestSource, :serialNumberFormat
177
+ api_opts[key] = val
178
+ when :from, :to
179
+ api_opts[key] = val.strftime('%Y-%m-%d')
180
+ when :certificateStatus
181
+ api_opts[key] = REPORT_CERT_STATUS[val]
182
+ when :certificateDateAttribute
183
+ api_opts[key] = REPORT_CERT_DATE_ATTR[val]
184
+ else
185
+ raise ArgumentError, "Unknown key: #{key.inspect}"
186
+ end
187
+ end
188
+
189
+ api_opts
190
+ end
133
191
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Varanus
4
- VERSION = '0.5.1'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: varanus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Dilda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-28 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler