Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json #146

Merged
merged 4 commits into from
Oct 26, 2015
Merged

Json #146

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Max: 10
Metrics/AbcSize:
Max: 29
Style/DotPosition:
EnforcedStyle: trailing
Enabled: true
Max: 33
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': '{}'
Expand Down
57 changes: 22 additions & 35 deletions bin/vulcano
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,6 @@ require 'json'
require_relative '../lib/vulcano'

class VulcanoCLI < Thor
desc 'json PATH', 'read all tests in PATH and generate a JSON-profile'
option :output, aliases: :o, type: :string
option :print, aliases: :p, type: :boolean
option :id, type: :string
def json(*paths)
require_relative '../lib/verify'
paths.each do |path|
Vulcano::Profiles.new.valid_folder? path unless options[:print]
vc = Vulcano::Profiles.new({ quiet: options[:print], id: options[:id] })
vc.add_folder(path)
if options[:print]
puts JSON.pretty_generate(vc.profiles)
else
dst = options[:output] || File.join(path, '.vulcano.json')
if File.exist? dst
puts "----> updating #{dst}"
else
puts "----> creating #{dst}"
end
fdst = File.expand_path(dst)
File.write(fdst, JSON.dump(vc.profiles))
end
end
end

desc 'check PATH', 'check all tests in PATH'
def check(*paths)
require_relative '../lib/verify'
paths.each do |path|
puts "#{path}"
Vulcano::Profiles.new.valid_folder? path
puts
end
end

def self.target_options
option :target, aliases: :t, type: :string, default: nil,
desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port'
Expand Down Expand Up @@ -73,6 +38,28 @@ class VulcanoCLI < Thor
desc: 'Allow remote scans with self-signed certificates (WinRM).'
end

desc 'json PATH', 'read all tests in PATH and generate a JSON-profile'
target_options
option :id, type: :string,
desc: 'Attach a profile ID to all test results'
option :output, aliases: :o, type: :string,
desc: 'Save the created profile to a path'
def json(path)
profile = Vulcano::Profile.from_path(path, options)
dst = options[:output].to_s
if dst.empty?
puts JSON.pretty_generate(profile.params)
else
if File.exist? dst
puts "----> updating #{dst}"
else
puts "----> creating #{dst}"
end
fdst = File.expand_path(dst)
File.write(fdst, JSON.dump(profile.params))
end
end

desc 'exec PATHS', 'run all test files'
option :id, type: :string,
desc: 'Attach a profile ID to all test results'
Expand Down
10 changes: 5 additions & 5 deletions lib/resources/postgres_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def describe(query, db = [], &block)
end
end
else
lines = cmd.stdout.
# remove the whole header (i.e. up to the first ^-----+------+------$)
sub(/(.*\n)+([-]+[+])*[-]+\n/, '').
# remove the tail
sub(/\n[^\n]*\n\n$/, '')
# remove the whole header (i.e. up to the first ^-----+------+------$)
# remove the tail
lines = cmd.stdout
.sub(/(.*\n)+([-]+[+])*[-]+\n/, '')
.sub(/\n[^\n]*\n\n$/, '')
l = Lines.new(lines.strip, "PostgreSQL query: #{query}")
RSpec.__send__('describe', l, &block)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/find_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def find_files(path, opts = {})
exit_status = result.exit_status

return [nil, exit_status] unless exit_status == 0
files = result.stdout.split("\n").
map(&:strip).
find_all { |x| !x.empty? }
files = result.stdout.split("\n")
.map(&:strip)
.find_all { |x| !x.empty? }
[files, exit_status]
end
end
8 changes: 0 additions & 8 deletions lib/verify.rb

This file was deleted.

69 changes: 0 additions & 69 deletions lib/verify/dummy.rb

This file was deleted.

80 changes: 0 additions & 80 deletions lib/verify/metadata.rb

This file was deleted.

123 changes: 0 additions & 123 deletions lib/verify/profiles.rb

This file was deleted.

Loading