chook 1.0.1.b2 → 1.1.5

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.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES.md +56 -0
  3. data/README.md +363 -127
  4. data/bin/chook-server +31 -1
  5. data/data/chook.conf.example +183 -0
  6. data/data/com.pixar.chook-server.plist +20 -0
  7. data/data/sample_handlers/RestAPIOperation.rb +11 -11
  8. data/data/sample_handlers/SmartGroupComputerMembershipChange.rb +3 -6
  9. data/data/sample_jsons/SmartGroupComputerMembershipChange.json +3 -1
  10. data/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +3 -1
  11. data/lib/chook/configuration.rb +27 -8
  12. data/lib/chook/event.rb +6 -1
  13. data/lib/chook/event/handled_event.rb +36 -9
  14. data/lib/chook/event/handled_event/handlers.rb +260 -98
  15. data/lib/chook/event/handled_event_logger.rb +86 -0
  16. data/lib/chook/event_handling.rb +1 -0
  17. data/lib/chook/foundation.rb +3 -0
  18. data/lib/chook/procs.rb +17 -1
  19. data/lib/chook/server.rb +73 -72
  20. data/lib/chook/server/auth.rb +164 -0
  21. data/lib/chook/server/log.rb +215 -0
  22. data/lib/chook/server/public/css/chook.css +133 -0
  23. data/lib/chook/server/public/imgs/ChookLogoAlMcWhiggin.png +0 -0
  24. data/lib/chook/server/public/js/chook.js +126 -0
  25. data/lib/chook/server/public/js/logstream.js +101 -0
  26. data/lib/chook/server/routes.rb +28 -0
  27. data/lib/chook/server/routes/handle_by_name.rb +65 -0
  28. data/lib/chook/server/routes/handle_webhook_event.rb +27 -3
  29. data/lib/chook/server/routes/handlers.rb +52 -0
  30. data/lib/chook/server/routes/home.rb +48 -1
  31. data/lib/chook/server/routes/log.rb +105 -0
  32. data/lib/chook/server/routes/login_logout.rb +48 -0
  33. data/lib/chook/server/views/admin.haml +11 -0
  34. data/lib/chook/server/views/bak.haml +48 -0
  35. data/lib/chook/server/views/config.haml +15 -0
  36. data/lib/chook/server/views/handlers.haml +63 -0
  37. data/lib/chook/server/views/layout.haml +64 -0
  38. data/lib/chook/server/views/logstream.haml +33 -0
  39. data/lib/chook/server/views/sketch_admin +44 -0
  40. data/lib/chook/subject.rb +13 -2
  41. data/lib/chook/subject/dep_device.rb +81 -0
  42. data/lib/chook/subject/policy_finished.rb +43 -0
  43. data/lib/chook/subject/smart_group.rb +6 -0
  44. data/lib/chook/version.rb +1 -1
  45. metadata +79 -19
@@ -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]
@@ -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,
@@ -27,6 +27,6 @@
27
27
  module Chook
28
28
 
29
29
  ### The version of the Chook framework
30
- VERSION = '1.0.1.b2'.freeze
30
+ VERSION = '1.1.5'.freeze
31
31
 
32
32
  end # module
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.0.1.b2
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Lasell
@@ -9,27 +9,69 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-25 00:00:00.000000000 Z
12
+ date: 2020-12-22 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: 1.4.8
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: 1.4.8
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
77
  executables:
@@ -38,10 +80,14 @@ extensions: []
38
80
  extra_rdoc_files:
39
81
  - README.md
40
82
  - LICENSE.txt
83
+ - CHANGES.md
41
84
  files:
85
+ - CHANGES.md
42
86
  - LICENSE.txt
43
87
  - README.md
44
88
  - bin/chook-server
89
+ - data/chook.conf.example
90
+ - data/com.pixar.chook-server.plist
45
91
  - data/sample_handlers/RestAPIOperation-executable
46
92
  - data/sample_handlers/RestAPIOperation.rb
47
93
  - data/sample_handlers/SmartGroupComputerMembershipChange-executable
@@ -70,6 +116,7 @@ files:
70
116
  - lib/chook/event.rb
71
117
  - lib/chook/event/handled_event.rb
72
118
  - lib/chook/event/handled_event/handlers.rb
119
+ - lib/chook/event/handled_event_logger.rb
73
120
  - lib/chook/event/test_event.rb
74
121
  - lib/chook/event_handling.rb
75
122
  - lib/chook/event_testing.rb
@@ -78,15 +125,34 @@ files:
78
125
  - lib/chook/handled_subjects.rb
79
126
  - lib/chook/procs.rb
80
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
81
134
  - lib/chook/server/routes.rb
135
+ - lib/chook/server/routes/handle_by_name.rb
82
136
  - lib/chook/server/routes/handle_webhook_event.rb
137
+ - lib/chook/server/routes/handlers.rb
83
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
84
148
  - lib/chook/subject.rb
85
149
  - lib/chook/subject/computer.rb
150
+ - lib/chook/subject/dep_device.rb
86
151
  - lib/chook/subject/handled_subject.rb
87
152
  - lib/chook/subject/jss.rb
88
153
  - lib/chook/subject/mobile_device.rb
89
154
  - lib/chook/subject/patch_software_title_update.rb
155
+ - lib/chook/subject/policy_finished.rb
90
156
  - lib/chook/subject/push.rb
91
157
  - lib/chook/subject/randomizers.rb
92
158
  - lib/chook/subject/rest_api_operation.rb
@@ -103,28 +169,22 @@ licenses:
103
169
  - Nonstandard
104
170
  metadata: {}
105
171
  post_install_message:
106
- rdoc_options:
107
- - --title
108
- - Chook
109
- - --line-numbers
110
- - --main
111
- - README.md
172
+ rdoc_options: []
112
173
  require_paths:
113
174
  - lib
114
175
  required_ruby_version: !ruby/object:Gem::Requirement
115
176
  requirements:
116
- - - '>='
177
+ - - ">="
117
178
  - !ruby/object:Gem::Version
118
179
  version: '0'
119
180
  required_rubygems_version: !ruby/object:Gem::Requirement
120
181
  requirements:
121
- - - '>'
182
+ - - ">="
122
183
  - !ruby/object:Gem::Version
123
- version: 1.3.1
184
+ version: '0'
124
185
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.6.8
186
+ rubygems_version: 3.0.3
127
187
  signing_key:
128
188
  specification_version: 4
129
- summary: A Ruby framework for simulating and processing Jamf Pro Webhooks
189
+ summary: A Ruby framework for simulating and processing Jamf Pro Webhook Events
130
190
  test_files: []