chook 1.0.1.b1 → 1.1.5b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +56 -0
- data/README.md +397 -145
- data/bin/chook-server +31 -1
- data/data/chook.conf.example +183 -0
- data/data/com.pixar.chook-server.plist +20 -0
- data/data/sample_handlers/RestAPIOperation.rb +11 -11
- data/data/sample_handlers/SmartGroupComputerMembershipChange.rb +3 -6
- data/data/sample_jsons/SmartGroupComputerMembershipChange.json +3 -1
- data/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +3 -1
- data/lib/chook/configuration.rb +27 -8
- data/lib/chook/event.rb +6 -1
- data/lib/chook/event/handled_event.rb +36 -9
- data/lib/chook/event/handled_event/handlers.rb +252 -99
- data/lib/chook/event/handled_event_logger.rb +86 -0
- data/lib/chook/event_handling.rb +1 -0
- data/lib/chook/foundation.rb +3 -0
- data/lib/chook/procs.rb +17 -1
- data/lib/chook/server.rb +73 -72
- data/lib/chook/server/auth.rb +164 -0
- data/lib/chook/server/log.rb +215 -0
- data/lib/chook/server/public/css/chook.css +133 -0
- data/lib/chook/server/public/imgs/ChookLogoAlMcWhiggin.png +0 -0
- data/lib/chook/server/public/js/chook.js +126 -0
- data/lib/chook/server/public/js/logstream.js +101 -0
- data/lib/chook/server/routes.rb +28 -0
- data/lib/chook/server/routes/handle_by_name.rb +65 -0
- data/lib/chook/server/routes/handle_webhook_event.rb +27 -3
- data/lib/chook/server/routes/handlers.rb +52 -0
- data/lib/chook/server/routes/home.rb +48 -1
- data/lib/chook/server/routes/log.rb +105 -0
- data/lib/chook/server/routes/login_logout.rb +48 -0
- data/lib/chook/server/views/admin.haml +11 -0
- data/lib/chook/server/views/bak.haml +48 -0
- data/lib/chook/server/views/config.haml +15 -0
- data/lib/chook/server/views/handlers.haml +63 -0
- data/lib/chook/server/views/layout.haml +64 -0
- data/lib/chook/server/views/logstream.haml +33 -0
- data/lib/chook/server/views/sketch_admin +44 -0
- data/lib/chook/subject.rb +13 -2
- data/lib/chook/subject/dep_device.rb +81 -0
- data/lib/chook/subject/policy_finished.rb +43 -0
- data/lib/chook/subject/smart_group.rb +6 -0
- data/lib/chook/subject/test_subject.rb +2 -2
- data/lib/chook/version.rb +1 -1
- metadata +78 -17
@@ -0,0 +1,33 @@
|
|
1
|
+
.section_label#log_label
|
2
|
+
%button#view_log_btn{ type: 'button', onClick: 'view_log();', title: 'view the live Chook log' }
|
3
|
+
View
|
4
|
+
%button#hide_log_btn{ type: 'button', onClick: 'hide_log();', title: 'hide the live Chook log' }
|
5
|
+
Hide
|
6
|
+
|
7
|
+
|
8
|
+
The Live Chook Log
|
9
|
+
|
10
|
+
Server Log Level:
|
11
|
+
%select#log_level_select{ onchange: 'change_log_level();',
|
12
|
+
title: 'changes here affect logging the server, not just your view' }
|
13
|
+
|
14
|
+
%option{ value: 'fatal', selected: Chook.logger.level == Logger::FATAL } fatal
|
15
|
+
%option{ value: 'error', selected: Chook.logger.level == Logger::ERROR } error
|
16
|
+
%option{ value: 'warn', selected: Chook.logger.level == Logger::WARN } warn
|
17
|
+
%option{ value: 'info', selected: Chook.logger.level == Logger::INFO } info
|
18
|
+
%option{ value: 'debug', selected: Chook.logger.level == Logger::DEBUG } debug
|
19
|
+
|
20
|
+
#logbox_div
|
21
|
+
#logbox_btns
|
22
|
+
%input#pause_log{ type: 'checkbox', checked: false, onclick: 'update_logbox();' }
|
23
|
+
Pause
|
24
|
+
|
25
|
+
|
26
|
+
%button#clear_log_btn{ type: 'button', onClick: 'clear_log();', title: 'clear the live Chook log' }
|
27
|
+
Clear
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
%textarea.monospaced#logbox{ readonly: true, rows: 20 }
|
@@ -0,0 +1,44 @@
|
|
1
|
+
[image] Chook v.XXX
|
2
|
+
|
3
|
+
|
4
|
+
Log (view/hide) Log Level: [popup list] (set)
|
5
|
+
--------- hidable text area with streaming log -----------
|
6
|
+
|
7
|
+
|
8
|
+
Current Handlers
|
9
|
+
filename/type (view/edit) (remove)
|
10
|
+
...
|
11
|
+
...
|
12
|
+
(Add new handler)
|
13
|
+
--------- text area with editable handler -----------
|
14
|
+
(save)
|
15
|
+
|
16
|
+
|
17
|
+
Configuration (save)
|
18
|
+
--------- text area with editable (?) config file -----------
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
(c) Pixar.... [links]
|
data/lib/chook/subject.rb
CHANGED
@@ -49,6 +49,11 @@ module Chook
|
|
49
49
|
# Chook::HandledSubjects and Chook::TestSubjects
|
50
50
|
COMPUTER = 'Computer'.freeze
|
51
51
|
|
52
|
+
# The name of the DeviceAddedtoDEP subject (a.k.a. 'event_object')
|
53
|
+
# as known to the JSS. Also the class name of such subjects in
|
54
|
+
# Chook::HandledSubjects and Chook::TestSubjects
|
55
|
+
DEP_DEVICE = 'DEPDevice'.freeze
|
56
|
+
|
52
57
|
# The name of the JSS subject (a.k.a. 'event_object')
|
53
58
|
# as known to the JSS. Also the class name of such subjects in
|
54
59
|
# Chook::HandledSubjects and Chook::TestSubjects
|
@@ -64,6 +69,11 @@ module Chook
|
|
64
69
|
# Chook::HandledSubjects and Chook::TestSubjects
|
65
70
|
PATCH_SW_UPDATE = 'PatchSoftwareTitleUpdated'.freeze
|
66
71
|
|
72
|
+
# The name of the ComputerPolicyFinished subject (a.k.a. 'event_object')
|
73
|
+
# as known to the JSS. Also the class name of such subjects in
|
74
|
+
# Chook::HandledSubjects and Chook::TestSubjects
|
75
|
+
POLICY_FINISHED = 'PolicyFinished'.freeze
|
76
|
+
|
67
77
|
# The name of the Push subject (a.k.a. 'event_object')
|
68
78
|
# as known to the JSS. Also the class name of such subjects in
|
69
79
|
# Chook::HandledSubjects and Chook::TestSubjects
|
@@ -122,9 +132,8 @@ module Chook
|
|
122
132
|
# Proc: Pass an API object to the PROC to get a value
|
123
133
|
#
|
124
134
|
def self.classes
|
125
|
-
@classes
|
135
|
+
@classes ||= {}
|
126
136
|
end
|
127
|
-
@classes = {}
|
128
137
|
|
129
138
|
end # class Subject
|
130
139
|
|
@@ -141,3 +150,5 @@ require 'chook/subject/rest_api_operation'
|
|
141
150
|
require 'chook/subject/scep_challenge'
|
142
151
|
require 'chook/subject/smart_group'
|
143
152
|
require 'chook/test_subjects'
|
153
|
+
require 'chook/subject/dep_device'
|
154
|
+
require 'chook/subject/policy_finished'
|
@@ -0,0 +1,81 @@
|
|
1
|
+
### Copyright 2020 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
Chook::Subject.classes[Chook::Subject::DEP_DEVICE] = {
|
26
|
+
assetTag: {
|
27
|
+
validation: String,
|
28
|
+
# randomizer: ,
|
29
|
+
# sampler: ,
|
30
|
+
# api_object_attribute:
|
31
|
+
},
|
32
|
+
description: {
|
33
|
+
validation: String,
|
34
|
+
randomizer: :word,
|
35
|
+
# sampler: ,
|
36
|
+
# api_object_attribute:
|
37
|
+
},
|
38
|
+
deviceAssignedDate: {
|
39
|
+
to_json: :to_jss_epoch,
|
40
|
+
validation: Time,
|
41
|
+
randomizer: :time,
|
42
|
+
# sampler: ,
|
43
|
+
# api_object_attribute:
|
44
|
+
},
|
45
|
+
deviceEnrollmentProgramInstanceId: {
|
46
|
+
validation: Integer,
|
47
|
+
randomizer: :int,
|
48
|
+
# sampler: ,
|
49
|
+
# api_object_attribute:
|
50
|
+
},
|
51
|
+
model: {
|
52
|
+
validation: String,
|
53
|
+
randomizer: [:computer_model, :mobile_model], # /:
|
54
|
+
# sampler: ,
|
55
|
+
api_object_attribute: [:hardware, :model]
|
56
|
+
},
|
57
|
+
serialNumber: {
|
58
|
+
validation: String, #:validate_serial_number,
|
59
|
+
# randomizer: :computer_serial_number,
|
60
|
+
# sampler: ,
|
61
|
+
api_object_attribute: :serial_number
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
# https://www.jamf.com/developers/webhooks/#deviceaddedtoDEP
|
66
|
+
# {
|
67
|
+
# "event": {
|
68
|
+
# "assetTag": "1664194",
|
69
|
+
# "description": "Mac Pro",
|
70
|
+
# "deviceAssignedDate": 1552478234000,
|
71
|
+
# "deviceEnrollmentProgramInstanceId": 1,
|
72
|
+
# "model": "Mac Pro",
|
73
|
+
# "serialNumber": "92D8014694C4BE96B3"
|
74
|
+
# },
|
75
|
+
# "webhook": {
|
76
|
+
# "eventTimestamp": 1553550275590,
|
77
|
+
# "id": 1,
|
78
|
+
# "name": "Webhook Documentation",
|
79
|
+
# "webhookEvent": "DeviceAddedToDEP"
|
80
|
+
# }
|
81
|
+
# }
|
@@ -0,0 +1,43 @@
|
|
1
|
+
### Copyright 2017 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
# Add the attrbutes of a Computer subject to the Chook::Subject.attributes
|
27
|
+
# hash, to be used in defining Chook::TestSubjects::Computer and
|
28
|
+
# Chook::HandledSubjects::Computer
|
29
|
+
#
|
30
|
+
Chook::Subject.classes[Chook::Subject::POLICY_FINISHED] = {
|
31
|
+
computer: {
|
32
|
+
validation: Hash,
|
33
|
+
api_object_attribute: :computer
|
34
|
+
},
|
35
|
+
policyId: {
|
36
|
+
validation: Integer,
|
37
|
+
api_object_attribute: :policyId
|
38
|
+
},
|
39
|
+
successful: {
|
40
|
+
validation: :boolean,
|
41
|
+
api_object_attribute: :successful
|
42
|
+
}
|
43
|
+
}
|
@@ -41,6 +41,12 @@ Chook::Subject.classes[Chook::Subject::SMART_GROUP] = {
|
|
41
41
|
# sampler: :smart_group_jssid,
|
42
42
|
api_object_attribute: :id
|
43
43
|
},
|
44
|
+
groupAddedDevicesIds: {
|
45
|
+
validation: Array
|
46
|
+
},
|
47
|
+
groupRemovedDevicesIds: {
|
48
|
+
validation: Array
|
49
|
+
},
|
44
50
|
computer: { # SmartGroupComputerMembershipChange == true, SmartGroupMobileDeviceMembershipChange == false
|
45
51
|
validation: :boolean,
|
46
52
|
randomizer: :bool,
|
@@ -72,8 +72,8 @@ module Chook
|
|
72
72
|
# a random test subject,
|
73
73
|
def self.random
|
74
74
|
random_vals = {}
|
75
|
-
Chook::Subject.classes[].each do |attrib, deets|
|
76
|
-
random_vals[attrib] = Chook::Randomizers.send deets[:randomizer]
|
75
|
+
Chook::Subject.classes[self.const_get NAME_CONSTANT].each do |attrib, deets|
|
76
|
+
random_vals[attrib] = Chook::Randomizers.send deets[:randomizer] if deets[:randomizer]
|
77
77
|
end # each do |attr_def|
|
78
78
|
new random_vals
|
79
79
|
end # end random
|
data/lib/chook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.5b1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -9,38 +9,85 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '2.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '2.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: sinatra-contrib
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '2.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: thin
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.7'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.7'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: haml
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '5.0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '5.0'
|
28
70
|
description: |2
|
29
71
|
Chook is a Ruby module which implements a framework for working with webhook events
|
30
72
|
sent by the JSS, the core of Jamf Pro, a management tool for Apple devices.
|
31
73
|
|
32
|
-
Chook also provides a simple, sinatra-based HTTP server, for handling those Events,
|
74
|
+
Chook also provides a simple, sinatra-based HTTP(S) server, for handling those Events,
|
33
75
|
and classes for sending simulated TestEvents to a webhook handling server.
|
34
76
|
email: chook@pixar.com
|
35
|
-
executables:
|
77
|
+
executables:
|
78
|
+
- chook-server
|
36
79
|
extensions: []
|
37
80
|
extra_rdoc_files:
|
38
81
|
- README.md
|
39
82
|
- LICENSE.txt
|
83
|
+
- CHANGES.md
|
40
84
|
files:
|
85
|
+
- CHANGES.md
|
41
86
|
- LICENSE.txt
|
42
87
|
- README.md
|
43
88
|
- bin/chook-server
|
89
|
+
- data/chook.conf.example
|
90
|
+
- data/com.pixar.chook-server.plist
|
44
91
|
- data/sample_handlers/RestAPIOperation-executable
|
45
92
|
- data/sample_handlers/RestAPIOperation.rb
|
46
93
|
- data/sample_handlers/SmartGroupComputerMembershipChange-executable
|
@@ -69,6 +116,7 @@ files:
|
|
69
116
|
- lib/chook/event.rb
|
70
117
|
- lib/chook/event/handled_event.rb
|
71
118
|
- lib/chook/event/handled_event/handlers.rb
|
119
|
+
- lib/chook/event/handled_event_logger.rb
|
72
120
|
- lib/chook/event/test_event.rb
|
73
121
|
- lib/chook/event_handling.rb
|
74
122
|
- lib/chook/event_testing.rb
|
@@ -77,15 +125,34 @@ files:
|
|
77
125
|
- lib/chook/handled_subjects.rb
|
78
126
|
- lib/chook/procs.rb
|
79
127
|
- lib/chook/server.rb
|
128
|
+
- lib/chook/server/auth.rb
|
129
|
+
- lib/chook/server/log.rb
|
130
|
+
- lib/chook/server/public/css/chook.css
|
131
|
+
- lib/chook/server/public/imgs/ChookLogoAlMcWhiggin.png
|
132
|
+
- lib/chook/server/public/js/chook.js
|
133
|
+
- lib/chook/server/public/js/logstream.js
|
80
134
|
- lib/chook/server/routes.rb
|
135
|
+
- lib/chook/server/routes/handle_by_name.rb
|
81
136
|
- lib/chook/server/routes/handle_webhook_event.rb
|
137
|
+
- lib/chook/server/routes/handlers.rb
|
82
138
|
- lib/chook/server/routes/home.rb
|
139
|
+
- lib/chook/server/routes/log.rb
|
140
|
+
- lib/chook/server/routes/login_logout.rb
|
141
|
+
- lib/chook/server/views/admin.haml
|
142
|
+
- lib/chook/server/views/bak.haml
|
143
|
+
- lib/chook/server/views/config.haml
|
144
|
+
- lib/chook/server/views/handlers.haml
|
145
|
+
- lib/chook/server/views/layout.haml
|
146
|
+
- lib/chook/server/views/logstream.haml
|
147
|
+
- lib/chook/server/views/sketch_admin
|
83
148
|
- lib/chook/subject.rb
|
84
149
|
- lib/chook/subject/computer.rb
|
150
|
+
- lib/chook/subject/dep_device.rb
|
85
151
|
- lib/chook/subject/handled_subject.rb
|
86
152
|
- lib/chook/subject/jss.rb
|
87
153
|
- lib/chook/subject/mobile_device.rb
|
88
154
|
- lib/chook/subject/patch_software_title_update.rb
|
155
|
+
- lib/chook/subject/policy_finished.rb
|
89
156
|
- lib/chook/subject/push.rb
|
90
157
|
- lib/chook/subject/randomizers.rb
|
91
158
|
- lib/chook/subject/rest_api_operation.rb
|
@@ -102,12 +169,7 @@ licenses:
|
|
102
169
|
- Nonstandard
|
103
170
|
metadata: {}
|
104
171
|
post_install_message:
|
105
|
-
rdoc_options:
|
106
|
-
- "--title"
|
107
|
-
- Chook
|
108
|
-
- "--line-numbers"
|
109
|
-
- "--main"
|
110
|
-
- README.md
|
172
|
+
rdoc_options: []
|
111
173
|
require_paths:
|
112
174
|
- lib
|
113
175
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -121,9 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
183
|
- !ruby/object:Gem::Version
|
122
184
|
version: 1.3.1
|
123
185
|
requirements: []
|
124
|
-
|
125
|
-
rubygems_version: 2.6.8
|
186
|
+
rubygems_version: 3.0.3
|
126
187
|
signing_key:
|
127
188
|
specification_version: 4
|
128
|
-
summary: A Ruby framework for simulating and processing Jamf Pro
|
189
|
+
summary: A Ruby framework for simulating and processing Jamf Pro Webhook Events
|
129
190
|
test_files: []
|