ruby-jss 2.1.0b5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +3 -1
- data/bin/cgrouper +3 -6
- data/bin/netseg-update +9 -5
- data/lib/jamf/api/classic/api_objects/computer.rb +1 -1
- data/lib/jamf/api/classic/api_objects/patch_title.rb +4 -4
- data/lib/jamf/api/classic/xml_workaround.rb +3 -1
- data/lib/jamf/api/connection/attributes.rb +8 -8
- data/lib/jamf/api/connection/classic_api.rb +10 -1
- data/lib/jamf/api/connection/constants.rb +2 -0
- data/lib/jamf/api/connection/jamf_pro_api.rb +7 -1
- data/lib/jamf/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 970c4289986bb3f0b3ea9a60b31777a29b4c927879a3204d28c3f9bdd46a2a9f
|
4
|
+
data.tar.gz: f75ae4ae8ba5bd0cfadb065c62f495fcb4eea86b2473aa5d8357569e9ce49059
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b86acc435cc02cdd0976361305331b4bf98b176fd25c8accb791cfba794c7bdf6d42d94d62cc76b11cb510e9c3ac23495ac99aa244e76a39e5e6e061aeeae4a8
|
7
|
+
data.tar.gz: 31f95548e2cb64bedb1781977222c705183c3e866ce8c8a9fb5532dfdbdeabe11d59faa92818c8506d5235d2fc868d1eb58d949b17ecc5f6c3d66bafde910750
|
data/CHANGES.md
CHANGED
@@ -14,7 +14,7 @@ __Please update all installations of ruby-jss to at least v1.6.0.__
|
|
14
14
|
|
15
15
|
Many many thanks to actae0n of Blacksun Hackers Club for reporting this issue and providing examples of how it could be exploited.
|
16
16
|
|
17
|
-
## \[2.1.0] -
|
17
|
+
## \[2.1.0] - 2022-10-10
|
18
18
|
|
19
19
|
### Added
|
20
20
|
|
@@ -34,6 +34,8 @@ Many many thanks to actae0n of Blacksun Hackers Club for reporting this issue an
|
|
34
34
|
- A few internal rescues of a deprecated exception class
|
35
35
|
- Removed auto-loading of deprecation files; now explicitly loaded.
|
36
36
|
- A few Ruby 2 => Ruby 3 bugs - method params needing double-splats (Thanks to @Timelost for reporting this one)
|
37
|
+
- Ensure resource paths don't start with a slash
|
38
|
+
- Setting the timeouts on an existing API connection object now works.
|
37
39
|
|
38
40
|
## \[2.0.0] - 2022-09-12
|
39
41
|
|
data/bin/cgrouper
CHANGED
@@ -55,7 +55,7 @@ class App
|
|
55
55
|
###
|
56
56
|
### set up
|
57
57
|
###
|
58
|
-
def initialize
|
58
|
+
def initialize
|
59
59
|
@debug = false
|
60
60
|
|
61
61
|
# define the options
|
@@ -207,7 +207,7 @@ class App
|
|
207
207
|
|
208
208
|
# smart groups can't have some things done to them
|
209
209
|
if ACTIONS_FOR_STATIC_GROUPS_ONLY.include? @options.action and @group.smart?
|
210
|
-
raise InvalidTypeError,
|
210
|
+
raise InvalidTypeError,
|
211
211
|
"You can't do that to a smart group. Use the JSS WebApp if needed."
|
212
212
|
end
|
213
213
|
|
@@ -384,7 +384,6 @@ Notes:
|
|
384
384
|
return unless @options.action == :create_group or confirm "add computers to group '#{@group.name}'"
|
385
385
|
|
386
386
|
@options.computers.each do |c|
|
387
|
-
|
388
387
|
@group.add_member c
|
389
388
|
rescue JSS::NoSuchItemError
|
390
389
|
puts "#{$!} - skipping"
|
@@ -404,11 +403,9 @@ Notes:
|
|
404
403
|
return unless confirm "remove computers from group '#{@group.name}'"
|
405
404
|
|
406
405
|
@options.computers.each do |c|
|
407
|
-
|
408
406
|
@group.remove_member c
|
409
407
|
rescue JSS::NoSuchItemError
|
410
408
|
puts "#{$!} - skipping"
|
411
|
-
|
412
409
|
end
|
413
410
|
@group.update
|
414
411
|
end
|
@@ -459,7 +456,7 @@ end # class App
|
|
459
456
|
|
460
457
|
#######################################
|
461
458
|
begin
|
462
|
-
app = App.new
|
459
|
+
app = App.new
|
463
460
|
app.run
|
464
461
|
rescue
|
465
462
|
# handle exceptions not handled elsewhere
|
data/bin/netseg-update
CHANGED
@@ -55,13 +55,13 @@ class App
|
|
55
55
|
|
56
56
|
USAGE = "Usage: #{PROG_NAME} [options] [--help] /path/to/file".freeze
|
57
57
|
|
58
|
-
POTENTIAL_COLUMNS = %i
|
58
|
+
POTENTIAL_COLUMNS = %i[name starting ending cidr mask].freeze
|
59
59
|
|
60
60
|
DEFAULT_CACHE_FILE = Pathname.new('~/.last_subnet_update').expand_path
|
61
61
|
|
62
62
|
DEFAULT_DELIMITER = "\t".freeze
|
63
63
|
|
64
|
-
DEFAULT_COLUMNS = [
|
64
|
+
DEFAULT_COLUMNS = %i[name starting ending].freeze
|
65
65
|
|
66
66
|
DEFAULT_MANUAL_PREFIX = 'Manual-'.freeze
|
67
67
|
|
@@ -84,7 +84,7 @@ class App
|
|
84
84
|
|
85
85
|
attr_reader :debug
|
86
86
|
|
87
|
-
def initialize
|
87
|
+
def initialize
|
88
88
|
@getpass = $stdin.tty? ? :prompt : :stdin
|
89
89
|
set_defaults
|
90
90
|
parse_cli
|
@@ -183,7 +183,7 @@ Options:
|
|
183
183
|
-V, --no-verify-cert - Allow self-signed, unverified SSL certificate
|
184
184
|
-T, --timeout secs - specify the JSS API timeout
|
185
185
|
-N, --no-op - Don't make any changes in the JSS, just report what would
|
186
|
-
have
|
186
|
+
have been changed.
|
187
187
|
-H, --help - show this help
|
188
188
|
--debug - show the ruby backtrace when errors occur
|
189
189
|
|
@@ -254,6 +254,7 @@ Notes:
|
|
254
254
|
lines.each do |line|
|
255
255
|
parsed_line = parse_a_data_line line
|
256
256
|
next unless parsed_line
|
257
|
+
|
257
258
|
name = parsed_line.delete :name
|
258
259
|
parsed_data[name] = parsed_line
|
259
260
|
end
|
@@ -273,6 +274,7 @@ Notes:
|
|
273
274
|
@columns.include?(:ending) || \
|
274
275
|
@columns.include?(:cidr) || \
|
275
276
|
@columns.include?(:mask)
|
277
|
+
|
276
278
|
@use_cidr = (@columns.include?(:cidr) || @columns.include?(:mask))
|
277
279
|
end
|
278
280
|
|
@@ -296,11 +298,13 @@ Notes:
|
|
296
298
|
# read in the file
|
297
299
|
@raw_data = @file.read
|
298
300
|
return true unless @cache_file.exist?
|
301
|
+
|
299
302
|
@raw_data != @cache_file.read
|
300
303
|
end
|
301
304
|
|
302
305
|
def cache_latest_data
|
303
306
|
return if @noop
|
307
|
+
|
304
308
|
@cache_file.jss_save @raw_data
|
305
309
|
end
|
306
310
|
|
@@ -375,7 +379,7 @@ end # app
|
|
375
379
|
# create the app and go
|
376
380
|
begin
|
377
381
|
debug = ARGV.include? '--debug'
|
378
|
-
app = App.new
|
382
|
+
app = App.new
|
379
383
|
app.run
|
380
384
|
rescue
|
381
385
|
# handle exceptions not handled elsewhere
|
@@ -440,7 +440,7 @@ module Jamf
|
|
440
440
|
cnx = api if api
|
441
441
|
|
442
442
|
id = valid_id ident, cnx: cnx
|
443
|
-
raise "No computer matches identifier: #{ident}" unless id
|
443
|
+
raise Jamf::NoSuchItemError, "No computer matches identifier: #{ident}" unless id
|
444
444
|
|
445
445
|
end_date ||= start_date
|
446
446
|
start_date = Jamf.parse_time start_date
|
@@ -154,7 +154,7 @@ module Jamf
|
|
154
154
|
# when fetching a specific version, this is a valid version
|
155
155
|
UNKNOWN_VERSION_ID = 'Unknown'.freeze
|
156
156
|
|
157
|
-
REPORTS_RSRC_BASE = '
|
157
|
+
REPORTS_RSRC_BASE = 'patchreports/patchsoftwaretitleid'.freeze
|
158
158
|
|
159
159
|
# Class Methods
|
160
160
|
#######################################
|
@@ -233,7 +233,7 @@ module Jamf
|
|
233
233
|
all(refresh, cnx: cnx).map { |i| i[:source_name_id] }
|
234
234
|
end
|
235
235
|
|
236
|
-
# Get a patch report for a softwaretitle,
|
236
|
+
# Get a patch report for a softwaretitle, without fetching an instance.
|
237
237
|
# Defaults to reporting all versions. Specifiying a version will be faster.
|
238
238
|
#
|
239
239
|
# The Hash returned has 3 keys:
|
@@ -269,6 +269,7 @@ module Jamf
|
|
269
269
|
|
270
270
|
# TODO: remove this and adjust parsing when jamf fixes the JSON
|
271
271
|
raw_report = XMLWorkaround.data_via_xml(rsrc, PATCH_REPORT_DATA_MAP, cnx)[:patch_report]
|
272
|
+
|
272
273
|
report = {}
|
273
274
|
report[:total_computers] = raw_report[:total_computers]
|
274
275
|
report[:total_versions] = raw_report[:total_versions]
|
@@ -312,7 +313,7 @@ module Jamf
|
|
312
313
|
# so all other lookup values have to be converted to ID before
|
313
314
|
# the call to super
|
314
315
|
#
|
315
|
-
def self.fetch(identifier = nil, **params)
|
316
|
+
def self.fetch(identifier = nil, **params)
|
316
317
|
# default connection if unspecified
|
317
318
|
cnx = params.delete :cnx
|
318
319
|
cnx ||= params.delete :api # backward compatibility, deprecated
|
@@ -472,7 +473,6 @@ module Jamf
|
|
472
473
|
# wrapper to fetch versions after creating
|
473
474
|
def create
|
474
475
|
super
|
475
|
-
|
476
476
|
end
|
477
477
|
|
478
478
|
# wrapper to clear @changed_pkgs after updating
|
@@ -150,7 +150,8 @@ module Jamf
|
|
150
150
|
element ? element.text.to_f : model
|
151
151
|
when nil
|
152
152
|
return nil unless element
|
153
|
-
|
153
|
+
|
154
|
+
element.text.downcase == TRUE_STRING
|
154
155
|
when Array
|
155
156
|
element ? elem_as_array(model.first, element) : []
|
156
157
|
when Hash
|
@@ -176,6 +177,7 @@ module Jamf
|
|
176
177
|
return unless size_elems.count == 1
|
177
178
|
return if size_elem.has_elements?
|
178
179
|
return unless size_elem.text.jss_integer?
|
180
|
+
|
179
181
|
elem.delete_element size_elem
|
180
182
|
end
|
181
183
|
|
@@ -74,15 +74,15 @@ module Jamf
|
|
74
74
|
attr_reader :sticky_session
|
75
75
|
alias sticky_session? sticky_session
|
76
76
|
alias sticky? sticky_session
|
77
|
-
|
77
|
+
|
78
78
|
# @return [String, nil] The current sticky_session cookie. nil unless
|
79
79
|
# sticky_session is set to true, either as a param to 'connect' or via
|
80
80
|
# #sticky_session=
|
81
81
|
#
|
82
|
-
# When set via .connect, the cookie is gleaned from the token creation
|
82
|
+
# When set via .connect, the cookie is gleaned from the token creation
|
83
83
|
# reponse. When set via #sticky_session=, a HEAD request is made, and the
|
84
84
|
# cookie will be in the response.
|
85
|
-
#
|
85
|
+
#
|
86
86
|
# Only valid when the connection is to a Jamf Cloud server.
|
87
87
|
attr_reader :sticky_session_cookie
|
88
88
|
|
@@ -100,7 +100,7 @@ module Jamf
|
|
100
100
|
|
101
101
|
# convert boolean-y to boolean
|
102
102
|
value = value ? true : false
|
103
|
-
|
103
|
+
|
104
104
|
return if @sticky_session == value
|
105
105
|
|
106
106
|
if value
|
@@ -125,8 +125,8 @@ module Jamf
|
|
125
125
|
#
|
126
126
|
def timeout=(new_timeout)
|
127
127
|
@timeout = new_timeout.to_i
|
128
|
-
@c_cnx
|
129
|
-
@jp_cnx
|
128
|
+
@c_cnx.options.timeout = @timeout if @c_cnx
|
129
|
+
@jp_cnx.options.timeout = @timeout if @jp_cnx
|
130
130
|
end
|
131
131
|
|
132
132
|
# Reset the open-connection timeout for the rest connection
|
@@ -137,8 +137,8 @@ module Jamf
|
|
137
137
|
#
|
138
138
|
def open_timeout=(new_timeout)
|
139
139
|
@open_timeout = new_timeout.to_i
|
140
|
-
@c_cnx
|
141
|
-
@jp_cnx
|
140
|
+
@c_cnx.options.open_timeout = @open_timeout if @c_cnx
|
141
|
+
@jp_cnx.options.open_timeout = @open_timeout if @jp_cnx
|
142
142
|
end
|
143
143
|
|
144
144
|
# @return [URI::HTTPS] the base URL to the server
|
@@ -59,6 +59,8 @@ module Jamf
|
|
59
59
|
# @return [Hash,String] the result of the get
|
60
60
|
#
|
61
61
|
def c_get(rsrc, format = :json, raw_json: false)
|
62
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
63
|
+
|
62
64
|
validate_connected @c_cnx
|
63
65
|
raise Jamf::InvalidDataError, 'format must be :json or :xml' unless Jamf::Connection::GET_FORMATS.include?(format)
|
64
66
|
|
@@ -92,6 +94,8 @@ module Jamf
|
|
92
94
|
def c_post(rsrc, xml)
|
93
95
|
validate_connected @c_cnx
|
94
96
|
|
97
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
98
|
+
|
95
99
|
# convert CRs & to
|
96
100
|
xml&.gsub!(/\r/, ' ')
|
97
101
|
|
@@ -125,6 +129,8 @@ module Jamf
|
|
125
129
|
def c_put(rsrc, xml)
|
126
130
|
validate_connected @c_cnx
|
127
131
|
|
132
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
133
|
+
|
128
134
|
# convert CRs & to
|
129
135
|
xml.gsub!(/\r/, ' ')
|
130
136
|
|
@@ -157,6 +163,8 @@ module Jamf
|
|
157
163
|
validate_connected @c_cnx
|
158
164
|
raise MissingDataError, 'Missing :rsrc' if rsrc.nil?
|
159
165
|
|
166
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
167
|
+
|
160
168
|
# delete the resource
|
161
169
|
resp =
|
162
170
|
@c_cnx.delete(rsrc) do |req|
|
@@ -188,6 +196,7 @@ module Jamf
|
|
188
196
|
#
|
189
197
|
def upload(rsrc, local_file)
|
190
198
|
validate_connected @c_cnx
|
199
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
191
200
|
|
192
201
|
# the upload file object for faraday
|
193
202
|
local_file = Pathname.new local_file
|
@@ -223,7 +232,7 @@ module Jamf
|
|
223
232
|
|
224
233
|
cnx.options[:timeout] = @timeout
|
225
234
|
cnx.options[:open_timeout] = @open_timeout
|
226
|
-
|
235
|
+
|
227
236
|
cnx.request :multipart
|
228
237
|
cnx.request :url_encoded
|
229
238
|
|
@@ -53,11 +53,12 @@ module Jamf
|
|
53
53
|
|
54
54
|
# @param rsrc[String] the resource to get
|
55
55
|
# (the part of the API url after the '/api/' )
|
56
|
-
|
56
|
+
|
57
57
|
# @return [Hash] the result of the get
|
58
58
|
#######################################################
|
59
59
|
def jp_get(rsrc)
|
60
60
|
validate_connected @jp_cnx
|
61
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
61
62
|
resp = @jp_cnx.get(rsrc) do |req|
|
62
63
|
# Modify the request here if needed.
|
63
64
|
# puts "JPAPI Cookie is: #{req.headers['Cookie']}"
|
@@ -82,6 +83,7 @@ module Jamf
|
|
82
83
|
#######################################################
|
83
84
|
def jp_post(rsrc, data)
|
84
85
|
validate_connected @jp_cnx
|
86
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
85
87
|
resp = @jp_cnx.post(rsrc) do |req|
|
86
88
|
req.body = data
|
87
89
|
end
|
@@ -104,6 +106,7 @@ module Jamf
|
|
104
106
|
#######################################################
|
105
107
|
def jp_put(rsrc, data)
|
106
108
|
validate_connected @jp_cnx
|
109
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
107
110
|
resp = @jp_cnx.put(rsrc) do |req|
|
108
111
|
req.body = data
|
109
112
|
end
|
@@ -126,6 +129,7 @@ module Jamf
|
|
126
129
|
#######################################################
|
127
130
|
def jp_patch(rsrc, data)
|
128
131
|
validate_connected @jp_cnx
|
132
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
129
133
|
resp = @jp_cnx.patch(rsrc) do |req|
|
130
134
|
req.body = data
|
131
135
|
end
|
@@ -146,6 +150,7 @@ module Jamf
|
|
146
150
|
#######################################################
|
147
151
|
def jp_delete(rsrc)
|
148
152
|
validate_connected @jp_cnx
|
153
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
149
154
|
resp = @jp_cnx.delete rsrc
|
150
155
|
@last_http_response = resp
|
151
156
|
return resp.body if resp.success?
|
@@ -159,6 +164,7 @@ module Jamf
|
|
159
164
|
# a temporary Faraday connection object
|
160
165
|
#######################################################
|
161
166
|
def jp_download(rsrc)
|
167
|
+
rsrc = rsrc.delete_prefix Jamf::Connection::SLASH
|
162
168
|
temp_cnx = create_jp_connection(parse_json: false)
|
163
169
|
resp = temp_cnx.get rsrc
|
164
170
|
@last_http_response = resp
|
data/lib/jamf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: CFPropertyList
|
@@ -824,9 +824,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
824
824
|
version: 2.6.3
|
825
825
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
826
826
|
requirements:
|
827
|
-
- - "
|
827
|
+
- - ">="
|
828
828
|
- !ruby/object:Gem::Version
|
829
|
-
version:
|
829
|
+
version: '0'
|
830
830
|
requirements: []
|
831
831
|
rubygems_version: 3.0.3.1
|
832
832
|
signing_key:
|