egi-fedcloud-cloudhound 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.rspec +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +3 -0
- data/LICENSE +202 -0
- data/README.md +16 -0
- data/Rakefile +27 -0
- data/bin/egi-fedcloud-cloudhound +92 -0
- data/config/settings.yml +21 -0
- data/egi-fedcloud-cloudhound.gemspec +37 -0
- data/lib/egi-fedcloud-cloudhound.rb +22 -0
- data/lib/egi/fedcloud/cloudhound/appdb.rb +72 -0
- data/lib/egi/fedcloud/cloudhound/appdb_appliance.rb +56 -0
- data/lib/egi/fedcloud/cloudhound/appdb_site.rb +52 -0
- data/lib/egi/fedcloud/cloudhound/connector.rb +25 -0
- data/lib/egi/fedcloud/cloudhound/extractor.rb +61 -0
- data/lib/egi/fedcloud/cloudhound/formatter.rb +28 -0
- data/lib/egi/fedcloud/cloudhound/gocdb.rb +53 -0
- data/lib/egi/fedcloud/cloudhound/gocdb_site.rb +70 -0
- data/lib/egi/fedcloud/cloudhound/log.rb +69 -0
- data/lib/egi/fedcloud/cloudhound/settings.rb +11 -0
- data/lib/egi/fedcloud/cloudhound/version.rb +8 -0
- data/spec/spec_helper.rb +11 -0
- metadata +280 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53b9e447d5ff5c639e1ed13116b39f2d3d86dd77
|
4
|
+
data.tar.gz: 6019140b5a86e42f0f6c70e5cbe96991582fe1cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0d2c1a3919ea1625bafbfb04e7e04b467482ce6d4cb2b24fd72000b6e551aac46fef1e138885b104447238bd26ce9144527e97d03d3e44baf9840eede2bf41e
|
7
|
+
data.tar.gz: c5902b4cae877356fa73948b00bea14ac51af3c944d52a71505daec59d1531d78dd92be6152844a87ce838398d7c8e8ca0a62ea012977095b333fc5519d376f8
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
Gemfile.lock
|
31
|
+
.ruby-version
|
32
|
+
.ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper --color --format documentation
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
202
|
+
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/arax/egi-fedcloud-cloudhound.png)](http://travis-ci.org/arax/egi-fedcloud-cloudhound)
|
2
|
+
[![Dependency Status](https://gemnasium.com/arax/egi-fedcloud-cloudhound.png)](https://gemnasium.com/arax/egi-fedcloud-cloudhound)
|
3
|
+
[![Gem Version](https://fury-badge.herokuapp.com/rb/egi-fedcloud-cloudhound.png)](https://badge.fury.io/rb/egi-fedcloud-cloudhound)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/arax/egi-fedcloud-cloudhound.png)](https://codeclimate.com/github/arax/egi-fedcloud-cloudhound)
|
5
|
+
|
6
|
+
# EGI FedCloud CloudHound
|
7
|
+
|
8
|
+
A proof-of-concept utility for locating cloud sites and corresponding CSIRT/CERT contacts in EGI Federated Cloud.
|
9
|
+
|
10
|
+
## Contributing
|
11
|
+
|
12
|
+
1. Fork it ( https://github.com/arax/egi-fedcloud-cloudhound/fork )
|
13
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
14
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
15
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
16
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems/tasks'
|
2
|
+
|
3
|
+
task :default => 'test'
|
4
|
+
|
5
|
+
desc "Run all tests; includes rspec and coverage reports"
|
6
|
+
task :test => 'rcov:all'
|
7
|
+
|
8
|
+
desc "Run all tests; includes rspec and coverage reports"
|
9
|
+
task :spec => 'test'
|
10
|
+
|
11
|
+
Gem::Tasks.new(:build => {:tar => true, :zip => true}, :sign => {:checksum => true, :pgp => false})
|
12
|
+
|
13
|
+
namespace :rcov do
|
14
|
+
|
15
|
+
require 'rspec/core/rake_task'
|
16
|
+
|
17
|
+
RSpec::Core::RakeTask.new(:rspec) do |t|
|
18
|
+
ENV['COVERAGE'] = "true"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Run rspec to generate aggregated coverage"
|
22
|
+
task :all do |t|
|
23
|
+
rm "coverage/coverage.data" if File.exist?("coverage/coverage.data")
|
24
|
+
Rake::Task['rcov:rspec'].invoke
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# -------------------------------------------------------------------------- #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
6
|
+
# a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
#--------------------------------------------------------------------------- #
|
16
|
+
|
17
|
+
require 'rubygems'
|
18
|
+
|
19
|
+
require 'thor'
|
20
|
+
require 'egi-fedcloud-cloudhound'
|
21
|
+
|
22
|
+
class EgiFedcloudCloudhound < Thor
|
23
|
+
include Thor::Actions
|
24
|
+
|
25
|
+
desc "ip IP_ADDRESS", "Prints information based on the provided IP address or IP address range"
|
26
|
+
method_option :credentials, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.credentials,
|
27
|
+
:aliases => '-c', :desc => 'PEM file with a personal certificate and private key'
|
28
|
+
method_option :password, :type => :string, :default => nil,
|
29
|
+
:aliases => '-p', :desc => 'PEM private key password'
|
30
|
+
method_option :ca_path, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.ca_path,
|
31
|
+
:aliases => '-x', :desc => 'Directory path to all trusted CA certificates'
|
32
|
+
method_option :gocdb_base_url, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.gocdb_base_url,
|
33
|
+
:aliases => '-g', :desc => 'GOCDB endpoint URL'
|
34
|
+
method_option :appdb_base_url, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.appdb_base_url,
|
35
|
+
:aliases => '-a', :desc => 'AppDB API endpoint URL'
|
36
|
+
method_option :debug, :type => :boolean, :default => Egi::Fedcloud::Cloudhound::Settings.debug,
|
37
|
+
:aliases => '-d', :desc => 'Enable debugging'
|
38
|
+
def ip(ip_address)
|
39
|
+
init_log options[:debug]
|
40
|
+
|
41
|
+
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.as_table(
|
42
|
+
Egi::Fedcloud::Cloudhound::Extractor.find_by_ip(
|
43
|
+
ip_address,
|
44
|
+
options
|
45
|
+
)
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "appuri URI", "Prints information based on the provided Appliance MPURI"
|
50
|
+
method_option :credentials, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.credentials,
|
51
|
+
:aliases => '-c', :desc => 'PEM file with a personal certificate and private key'
|
52
|
+
method_option :password, :type => :string, :default => nil,
|
53
|
+
:aliases => '-p', :desc => 'PEM private key password'
|
54
|
+
method_option :ca_path, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.ca_path,
|
55
|
+
:aliases => '-x', :desc => 'Directory path to all trusted CA certificates'
|
56
|
+
method_option :gocdb_base_url, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.gocdb_base_url,
|
57
|
+
:aliases => '-g', :desc => 'GOCDB endpoint URL'
|
58
|
+
method_option :appdb_base_url, :type => :string, :default => Egi::Fedcloud::Cloudhound::Settings.appdb_base_url,
|
59
|
+
:aliases => '-a', :desc => 'AppDB API endpoint URL'
|
60
|
+
method_option :debug, :type => :boolean, :default => Egi::Fedcloud::Cloudhound::Settings.debug,
|
61
|
+
:aliases => '-d', :desc => 'Enable debugging'
|
62
|
+
def appuri(uri)
|
63
|
+
init_log options[:debug]
|
64
|
+
|
65
|
+
$stdout.puts Egi::Fedcloud::Cloudhound::Formatter.as_table(
|
66
|
+
Egi::Fedcloud::Cloudhound::Extractor.find_by_appuri(
|
67
|
+
uri,
|
68
|
+
options
|
69
|
+
)
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Static method required by Thor to make certain
|
74
|
+
# actions work.
|
75
|
+
def self.source_root
|
76
|
+
File.expand_path(File.join('..', '..', 'config'), __FILE__)
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
# Initializes logging facilities.
|
82
|
+
#
|
83
|
+
# @param debug [Boolean] rudimentary logging level control
|
84
|
+
# @return [Egi::Fedcloud::Cloudhound::Log] logger instance for additional configuration
|
85
|
+
def init_log(debug = false)
|
86
|
+
logger = Egi::Fedcloud::Cloudhound::Log.new(STDERR)
|
87
|
+
logger.level = debug ? Egi::Fedcloud::Cloudhound::Log::DEBUG : Egi::Fedcloud::Cloudhound::Log::ERROR
|
88
|
+
logger
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
EgiFedcloudCloudhound.start
|
data/config/settings.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
production:
|
3
|
+
credentials: "<%= ENV['HOME'] %>/.globus/usercred.pem"
|
4
|
+
ca_path: '/etc/grid-security/certificates'
|
5
|
+
gocdb_base_url: 'https://goc.egi.eu'
|
6
|
+
appdb_base_url: 'https://appdb-pi.egi.eu'
|
7
|
+
debug: false
|
8
|
+
|
9
|
+
development:
|
10
|
+
credentials: "<%= ENV['HOME'] %>/.globus/usercred.pem"
|
11
|
+
ca_path: '/etc/grid-security/certificates'
|
12
|
+
gocdb_base_url: 'https://goc.egi.eu'
|
13
|
+
appdb_base_url: 'https://appdb-pi.egi.eu'
|
14
|
+
debug: true
|
15
|
+
|
16
|
+
test:
|
17
|
+
credentials: "<%= ENV['HOME'] %>/.globus/testcred.pem"
|
18
|
+
ca_path: '/etc/grid-security/certificates'
|
19
|
+
gocdb_base_url: 'http://localhost/goc'
|
20
|
+
appdb_base_url: 'http://localhost/appdb-pi'
|
21
|
+
debug: true
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'egi/fedcloud/cloudhound/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |gem|
|
8
|
+
gem.name = "egi-fedcloud-cloudhound"
|
9
|
+
gem.version = Egi::Fedcloud::Cloudhound::VERSION
|
10
|
+
gem.authors = ["Boris Parak"]
|
11
|
+
gem.email = ['parak@cesnet.cz']
|
12
|
+
gem.description = %q{A proof-of-concept utility for locating cloud sites and corresponding CSIRT/CERT contacts in EGI Federated Cloud}
|
13
|
+
gem.summary = %q{A proof-of-concept utility for locating cloud sites and corresponding CSIRT/CERT contacts in EGI Federated Cloud}
|
14
|
+
gem.homepage = 'https://github.com/arax/egi-fedcloud-cloudhound'
|
15
|
+
gem.license = 'Apache License, Version 2.0'
|
16
|
+
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
gem.files = `git ls-files`.split("\n")
|
19
|
+
gem.test_files = `git ls-files -- {test,spec}/*`.split("\n")
|
20
|
+
gem.require_paths = ['lib']
|
21
|
+
|
22
|
+
gem.add_dependency 'activesupport', '~> 4.0', '>= 4.0.0'
|
23
|
+
gem.add_dependency 'settingslogic', '~> 2.0', '>= 2.0.9'
|
24
|
+
gem.add_dependency 'thor', '~> 0.19', '>= 0.19.1'
|
25
|
+
gem.add_dependency 'httparty', '~> 0.13', '>= 0.13.3'
|
26
|
+
gem.add_dependency 'highline', '~> 1.7', '>= 1.7.2'
|
27
|
+
gem.add_dependency 'terminal-table', '~> 1.4', '>= 1.4.5'
|
28
|
+
gem.add_dependency 'ox', '~> 2.2', '>= 2.2.0'
|
29
|
+
|
30
|
+
gem.add_development_dependency 'bundler', '~> 1.6'
|
31
|
+
gem.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
gem.add_development_dependency 'rspec', '~> 3.0.0'
|
33
|
+
gem.add_development_dependency 'simplecov', '~> 0.9.0'
|
34
|
+
gem.add_development_dependency 'rubygems-tasks', '~> 0.2.4'
|
35
|
+
|
36
|
+
gem.required_ruby_version = ">= 1.9.3"
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Initialize modules, if necessary
|
2
|
+
module Egi; end
|
3
|
+
module Egi::Fedcloud; end
|
4
|
+
module Egi::Fedcloud::Cloudhound; end
|
5
|
+
|
6
|
+
require 'active_support'
|
7
|
+
require 'active_support/core_ext'
|
8
|
+
require 'active_support/json'
|
9
|
+
require 'active_support/inflector'
|
10
|
+
require 'active_support/notifications'
|
11
|
+
|
12
|
+
require 'egi/fedcloud/cloudhound/version'
|
13
|
+
require 'egi/fedcloud/cloudhound/settings'
|
14
|
+
require 'egi/fedcloud/cloudhound/log'
|
15
|
+
require 'egi/fedcloud/cloudhound/formatter'
|
16
|
+
require 'egi/fedcloud/cloudhound/connector'
|
17
|
+
require 'egi/fedcloud/cloudhound/appdb_site'
|
18
|
+
require 'egi/fedcloud/cloudhound/appdb_appliance'
|
19
|
+
require 'egi/fedcloud/cloudhound/appdb'
|
20
|
+
require 'egi/fedcloud/cloudhound/gocdb_site'
|
21
|
+
require 'egi/fedcloud/cloudhound/gocdb'
|
22
|
+
require 'egi/fedcloud/cloudhound/extractor'
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'ox'
|
2
|
+
|
3
|
+
#
|
4
|
+
class Egi::Fedcloud::Cloudhound::Appdb < Egi::Fedcloud::Cloudhound::Connector
|
5
|
+
|
6
|
+
APPDB_SITES_URL = '/rest/1.0/sites?flt=+=&site.supports:1'
|
7
|
+
|
8
|
+
#
|
9
|
+
def initialize(opts = {}, password = nil)
|
10
|
+
super
|
11
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] With AppDB instance at #{opts[:appdb_base_url].inspect}"
|
12
|
+
@appdb_base_url = opts[:appdb_base_url].chomp '/'
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
def sites
|
17
|
+
return @cached_sites if @cached_sites
|
18
|
+
|
19
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Pulling site data from \"#{@appdb_base_url}#{APPDB_SITES_URL}\""
|
20
|
+
sites = Ox.parse retrieve("#{@appdb_base_url}#{APPDB_SITES_URL}")
|
21
|
+
@cached_sites = sites.locate('appdb/*').map { |site| Egi::Fedcloud::Cloudhound::AppdbSite.new(site) }
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
def production_sites
|
26
|
+
production sites
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
def certified_production_sites
|
31
|
+
certified production_sites
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
def cloud_sites
|
36
|
+
sites.select { |site| site.type == 'cloud' }
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
def production_cloud_sites
|
41
|
+
production cloud_sites
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
def certified_production_cloud_sites
|
46
|
+
certified production_cloud_sites
|
47
|
+
end
|
48
|
+
|
49
|
+
#
|
50
|
+
def appliance(uri)
|
51
|
+
uri = uri.chomp '/'
|
52
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Pulling appliance data from \"#{uri}/json\""
|
53
|
+
raw_appliance = JSON.parse retrieve("#{uri}/json")
|
54
|
+
Egi::Fedcloud::Cloudhound::AppdbAppliance.new raw_appliance
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
def site_gocdb(site_name)
|
59
|
+
found = sites.select { |site| site.name == site_name }
|
60
|
+
found.first ? found.first.gocdb_link : nil
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def production(sites)
|
66
|
+
sites.select { |site| site.infrastructure == 'Production' }
|
67
|
+
end
|
68
|
+
|
69
|
+
def certified(sites)
|
70
|
+
sites.select { |site| site.status == 'Certified' }
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#
|
2
|
+
class Egi::Fedcloud::Cloudhound::AppdbAppliance
|
3
|
+
|
4
|
+
attr_reader :identifier, :version, :url,
|
5
|
+
:checksum, :format, :owner,
|
6
|
+
:published, :mpuri
|
7
|
+
attr_reader :sites
|
8
|
+
|
9
|
+
#
|
10
|
+
def initialize(element)
|
11
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Initializing with #{element.inspect}"
|
12
|
+
|
13
|
+
@identifier = element['identifier']
|
14
|
+
@version = element['version']
|
15
|
+
@url = element['url']
|
16
|
+
@checksum = element['checksum']
|
17
|
+
@format = element['format']
|
18
|
+
@owner = element['addedby'] ? element['addedby']['permalink'] : 'unknown'
|
19
|
+
@published = element['published']
|
20
|
+
@mpuri = element['mpuri']
|
21
|
+
|
22
|
+
# and now the difficult part
|
23
|
+
@sites = self.class.extract_sites(element['sites'])
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
#
|
28
|
+
def extract_sites(element)
|
29
|
+
return [] if element.blank?
|
30
|
+
|
31
|
+
element.collect do |site|
|
32
|
+
st = {}
|
33
|
+
st['name'] = site['name']
|
34
|
+
st['gocdb_link'] = site['url'] ? site['url']['portal'] : 'unknown'
|
35
|
+
st['vos'] = extract_site_vos(site['services'])
|
36
|
+
st
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
def extract_site_vos(element)
|
42
|
+
return [] if element.blank?
|
43
|
+
|
44
|
+
vos = []
|
45
|
+
element.each do |service|
|
46
|
+
vos << service['vos'].collect { |vo| vo['name'] }
|
47
|
+
end
|
48
|
+
vos.flatten!
|
49
|
+
vos.compact!
|
50
|
+
vos.uniq!
|
51
|
+
|
52
|
+
vos
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
class Egi::Fedcloud::Cloudhound::AppdbSite
|
3
|
+
|
4
|
+
attr_reader :type, :name, :gocdb_link, :status, :infrastructure
|
5
|
+
attr_reader :services
|
6
|
+
|
7
|
+
#
|
8
|
+
def initialize(element)
|
9
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Initializing with #{element.inspect}"
|
10
|
+
|
11
|
+
@services = self.class.extract_services(element)
|
12
|
+
@gocdb_link = self.class.extract_gocdb_link(element)
|
13
|
+
@name = element.name
|
14
|
+
@type = @services.empty? ? 'grid' : 'cloud'
|
15
|
+
@status = element.status
|
16
|
+
@infrastructure = element.infrastructure
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
def contacts
|
21
|
+
{
|
22
|
+
name: name,
|
23
|
+
type: type,
|
24
|
+
status: status,
|
25
|
+
csirt: nil,
|
26
|
+
ngi: nil
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
class << self
|
31
|
+
|
32
|
+
#
|
33
|
+
def extract_services(element)
|
34
|
+
services = (element.locate('service') || [])
|
35
|
+
services.map do |service|
|
36
|
+
srv = {}
|
37
|
+
srv['type'] = service.type
|
38
|
+
srv['host'] = service.host
|
39
|
+
srv
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
def extract_gocdb_link(element)
|
45
|
+
urls = (element.locate('url') || [])
|
46
|
+
portals = urls.select { |url| url.text && url.type('portal') }
|
47
|
+
portals.first ? portals.first.text : nil
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'highline/import'
|
3
|
+
|
4
|
+
#
|
5
|
+
class Egi::Fedcloud::Cloudhound::Connector
|
6
|
+
include HTTParty
|
7
|
+
|
8
|
+
#
|
9
|
+
def initialize(opts = {}, password = nil)
|
10
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Initializing with #{opts.inspect}"
|
11
|
+
|
12
|
+
self.class.pem File.read(opts[:credentials]), password
|
13
|
+
self.class.ssl_ca_path opts[:ca_path]
|
14
|
+
self.class.debug_output $stderr if opts[:debug]
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
def retrieve(url = '/')
|
19
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Retrieving #{url.inspect}"
|
20
|
+
response = self.class.get url
|
21
|
+
raise "Failed to get a response from '#{url}' [#{response.code}]" unless response.code.between?(200,299)
|
22
|
+
|
23
|
+
response.body
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
require 'highline/import'
|
3
|
+
|
4
|
+
#
|
5
|
+
class Egi::Fedcloud::Cloudhound::Extractor
|
6
|
+
|
7
|
+
LOOKUP_ORDER = %w(certified_production_sites production_sites sites)
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def init(options)
|
12
|
+
# TODO: move upstream
|
13
|
+
password = options[:password] ? options[:password] : ask("Enter PEM password: ") { |q| q.echo = false }
|
14
|
+
|
15
|
+
@@gocdb ||= Egi::Fedcloud::Cloudhound::Gocdb.new(options, password)
|
16
|
+
@@appdb ||= Egi::Fedcloud::Cloudhound::Appdb.new(options, password)
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
def find_by_ip(ip, options = {})
|
21
|
+
init options
|
22
|
+
|
23
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Searching for contacts by IP: #{ip.inspect}"
|
24
|
+
found = []
|
25
|
+
LOOKUP_ORDER.each do |lookup_type|
|
26
|
+
found << @@gocdb.send(lookup_type).select { |site| site.in_range?(ip) }
|
27
|
+
found.flatten!
|
28
|
+
found.compact!
|
29
|
+
|
30
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Found #{found.inspect} in #{lookup_type.inspect}"
|
31
|
+
break unless found.blank?
|
32
|
+
end
|
33
|
+
|
34
|
+
found.collect { |site| site.contacts }
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
def find_by_appuri(uri, options = {})
|
39
|
+
init options
|
40
|
+
|
41
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Searching for contacts by MPURI: #{uri.inspect}"
|
42
|
+
sites = @@appdb.appliance(uri).sites.collect { |site| site['name'] }
|
43
|
+
|
44
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Querying #{sites.inspect} for contact details"
|
45
|
+
found = []
|
46
|
+
sites.each do |affected_site|
|
47
|
+
LOOKUP_ORDER.each do |lookup_type|
|
48
|
+
found << @@gocdb.send(lookup_type).select { |site| site.name == affected_site }
|
49
|
+
found.flatten!
|
50
|
+
found.compact!
|
51
|
+
|
52
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Found #{found.inspect} in #{lookup_type.inspect}"
|
53
|
+
break unless found.blank?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
found.collect { |site| site.contacts }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
|
3
|
+
#
|
4
|
+
class Egi::Fedcloud::Cloudhound::Formatter
|
5
|
+
|
6
|
+
class << self
|
7
|
+
#
|
8
|
+
def as_table(data = [])
|
9
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] Transforming #{data.inspect} into a table"
|
10
|
+
table = Terminal::Table.new
|
11
|
+
|
12
|
+
table.add_row [' >>> Site Name <<< ', ' >>> NGI Name <<< ', ' >>> CSIRT Contact(s) <<< ']
|
13
|
+
table.add_separator
|
14
|
+
data.each do |site|
|
15
|
+
table.add_separator
|
16
|
+
table.add_row [site[:name], site[:ngi], site[:csirt]]
|
17
|
+
end
|
18
|
+
|
19
|
+
table
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
def as_json(data = [])
|
24
|
+
data ? JSON.generate(data) : '{}'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'ox'
|
2
|
+
|
3
|
+
#
|
4
|
+
class Egi::Fedcloud::Cloudhound::Gocdb < Egi::Fedcloud::Cloudhound::Connector
|
5
|
+
|
6
|
+
GOCDB_SITES_URL = '/gocdbpi/private/?method=get_site'
|
7
|
+
GOCDB_PROD_SITES_URL = "#{GOCDB_SITES_URL}&production_status=Production"
|
8
|
+
GOCDB_CERT_PROD_SITES_URL = "#{GOCDB_PROD_SITES_URL}&certification_status=Certified"
|
9
|
+
|
10
|
+
CLOUD_SERVICE_TYPES = [
|
11
|
+
"eu.egi.cloud.vm-management.occi",
|
12
|
+
"eu.egi.cloud.storage-management.cdmi",
|
13
|
+
"eu.egi.cloud.accounting",
|
14
|
+
"eu.egi.cloud.information.bdii",
|
15
|
+
"eu.egi.cloud.vm.metadata-vmcatcher",
|
16
|
+
]
|
17
|
+
|
18
|
+
#
|
19
|
+
def initialize(opts = {}, password = nil)
|
20
|
+
super
|
21
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] With GOCDB instance at #{opts[:gocdb_base_url].inspect}"
|
22
|
+
self.class.base_uri opts[:gocdb_base_url]
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
def sites
|
27
|
+
get_and_parse GOCDB_SITES_URL, 'sites'
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
def production_sites
|
32
|
+
get_and_parse GOCDB_PROD_SITES_URL, 'prod_sites'
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
def certified_production_sites
|
37
|
+
get_and_parse GOCDB_CERT_PROD_SITES_URL, 'cert_prod_sites'
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
#
|
43
|
+
def get_and_parse(url, type)
|
44
|
+
return instance_variable_get("@cached_#{type}") if instance_variable_defined?("@cached_#{type}")
|
45
|
+
|
46
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Pulling site data from #{url.inspect}"
|
47
|
+
results = Ox.parse retrieve(url)
|
48
|
+
results = results.locate('results/*').map { |site| Egi::Fedcloud::Cloudhound::GocdbSite.new(site) }
|
49
|
+
instance_variable_set("@cached_#{type}", results)
|
50
|
+
|
51
|
+
results
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
|
3
|
+
#
|
4
|
+
class Egi::Fedcloud::Cloudhound::GocdbSite
|
5
|
+
|
6
|
+
INVALID_RANGES = %w(255.255.255.255/0.0.0.0 0.0.0.0/0.0.0.0)
|
7
|
+
|
8
|
+
attr_reader :name, :csirt_email, :contact_email, :ngi, :ip_ranges
|
9
|
+
|
10
|
+
#
|
11
|
+
def initialize(element)
|
12
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Initializing with #{element.inspect}"
|
13
|
+
@name = self.class.extract_text(element.locate('SHORT_NAME'))
|
14
|
+
@csirt_email = self.class.extract_text(element.locate('CSIRT_EMAIL'))
|
15
|
+
@contact_email = self.class.extract_text(element.locate('CONTACT_EMAIL'))
|
16
|
+
@ngi = self.class.extract_text(element.locate('ROC'))
|
17
|
+
|
18
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Extracting IP ranges for site #{@name}"
|
19
|
+
@ip_ranges = self.class.extract_ranges(self.class.extract_text(element.locate('SITE_IP')))
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
def in_range?(ip)
|
24
|
+
ip = ip.to_s if ip.kind_of?(IPAddr)
|
25
|
+
|
26
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] Checking #{ip.inspect} against #{name}'s ranges"
|
27
|
+
ip_ranges.each do |my_range|
|
28
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self.class}] -- #{my_range.inspect}"
|
29
|
+
return true if my_range.include?(ip)
|
30
|
+
end
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
def contacts
|
36
|
+
{
|
37
|
+
name: name,
|
38
|
+
type: nil,
|
39
|
+
status: nil,
|
40
|
+
csirt: csirt_email,
|
41
|
+
ngi: ngi
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
class << self
|
46
|
+
#
|
47
|
+
def extract_ranges(text_ranges)
|
48
|
+
ranges = text_ranges.split(/[,;]/).reject { |el| el.blank? || !el.include?('/') || INVALID_RANGES.include?(el) }
|
49
|
+
|
50
|
+
Egi::Fedcloud::Cloudhound::Log.debug "[#{self}] -- Ranges: #{ranges.inspect}"
|
51
|
+
ranges.map! do |range|
|
52
|
+
begin
|
53
|
+
IPAddr.new(range)
|
54
|
+
rescue
|
55
|
+
Egi::Fedcloud::Cloudhound::Log.warn "[#{self}] -- Invalid range #{range.inspect}"
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
ranges.compact!
|
60
|
+
|
61
|
+
ranges
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
def extract_text(element)
|
66
|
+
(element && element.first) ? element.first.text : ''
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
class Egi::Fedcloud::Cloudhound::Log
|
4
|
+
include ::Logger::Severity
|
5
|
+
|
6
|
+
attr_reader :logger, :log_prefix
|
7
|
+
|
8
|
+
SUBSCRIPTION_HANDLE = "egi-fedcloud-cloudhound.log"
|
9
|
+
|
10
|
+
# Creates a new logger instance.
|
11
|
+
#
|
12
|
+
# @param log_dev [IO,String] The log device. This is a filename (String) or IO object (typically +STDOUT+)
|
13
|
+
# @param log_prefix [String] String placed in front of every logged message +STDERR+, or an open file).
|
14
|
+
def initialize(log_dev, log_prefix = '')
|
15
|
+
if log_dev.kind_of? ::Logger
|
16
|
+
@logger = log_dev
|
17
|
+
else
|
18
|
+
@logger = ::Logger.new(log_dev)
|
19
|
+
end
|
20
|
+
|
21
|
+
@log_prefix = log_prefix.blank? ? '' : log_prefix.strip
|
22
|
+
@log_prefix << ' ' unless @log_prefix.blank?
|
23
|
+
|
24
|
+
# subscribe to log messages and send to logger
|
25
|
+
@log_subscriber = ActiveSupport::Notifications.subscribe(self.class::SUBSCRIPTION_HANDLE) do |name, start, finish, id, payload|
|
26
|
+
@logger.log(payload[:level], "#{@log_prefix}#{payload[:message]}") if @logger
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def close
|
31
|
+
ActiveSupport::Notifications.unsubscribe(@log_subscriber)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param severity [::Logger::Severity] severity
|
35
|
+
def level=(severity)
|
36
|
+
@logger.level = severity
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [::Logger::Severity]
|
40
|
+
def level
|
41
|
+
@logger.level
|
42
|
+
end
|
43
|
+
|
44
|
+
# @see info
|
45
|
+
def self.debug(message)
|
46
|
+
ActiveSupport::Notifications.instrument(self::SUBSCRIPTION_HANDLE, :level => ::Logger::DEBUG, :message => message)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Log an +INFO+ message
|
50
|
+
# @param message [String] message the message to log; does not need to be a String
|
51
|
+
def self.info(message)
|
52
|
+
ActiveSupport::Notifications.instrument(self::SUBSCRIPTION_HANDLE, :level => ::Logger::INFO, :message => message)
|
53
|
+
end
|
54
|
+
|
55
|
+
# @see info
|
56
|
+
def self.warn(message)
|
57
|
+
ActiveSupport::Notifications.instrument(self::SUBSCRIPTION_HANDLE, :level => ::Logger::WARN, :message => message)
|
58
|
+
end
|
59
|
+
|
60
|
+
# @see info
|
61
|
+
def self.error(message)
|
62
|
+
ActiveSupport::Notifications.instrument(self::SUBSCRIPTION_HANDLE, :level => ::Logger::ERROR, :message => message)
|
63
|
+
end
|
64
|
+
|
65
|
+
# @see info
|
66
|
+
def self.fatal(message)
|
67
|
+
ActiveSupport::Notifications.instrument(self::SUBSCRIPTION_HANDLE, :level => ::Logger::FATAL, :message => message)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'settingslogic'
|
2
|
+
|
3
|
+
#
|
4
|
+
class Egi::Fedcloud::Cloudhound::Settings < Settingslogic
|
5
|
+
GEM_ROOT = File.expand_path '../../../../..', __FILE__
|
6
|
+
|
7
|
+
source "#{ENV['HOME']}/.egi-fedcloud-cloudhound" if File.readable?("#{ENV['HOME']}/.egi-fedcloud-cloudhound")
|
8
|
+
source "#{GEM_ROOT}/config/settings.yml"
|
9
|
+
|
10
|
+
namespace ((ENV['DEBUG'] == '1') ? 'development' : 'production')
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,280 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: egi-fedcloud-cloudhound
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Boris Parak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: settingslogic
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.0.9
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.0.9
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: thor
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.19'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.19.1
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.19'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 0.19.1
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: httparty
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.13'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.13.3
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.13'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.13.3
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: highline
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '1.7'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.7.2
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.7'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.7.2
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: terminal-table
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '1.4'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.4.5
|
123
|
+
type: :runtime
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '1.4'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 1.4.5
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: ox
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '2.2'
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 2.2.0
|
143
|
+
type: :runtime
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '2.2'
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 2.2.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: bundler
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.6'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.6'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rake
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '10.0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '10.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 3.0.0
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 3.0.0
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: simplecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 0.9.0
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 0.9.0
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rubygems-tasks
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 0.2.4
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 0.2.4
|
223
|
+
description: A proof-of-concept utility for locating cloud sites and corresponding
|
224
|
+
CSIRT/CERT contacts in EGI Federated Cloud
|
225
|
+
email:
|
226
|
+
- parak@cesnet.cz
|
227
|
+
executables:
|
228
|
+
- egi-fedcloud-cloudhound
|
229
|
+
extensions: []
|
230
|
+
extra_rdoc_files: []
|
231
|
+
files:
|
232
|
+
- ".gitignore"
|
233
|
+
- ".rspec"
|
234
|
+
- ".travis.yml"
|
235
|
+
- Gemfile
|
236
|
+
- LICENSE
|
237
|
+
- README.md
|
238
|
+
- Rakefile
|
239
|
+
- bin/egi-fedcloud-cloudhound
|
240
|
+
- config/settings.yml
|
241
|
+
- egi-fedcloud-cloudhound.gemspec
|
242
|
+
- lib/egi-fedcloud-cloudhound.rb
|
243
|
+
- lib/egi/fedcloud/cloudhound/appdb.rb
|
244
|
+
- lib/egi/fedcloud/cloudhound/appdb_appliance.rb
|
245
|
+
- lib/egi/fedcloud/cloudhound/appdb_site.rb
|
246
|
+
- lib/egi/fedcloud/cloudhound/connector.rb
|
247
|
+
- lib/egi/fedcloud/cloudhound/extractor.rb
|
248
|
+
- lib/egi/fedcloud/cloudhound/formatter.rb
|
249
|
+
- lib/egi/fedcloud/cloudhound/gocdb.rb
|
250
|
+
- lib/egi/fedcloud/cloudhound/gocdb_site.rb
|
251
|
+
- lib/egi/fedcloud/cloudhound/log.rb
|
252
|
+
- lib/egi/fedcloud/cloudhound/settings.rb
|
253
|
+
- lib/egi/fedcloud/cloudhound/version.rb
|
254
|
+
- spec/spec_helper.rb
|
255
|
+
homepage: https://github.com/arax/egi-fedcloud-cloudhound
|
256
|
+
licenses:
|
257
|
+
- Apache License, Version 2.0
|
258
|
+
metadata: {}
|
259
|
+
post_install_message:
|
260
|
+
rdoc_options: []
|
261
|
+
require_paths:
|
262
|
+
- lib
|
263
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
264
|
+
requirements:
|
265
|
+
- - ">="
|
266
|
+
- !ruby/object:Gem::Version
|
267
|
+
version: 1.9.3
|
268
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
269
|
+
requirements:
|
270
|
+
- - ">="
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
version: '0'
|
273
|
+
requirements: []
|
274
|
+
rubyforge_project:
|
275
|
+
rubygems_version: 2.2.2
|
276
|
+
signing_key:
|
277
|
+
specification_version: 4
|
278
|
+
summary: A proof-of-concept utility for locating cloud sites and corresponding CSIRT/CERT
|
279
|
+
contacts in EGI Federated Cloud
|
280
|
+
test_files: []
|