Lane-Reporter 0.1.1
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 +7 -0
- data/.gitignore +13 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +49 -0
- data/LICENSE.txt +21 -0
- data/Lane-Reporter-0.1.0.gem +0 -0
- data/Lane.gemspec +42 -0
- data/README.md +38 -0
- data/Rakefile +7 -0
- data/bin/Lane.rb +90 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/data/lane.conf +20 -0
- data/data/lane.conf.example +20 -0
- data/lib/Lane/config.rb +88 -0
- data/lib/Lane/connection.rb +24 -0
- data/lib/Lane/foundation.rb +6 -0
- data/lib/Lane/messages.rb +24 -0
- data/lib/Lane/report.rb +46 -0
- data/lib/Lane/version.rb +3 -0
- data/lib/Lane.rb +6 -0
- data/vendor/cache/domain_name-0.5.20180417.gem +0 -0
- data/vendor/cache/http-cookie-1.0.3.gem +0 -0
- data/vendor/cache/immutable-struct-2.4.0.gem +0 -0
- data/vendor/cache/mime-types-3.2.2.gem +0 -0
- data/vendor/cache/mime-types-data-3.2019.0331.gem +0 -0
- data/vendor/cache/net-ldap-0.16.1.gem +0 -0
- data/vendor/cache/netrc-0.11.0.gem +0 -0
- data/vendor/cache/plist-3.5.0.gem +0 -0
- data/vendor/cache/rake-10.5.0.gem +0 -0
- data/vendor/cache/recursive-open-struct-1.1.0.gem +0 -0
- data/vendor/cache/rest-client-2.0.2.gem +0 -0
- data/vendor/cache/ruby-jss-1.0.2.gem +0 -0
- data/vendor/cache/ruby-mysql-2.9.14.gem +0 -0
- data/vendor/cache/unf-0.1.4.gem +0 -0
- data/vendor/cache/unf_ext-0.0.7.5.gem +0 -0
- metadata +140 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8389d510cb5ad8612325cf915ae4b975abcc58c3c5ac2076dfdf16379c3bce1b
|
|
4
|
+
data.tar.gz: 96866586531ea0f3ebfba2f7cd65f52c3f5710d4efd376445ff6794a4c986738
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 29fa4773e5062efeb4a95a8a444fc4af6a53e3380eb1081e279243e3d4a85cb2b838845295c691231e00e1c66a9c8f747f59d0ba265e064ea376d2df7ed64a1c
|
|
7
|
+
data.tar.gz: 4b7c4d7e48de51895c374991a1bf70ee4c6c4b2653192dd4a2f77167f81ea8e03c9441f684a9f8a4d1409c06b961aa10d4c1e2142fa2c911f82f87c44d5f4849
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.5.1
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at bernardo.prieto.curiel@zalando.de. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
Lane-Reporter (0.1.0)
|
|
5
|
+
ruby-jss (~> 1.0.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
domain_name (0.5.20180417)
|
|
11
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
12
|
+
http-cookie (1.0.3)
|
|
13
|
+
domain_name (~> 0.5)
|
|
14
|
+
immutable-struct (2.4.0)
|
|
15
|
+
mime-types (3.2.2)
|
|
16
|
+
mime-types-data (~> 3.2015)
|
|
17
|
+
mime-types-data (3.2019.0331)
|
|
18
|
+
net-ldap (0.16.1)
|
|
19
|
+
netrc (0.11.0)
|
|
20
|
+
plist (3.5.0)
|
|
21
|
+
rake (10.5.0)
|
|
22
|
+
recursive-open-struct (1.1.0)
|
|
23
|
+
rest-client (2.0.2)
|
|
24
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
25
|
+
mime-types (>= 1.16, < 4.0)
|
|
26
|
+
netrc (~> 0.8)
|
|
27
|
+
ruby-jss (1.0.2)
|
|
28
|
+
immutable-struct (~> 2.3, >= 2.3.0)
|
|
29
|
+
net-ldap (~> 0.16)
|
|
30
|
+
plist (~> 3.1)
|
|
31
|
+
recursive-open-struct (~> 1.1, >= 1.1.0)
|
|
32
|
+
rest-client (>= 1.8.0, < 2.1)
|
|
33
|
+
ruby-mysql (~> 2.9, >= 2.9.12)
|
|
34
|
+
ruby-mysql (2.9.14)
|
|
35
|
+
unf (0.1.4)
|
|
36
|
+
unf_ext
|
|
37
|
+
unf_ext (0.0.7.5)
|
|
38
|
+
|
|
39
|
+
PLATFORMS
|
|
40
|
+
ruby
|
|
41
|
+
|
|
42
|
+
DEPENDENCIES
|
|
43
|
+
Lane-Reporter!
|
|
44
|
+
bundler (~> 2.0)
|
|
45
|
+
rake (~> 10.0)
|
|
46
|
+
ruby-jss (~> 1.0.2)
|
|
47
|
+
|
|
48
|
+
BUNDLED WITH
|
|
49
|
+
2.0.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Bernardo Prieto Curiel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
Binary file
|
data/Lane.gemspec
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "Lane/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "Lane-Reporter"
|
|
8
|
+
spec.version = Lane::VERSION
|
|
9
|
+
spec.authors = ["Bearzooka"]
|
|
10
|
+
spec.email = ["bprieto@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "Lane is a real-life reporter for JSS."
|
|
13
|
+
spec.homepage = "https://github.com/Bearzooka/Lane"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
18
|
+
if spec.respond_to?(:metadata)
|
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
|
20
|
+
|
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/Bearzooka/Lane"
|
|
23
|
+
spec.metadata["changelog_uri"] = "https://github.com/Bearzooka/Lane"
|
|
24
|
+
else
|
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
26
|
+
"public gem pushes."
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
33
|
+
end
|
|
34
|
+
spec.bindir = "exe"
|
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
36
|
+
spec.require_paths = ["lib"]
|
|
37
|
+
|
|
38
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
40
|
+
spec.add_development_dependency "ruby-jss", "~> 1.0.2"
|
|
41
|
+
spec.add_runtime_dependency "ruby-jss", "~> 1.0.2"
|
|
42
|
+
end
|
data/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Lane
|
|
2
|
+
|
|
3
|
+
Lane is a **real-world** reporter for JSS. Its goal is to give simple and easily automatic access to the information on the Apple Management platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install it yourself as:
|
|
8
|
+
|
|
9
|
+
$ gem install Lane
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
Once installed, the configuration will be taken from the file `/etc/lane.conf` in which you will be able to specify the URL of your JSS instance, the user and the password.
|
|
14
|
+
|
|
15
|
+
An example of this file can be found in your Gem installation PATH /Lane/data/lane.conf
|
|
16
|
+
|
|
17
|
+
Pound signs and blank spaces are ignored, and values do not need to be quoted.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
Once installed and configured, run it as following:
|
|
22
|
+
|
|
23
|
+
`lane --advanced_search | -a ID [-separator | -s char] [-output | -o output path]`
|
|
24
|
+
|
|
25
|
+
-a ID, --advanced_search ID:
|
|
26
|
+
ID of the JSS advanced search to base the report on.
|
|
27
|
+
|
|
28
|
+
-s char, --separator char:
|
|
29
|
+
Character that will be used as separator on the output file. Defaults to ';'
|
|
30
|
+
|
|
31
|
+
-o path, --output path:
|
|
32
|
+
Path for the output of the processed report. Defaults to /Users/Shared/lane_report_YY-MM-DD.txt"
|
|
33
|
+
|
|
34
|
+
**Lane** will fetch all the results of the advanced search with the ID specified as the -a parameter and parse them into columns, with the column titles pulled from the search, separated with the selected character and store in the defined output path.
|
|
35
|
+
|
|
36
|
+
## Dependencies
|
|
37
|
+
|
|
38
|
+
**Lane** connects to the JSS using the [Ruby-JSS library from Pixar Animation Studios](https://github.com/PixarAnimationStudios/ruby-jss).
|
data/Rakefile
ADDED
data/bin/Lane.rb
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'Lane/foundation'
|
|
4
|
+
require 'getoptlong'
|
|
5
|
+
|
|
6
|
+
# The CLI options for GetoptLong
|
|
7
|
+
OPTS = GetoptLong.new(
|
|
8
|
+
['--advanced_search', '-a', GetoptLong::REQUIRED_ARGUMENT],
|
|
9
|
+
['--separator', '-s', GetoptLong::REQUIRED_ARGUMENT],
|
|
10
|
+
['--output', '-o', GetoptLong::OPTIONAL_ARGUMENT]
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
report_id = nil
|
|
14
|
+
separator = nil
|
|
15
|
+
output = nil
|
|
16
|
+
|
|
17
|
+
OPTS.each do |opt, arg|
|
|
18
|
+
case opt
|
|
19
|
+
when '--advanced_search'
|
|
20
|
+
if arg == ''
|
|
21
|
+
puts Lane::USAGE
|
|
22
|
+
exit 1
|
|
23
|
+
else
|
|
24
|
+
report_id = arg
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
when '--separator'
|
|
28
|
+
if arg == ''
|
|
29
|
+
separator = ';'
|
|
30
|
+
else
|
|
31
|
+
separator = arg
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
when '--output'
|
|
35
|
+
if arg == ''
|
|
36
|
+
output = "/Users/Shared/lane_report_#{Time.now.strftime('%Y-%m-%d')}.txt"
|
|
37
|
+
else
|
|
38
|
+
output = arg
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end # case
|
|
42
|
+
end # opts.each
|
|
43
|
+
|
|
44
|
+
unless report_id
|
|
45
|
+
puts Lane::USAGE
|
|
46
|
+
exit 1
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Assigning a default path and separator for the report if no parameter was passed.
|
|
50
|
+
output ? output : output = "/Users/Shared/new_report_#{Time.now.strftime('%Y-%m-%d')}.txt"
|
|
51
|
+
separator ? separator : separator = ';'
|
|
52
|
+
|
|
53
|
+
begin
|
|
54
|
+
|
|
55
|
+
if Lane::Configuration::DEFAULT_CONF_FILE.file?
|
|
56
|
+
@config_src = Lane::Configuration::DEFAULT_CONF_FILE.to_s
|
|
57
|
+
puts "Config present as #{@config_src}"
|
|
58
|
+
elsif Lane::Configuration::SAMPLE_CONF_FILE.file?
|
|
59
|
+
puts Lane::CONFIG_ERROR
|
|
60
|
+
exit 1
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Lane.connect_to_jss
|
|
64
|
+
source = JSS::AdvancedComputerSearch.fetch(id: report_id.to_i).search_results
|
|
65
|
+
|
|
66
|
+
puts "Got #{source.count} results"
|
|
67
|
+
|
|
68
|
+
my_report = Lane::Report.new(output, separator)
|
|
69
|
+
|
|
70
|
+
my_report.clear
|
|
71
|
+
|
|
72
|
+
header_line = ''
|
|
73
|
+
|
|
74
|
+
source[0].each_key do |key_name|
|
|
75
|
+
header_line = "#{header_line}#{key_name.to_s.tr('_', ' ')}#{separator}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Removing a separator at the end of the line
|
|
79
|
+
header_line = header_line[0...-1]
|
|
80
|
+
|
|
81
|
+
my_report.write_header(header_line)
|
|
82
|
+
|
|
83
|
+
source.each do |item|
|
|
84
|
+
item.each { |value| my_report.append_data(value[1]) }
|
|
85
|
+
my_report.new_line
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
puts "Report successfully created at #{output}"
|
|
89
|
+
|
|
90
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "Lane"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/data/lane.conf
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#################
|
|
2
|
+
# This config file uses default settings.
|
|
3
|
+
#
|
|
4
|
+
# Each setting is defined on one line like so:
|
|
5
|
+
#
|
|
6
|
+
# key: value
|
|
7
|
+
#
|
|
8
|
+
# Values may have spaces.
|
|
9
|
+
#
|
|
10
|
+
# Blank lines and those starting with # are ignored.
|
|
11
|
+
|
|
12
|
+
jamf_server:
|
|
13
|
+
|
|
14
|
+
jamf_port:
|
|
15
|
+
|
|
16
|
+
jamf_use_ssl:
|
|
17
|
+
|
|
18
|
+
jamf_user:
|
|
19
|
+
|
|
20
|
+
jamf_password:
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#################
|
|
2
|
+
# This config file uses default settings.
|
|
3
|
+
#
|
|
4
|
+
# Each setting is defined on one line like so:
|
|
5
|
+
#
|
|
6
|
+
# key: value
|
|
7
|
+
#
|
|
8
|
+
# Values may have spaces.
|
|
9
|
+
#
|
|
10
|
+
# Blank lines and those starting with # are ignored.
|
|
11
|
+
|
|
12
|
+
jamf_server:
|
|
13
|
+
|
|
14
|
+
jamf_port:
|
|
15
|
+
|
|
16
|
+
jamf_use_ssl:
|
|
17
|
+
|
|
18
|
+
jamf_user:
|
|
19
|
+
|
|
20
|
+
jamf_password:
|
data/lib/Lane/config.rb
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
require 'singleton'
|
|
2
|
+
|
|
3
|
+
module Lane
|
|
4
|
+
|
|
5
|
+
class Configuration
|
|
6
|
+
|
|
7
|
+
include ::Singleton
|
|
8
|
+
|
|
9
|
+
# The location of the default config file
|
|
10
|
+
DEFAULT_CONF_FILE = Pathname.new '/etc/lane.conf'
|
|
11
|
+
|
|
12
|
+
SAMPLE_CONF_FILE = Pathname.new(__FILE__).parent.parent.parent + 'data/lane.conf.example'
|
|
13
|
+
|
|
14
|
+
CONF_KEYS = {
|
|
15
|
+
jamf_server: nil,
|
|
16
|
+
jamf_port: :to_i,
|
|
17
|
+
jamf_use_ssl: nil,
|
|
18
|
+
jamf_user: nil,
|
|
19
|
+
jamf_password: nil
|
|
20
|
+
}.freeze
|
|
21
|
+
|
|
22
|
+
# automatically create accessors for all the CONF_KEYS
|
|
23
|
+
CONF_KEYS.keys.each { |k| attr_accessor k }
|
|
24
|
+
|
|
25
|
+
# Initialize!
|
|
26
|
+
#
|
|
27
|
+
def initialize
|
|
28
|
+
read_global
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def read_global
|
|
32
|
+
return false unless DEFAULT_CONF_FILE.file? && DEFAULT_CONF_FILE.readable?
|
|
33
|
+
read DEFAULT_CONF_FILE
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def print
|
|
37
|
+
CONF_KEYS.keys.sort.each { |k| puts "#{k}: #{send k}" }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
def read(file)
|
|
43
|
+
available_conf_keys = CONF_KEYS.keys
|
|
44
|
+
|
|
45
|
+
puts file
|
|
46
|
+
Pathname.new(file).read.each_line do |line|
|
|
47
|
+
|
|
48
|
+
# skip blank lines and those starting with #
|
|
49
|
+
next if line =~ /^\s*(#|$)/
|
|
50
|
+
|
|
51
|
+
line.strip =~ /^(\w+?):\s*(\S.*)$/
|
|
52
|
+
key = Regexp.last_match(1)
|
|
53
|
+
next unless key
|
|
54
|
+
attr = key.to_sym
|
|
55
|
+
next unless available_conf_keys.include? attr
|
|
56
|
+
setter = "#{key}=".to_sym
|
|
57
|
+
value = Regexp.last_match(2).strip
|
|
58
|
+
|
|
59
|
+
# convert the string value read from the file
|
|
60
|
+
# to the correct class
|
|
61
|
+
value &&= case CONF_KEYS[attr]
|
|
62
|
+
when Proc
|
|
63
|
+
# If its a proc, pass it to the proc
|
|
64
|
+
CONF_KEYS[attr].call value
|
|
65
|
+
|
|
66
|
+
when Symbol
|
|
67
|
+
# otherwise its a symbol method name to call on the string
|
|
68
|
+
value.send(CONF_KEYS[attr])
|
|
69
|
+
|
|
70
|
+
else
|
|
71
|
+
value
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
send(setter, value)
|
|
76
|
+
end # do line
|
|
77
|
+
true
|
|
78
|
+
end # read file
|
|
79
|
+
|
|
80
|
+
end # class Configuration
|
|
81
|
+
|
|
82
|
+
# The single instance of Configuration
|
|
83
|
+
def self.config
|
|
84
|
+
Lane::Configuration.instance
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
end # module
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
require 'ruby-jss'
|
|
3
|
+
require_relative 'config'
|
|
4
|
+
|
|
5
|
+
module Lane
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def self.connect_to_jss
|
|
9
|
+
# JSS Connection info
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
JSS.api.connect user: Lane.config.jamf_user,
|
|
13
|
+
pw: Lane.config.jamf_password,
|
|
14
|
+
server: Lane.config.jamf_server,
|
|
15
|
+
verify_cert: false
|
|
16
|
+
|
|
17
|
+
puts "Connected to the JSS."
|
|
18
|
+
rescue
|
|
19
|
+
puts "Could not connect to JSS. Please check the configuration."
|
|
20
|
+
# abort
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end # Lane
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lane
|
|
4
|
+
USAGE = "≈≈≈ Lane, a real world reporter for JSS. ≈≈≈
|
|
5
|
+
|
|
6
|
+
Usage: lane --advanced_search | -a ID [-separator | -s char] [-output | -o output path]
|
|
7
|
+
|
|
8
|
+
-a ID, --advanced_search ID:
|
|
9
|
+
ID of the JSS advanced search to base the report on.
|
|
10
|
+
|
|
11
|
+
-s char, --separator char:
|
|
12
|
+
Character that will be used as separator on the output file. Defaults to ';'
|
|
13
|
+
|
|
14
|
+
-o path, --output path:
|
|
15
|
+
Path for the output of the processed report. Defaults to /Users/Shared/lane_report_YY-MM-DD.txt"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
CONFIG_ERROR = "≈≈≈ Lane, a real world reporter for JSS. ≈≈≈
|
|
19
|
+
|
|
20
|
+
[ERROR] The configuration file is missing in /etc/lane.conf
|
|
21
|
+
|
|
22
|
+
You can copy a sample file from the data folder inside the installation path of Lane and
|
|
23
|
+
fill the JSS URL, User and Password. "
|
|
24
|
+
end
|
data/lib/Lane/report.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# report.rb
|
|
2
|
+
|
|
3
|
+
module Lane
|
|
4
|
+
class Report
|
|
5
|
+
def initialize(path, separator = ',')
|
|
6
|
+
# instance variables
|
|
7
|
+
@path = path
|
|
8
|
+
@separator = separator
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def append_line(line)
|
|
12
|
+
# method that appends a line to a report.
|
|
13
|
+
File.write(@path, line, mode: 'a')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def write_header(header)
|
|
17
|
+
File.write(@path, "#{header}\n", mode: 'w')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def clear
|
|
21
|
+
File.write(@path, '', mode: 'w')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def delete
|
|
25
|
+
File.delete(@path)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def append_data(data)
|
|
29
|
+
# method that appends one piece of data and a separator
|
|
30
|
+
File.write(@path, "#{data}#{@separator} ", mode: 'a')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def new_line
|
|
34
|
+
# Deletes the last separator and then inserts a new line
|
|
35
|
+
File.truncate(@path, File.size(@path) - 2)
|
|
36
|
+
File.write(@path, "\n", mode: 'a')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def append_empty_columns(columns)
|
|
40
|
+
# Inserts the passed number of empty columns for cases of missing info
|
|
41
|
+
columns.times do
|
|
42
|
+
File.write(@path, @separator.to_s, mode: 'a')
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end # Class Report
|
|
46
|
+
end # Module
|
data/lib/Lane/version.rb
ADDED
data/lib/Lane.rb
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
metadata
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: Lane-Reporter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Bearzooka
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: ruby-jss
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 1.0.2
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 1.0.2
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: ruby-jss
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 1.0.2
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 1.0.2
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- bprieto@gmail.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- ".ruby-version"
|
|
78
|
+
- CODE_OF_CONDUCT.md
|
|
79
|
+
- Gemfile
|
|
80
|
+
- Gemfile.lock
|
|
81
|
+
- LICENSE.txt
|
|
82
|
+
- Lane-Reporter-0.1.0.gem
|
|
83
|
+
- Lane.gemspec
|
|
84
|
+
- README.md
|
|
85
|
+
- Rakefile
|
|
86
|
+
- bin/Lane.rb
|
|
87
|
+
- bin/console
|
|
88
|
+
- bin/setup
|
|
89
|
+
- data/lane.conf
|
|
90
|
+
- data/lane.conf.example
|
|
91
|
+
- lib/Lane.rb
|
|
92
|
+
- lib/Lane/config.rb
|
|
93
|
+
- lib/Lane/connection.rb
|
|
94
|
+
- lib/Lane/foundation.rb
|
|
95
|
+
- lib/Lane/messages.rb
|
|
96
|
+
- lib/Lane/report.rb
|
|
97
|
+
- lib/Lane/version.rb
|
|
98
|
+
- vendor/cache/domain_name-0.5.20180417.gem
|
|
99
|
+
- vendor/cache/http-cookie-1.0.3.gem
|
|
100
|
+
- vendor/cache/immutable-struct-2.4.0.gem
|
|
101
|
+
- vendor/cache/mime-types-3.2.2.gem
|
|
102
|
+
- vendor/cache/mime-types-data-3.2019.0331.gem
|
|
103
|
+
- vendor/cache/net-ldap-0.16.1.gem
|
|
104
|
+
- vendor/cache/netrc-0.11.0.gem
|
|
105
|
+
- vendor/cache/plist-3.5.0.gem
|
|
106
|
+
- vendor/cache/rake-10.5.0.gem
|
|
107
|
+
- vendor/cache/recursive-open-struct-1.1.0.gem
|
|
108
|
+
- vendor/cache/rest-client-2.0.2.gem
|
|
109
|
+
- vendor/cache/ruby-jss-1.0.2.gem
|
|
110
|
+
- vendor/cache/ruby-mysql-2.9.14.gem
|
|
111
|
+
- vendor/cache/unf-0.1.4.gem
|
|
112
|
+
- vendor/cache/unf_ext-0.0.7.5.gem
|
|
113
|
+
homepage: https://github.com/Bearzooka/Lane
|
|
114
|
+
licenses:
|
|
115
|
+
- MIT
|
|
116
|
+
metadata:
|
|
117
|
+
allowed_push_host: https://rubygems.org/
|
|
118
|
+
homepage_uri: https://github.com/Bearzooka/Lane
|
|
119
|
+
source_code_uri: https://github.com/Bearzooka/Lane
|
|
120
|
+
changelog_uri: https://github.com/Bearzooka/Lane
|
|
121
|
+
post_install_message:
|
|
122
|
+
rdoc_options: []
|
|
123
|
+
require_paths:
|
|
124
|
+
- lib
|
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '0'
|
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
|
+
requirements:
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: '0'
|
|
135
|
+
requirements: []
|
|
136
|
+
rubygems_version: 3.0.2
|
|
137
|
+
signing_key:
|
|
138
|
+
specification_version: 4
|
|
139
|
+
summary: Lane is a real-life reporter for JSS.
|
|
140
|
+
test_files: []
|