right_scraper 5.1.1 → 5.2.2
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 +4 -4
- data/bin/right_scraper-retrieve +9 -0
- data/bin/right_scraper-scan +24 -7
- data/lib/right_scraper/main.rb +10 -0
- data/lib/right_scraper/resources/cookbook.rb +10 -3
- data/lib/right_scraper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af3229fa87070f86fc76485027161ac82a40b77d
|
4
|
+
data.tar.gz: c65bfccf9eddef84be1fe95dff0d08a9a6d07e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0f38e7b46f971944d51e4b44fb4fef807c89a4e246ee7752b7eb8eea5719a188c6cdb549f46b924a8e9f21a1ee481d8225ef1a3a5c9303e3a940a4fc3c7d485
|
7
|
+
data.tar.gz: 6f051b52dc8c674eacf16e9c7a0cbdb0efd06c7cdd256e875bbb4d74a887c5367c057f42d4704032d7310d0882968c94046a94ce957703c8310b6aef3aa81232
|
data/bin/right_scraper-retrieve
CHANGED
@@ -39,6 +39,15 @@ main = nil
|
|
39
39
|
begin
|
40
40
|
options = ::JSON.load(::File.read(::ARGV.shift))
|
41
41
|
repository = ::JSON.load(::File.read(::ARGV.shift))
|
42
|
+
|
43
|
+
# use credentials from environment, if available.
|
44
|
+
if !(repo_first_cred = ::ENV['REPOSITORY_FIRST_CREDENTIAL'].to_s).empty?
|
45
|
+
repository['first_credential'] = repo_first_cred
|
46
|
+
if !(repo_second_cred = ::ENV['REPOSITORY_SECOND_CREDENTIAL'].to_s).empty?
|
47
|
+
repository['second_credential'] = repo_second_cred
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
42
51
|
main = ::RightScraper::Main.new(options)
|
43
52
|
if retrieved = main.retrieve(repository)
|
44
53
|
# remove any credentials from repository after retrieval; not needed in
|
data/bin/right_scraper-scan
CHANGED
@@ -41,18 +41,35 @@ begin
|
|
41
41
|
retrieved = ::JSON.load(::File.read(::ARGV.shift))
|
42
42
|
main = ::RightScraper::Main.new(options)
|
43
43
|
|
44
|
+
# use credentials from environment, if available.
|
45
|
+
if !(aws_access_key_id = ::ENV['AWS_ACCESS_KEY_ID'].to_s).empty?
|
46
|
+
options['s3_key'] = aws_access_key_id
|
47
|
+
if !(aws_secret_access_key = ::ENV['AWS_SECRET_ACCESS_KEY'].to_s).empty?
|
48
|
+
options['s3_secret'] = aws_secret_access_key
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
44
52
|
# cleanup any leftover errors/warnings in retrieved hash.
|
45
53
|
retrieved.delete('errors')
|
46
54
|
retrieved.delete('warnings')
|
47
55
|
if main.scan(retrieved)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
56
|
+
result = {}
|
57
|
+
result[:warnings] = main.warnings unless main.warnings.empty?
|
58
|
+
|
59
|
+
# we can optimize by not marshaling back resources when the only scanner is
|
60
|
+
# CookbookMetadata. the reason is that we expect this scanner to only be
|
61
|
+
# called in unprivileged isolation followed by more scanners with more
|
62
|
+
# privileges and only the latter need to return fully resolved resources.
|
63
|
+
if main.scanners != [RightScraper::Scanners::CookbookMetadata]
|
64
|
+
result[:resources] = main.resources.map do |r|
|
65
|
+
# remove relational repository from each returned cookbook due to being
|
66
|
+
# the same for each resource and already known to caller.
|
67
|
+
h = r.to_hash
|
68
|
+
h.delete(:repository)
|
69
|
+
h
|
70
|
+
end
|
54
71
|
end
|
55
|
-
$stdout.puts(::JSON.generate(
|
72
|
+
$stdout.puts(::JSON.generate(result))
|
56
73
|
else
|
57
74
|
result = { errors: main.errors }
|
58
75
|
$stderr.puts(::JSON.generate(result))
|
data/lib/right_scraper/main.rb
CHANGED
@@ -221,6 +221,16 @@ module RightScraper
|
|
221
221
|
@logger.warnings
|
222
222
|
end
|
223
223
|
|
224
|
+
# (Array):: scanners or empty
|
225
|
+
def builders
|
226
|
+
return @options[:builders]
|
227
|
+
end
|
228
|
+
|
229
|
+
# (Array):: scanners or empty
|
230
|
+
def scanners
|
231
|
+
return @options[:scanners]
|
232
|
+
end
|
233
|
+
|
224
234
|
# Was scraping successful?
|
225
235
|
# Call errors to get error messages if false
|
226
236
|
#
|
@@ -72,8 +72,8 @@ module RightScraper::Resources
|
|
72
72
|
def to_hash
|
73
73
|
{
|
74
74
|
repository: repository,
|
75
|
-
metadata: metadata,
|
76
|
-
manifest: manifest,
|
75
|
+
metadata: ::JSON.dump(metadata), # pass these as opaque JSON blobs to
|
76
|
+
manifest: ::JSON.dump(manifest), # be unmarshaled only by from_hash
|
77
77
|
pos: pos
|
78
78
|
}
|
79
79
|
end
|
@@ -82,7 +82,14 @@ module RightScraper::Resources
|
|
82
82
|
def self.from_hash(h)
|
83
83
|
h = ::RightSupport::Data::Mash.new(h)
|
84
84
|
c = self.new(h[:repository], h[:pos], h[:repo_dir])
|
85
|
-
|
85
|
+
if (md = h[:metadata]).kind_of?(::String)
|
86
|
+
md = ::JSON.load(md)
|
87
|
+
end
|
88
|
+
c.metadata = md
|
89
|
+
if (mf = h[:manifest]).kind_of?(::String)
|
90
|
+
mf = ::JSON.load(mf)
|
91
|
+
end
|
92
|
+
c.manifest = mf
|
86
93
|
c
|
87
94
|
end
|
88
95
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Simon
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-03-
|
13
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: right_aws
|