Skip to content

Commit

Permalink
Restructure project and add new spec testing approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
abrooke committed Sep 5, 2016
1 parent 4130508 commit 0fbb7a4
Show file tree
Hide file tree
Showing 157 changed files with 949 additions and 347 deletions.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified Gemfile
100644 → 100755
Empty file.
21 changes: 4 additions & 17 deletions Gemfile.lock
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ PATH
remote: .
specs:
zaws (0.0.6)
excon
json (~> 1.5.0)
mixlib-shellout (~> 1.1.0)
netaddr (~> 1.5.0)
Expand Down Expand Up @@ -35,21 +34,15 @@ GEM
multi_test (>= 0.1.1)
diff-lcs (1.2.5)
docile (1.1.5)
excon (0.49.0)
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
gherkin (2.12.2)
multi_json (~> 1.3)
gherkin (2.12.2-x86-mingw32)
multi_json (~> 1.3)
json (1.5.5)
mime-types (2.3)
mixlib-shellout (1.1.0)
mixlib-shellout (1.1.0-x86-mingw32)
win32-process (~> 0.6.5)
multi_json (1.7.9)
multi_test (0.1.1)
netaddr (1.5.1)
netaddr (1.5.0)
rake (10.1.0)
rest-client (1.6.7)
mime-types (>= 1.16)
Expand All @@ -70,18 +63,9 @@ GEM
tins (~> 1.0)
thor (0.18.1)
tins (1.3.0)
win32-api (1.5.3-x86-mingw32)
win32-process (0.6.6)
windows-pr (>= 1.2.2)
windows-api (0.4.4)
win32-api (>= 1.4.5)
windows-pr (1.2.4)
win32-api (>= 1.4.5)
windows-api (>= 0.4.0)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
aruba (~> 0.5.4)
Expand All @@ -92,3 +76,6 @@ DEPENDENCIES
rake
rspec (~> 2.14.1)
zaws!

BUNDLED WITH
1.10.6
11 changes: 3 additions & 8 deletions Gemfile.lock.windows
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PATH
remote: .
specs:
zaws (0.0.6)
excon
json (~> 1.5.0)
mixlib-shellout (~> 1.1.0)
netaddr (~> 1.5.0)
Expand Down Expand Up @@ -32,11 +33,9 @@ GEM
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.1)
debase (0.2.1)
debase-ruby_core_source
debase-ruby_core_source (0.8.2)
diff-lcs (1.2.5)
docile (1.1.5)
excon (0.49.0)
ffi (1.9.3)
ffi (1.9.3-x86-mingw32)
gherkin (2.12.2)
Expand All @@ -50,7 +49,7 @@ GEM
win32-process (~> 0.6.5)
multi_json (1.7.9)
multi_test (0.1.1)
netaddr (1.5.0)
netaddr (1.5.1)
rake (10.1.0)
rest-client (1.6.7)
mime-types (>= 1.16)
Expand All @@ -62,8 +61,6 @@ GEM
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.6)
ruby-debug-ide (0.6.0)
rake (>= 0.8.1)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
Expand Down Expand Up @@ -92,8 +89,6 @@ DEPENDENCIES
bundler
coveralls
cucumber (~> 1.3.14)
debase
rake
rspec (~> 2.14.1)
ruby-debug-ide
zaws!
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified Rakefile
100644 → 100755
Empty file.
Empty file modified feature/cloud_trail/cloud_trail.feature
100644 → 100755
Empty file.
Empty file modified feature/compute/assoc_security_group.feature
100644 → 100755
Empty file.
Empty file modified feature/compute/compute.feature
100644 → 100755
Empty file.
Empty file modified feature/compute/secondary_ip.feature
100644 → 100755
Empty file.
Empty file modified feature/compute/view.feature
100644 → 100755
Empty file.
Empty file modified feature/compute/view_images.feature
100644 → 100755
Empty file.
Empty file modified feature/elasticip/elasticip.feature
100644 → 100755
Empty file.
Empty file modified feature/elasticip/view.feature
100644 → 100755
Empty file.
Empty file modified feature/hosted_zone/view.feature
100644 → 100755
Empty file.
Empty file modified feature/hosted_zone/view_record.feature
100644 → 100755
Empty file.
Empty file modified feature/load_balancer/instance_registration.feature
100644 → 100755
Empty file.
Empty file modified feature/load_balancer/listener.feature
100644 → 100755
Empty file.
Empty file modified feature/load_balancer/load_balancer.feature
100644 → 100755
Empty file.
Empty file modified feature/load_balancer/view.feature
100644 → 100755
Empty file.
Empty file modified feature/route_table/assoc_subnet.feature
100644 → 100755
Empty file.
Empty file modified feature/route_table/route_propagation.feature
100644 → 100755
Empty file.
Empty file modified feature/route_table/route_table.feature
100644 → 100755
Empty file.
Empty file modified feature/route_table/route_to_gateway.feature
100644 → 100755
Empty file.
Empty file modified feature/route_table/route_to_instance.feature
100644 → 100755
Empty file.
Empty file modified feature/route_table/view.feature
100644 → 100755
Empty file.
Empty file modified feature/s3/bucket.feature
100644 → 100755
Empty file.
Empty file modified feature/security_group/ingress_cidr.feature
100644 → 100755
Empty file.
Empty file modified feature/security_group/ingress_group.feature
100644 → 100755
Empty file.
Empty file modified feature/security_group/security_group.feature
100644 → 100755
Empty file.
Empty file modified feature/security_group/view.feature
100644 → 100755
Empty file.
Empty file modified feature/step_definitions/gzip_steps.rb
100644 → 100755
Empty file.
Empty file modified feature/subnet/subnet.feature
100644 → 100755
Empty file.
Empty file modified feature/subnet/view.feature
100644 → 100755
Empty file.
Empty file modified feature/support/env.rb
100644 → 100755
Empty file.
Empty file modified lib/zaws/command/bucket.rb
100644 → 100755
Empty file.
Empty file modified lib/zaws/command/cloud_trail.rb
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion lib/zaws/command/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Compute < Thor
def initialize(*args)
super
shellout=ZAWS::Helper::Shell.new
awscli = ZAWS::AWSCLI.new(shellout)
awscli = ZAWS::AWSCLI.new(shellout,false)
@aws = ZAWS::AWS.new(shellout, awscli)
@out = $stdout
@print_exit_code = false
Expand Down
Empty file modified lib/zaws/command/config.rb
100644 → 100755
Empty file.
Empty file modified lib/zaws/command/elasticip.rb
100644 → 100755
Empty file.
Empty file modified lib/zaws/command/hosted_zone.rb
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion lib/zaws/command/iam.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class IAM < Thor
def initialize(*args)
super
shellout=ZAWS::Helper::Shell.new
awscli = ZAWS::AWSCLI.new(shellout)
awscli = ZAWS::AWSCLI.new(shellout,false)
@aws = ZAWS::AWS.new(shellout,awscli)
@out = $stdout
@print_exit_code = false
Expand Down
Empty file modified lib/zaws/command/load_balancer.rb
100644 → 100755
Empty file.
16 changes: 9 additions & 7 deletions lib/zaws/command/nessus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module ZAWS
module Command
class Nessus < Thor
class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
class_option :home, :type => :string, :default => ENV['HOME'], :desc => 'Home directory location for credentials file'
class_option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"

attr_accessor :nessus
attr_accessor :out
Expand All @@ -16,21 +18,21 @@ def initialize(*args)
@nessus = ZAWS::Controllers::Nessus.new(shellout, nessusapi)
@out = $stdout
@print_exit_code = false
@params= {
'home' => options[:home]
}
end

desc "view_scanners", "View scanners."
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
option :home, :type => :string, :default => ENV['HOME'], :desc => 'Home directory location for credentials file'
def view_scanners
@nessus.scanners.view(options[:home], @out, (options[:verbose] ? @out : nil))
@out.puts(@nessus.scanners.view(@params));
end

desc "view_agents", "View scanners."
option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
option :home, :type => :string, :default => ENV['HOME'], :desc => 'Home directory location for credentials file'
desc "view_agents", "View agents."
option :scanner, :type => :string, :default => '1', :desc => 'scanner id'
def view_agents
@nessus.agents.view(options[:home],options[:scanner], @out, (options[:verbose] ? @out : nil))
@params['scanner']=options[:scanner]
@out.puts(@nessus.agents.view(params));
end
end
end
Expand Down
Empty file modified lib/zaws/command/route_table.rb
100644 → 100755
Empty file.
Empty file modified lib/zaws/command/security_group.rb
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion lib/zaws/command/subnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Subnet < Thor
def initialize(*args)
super
shellout=ZAWS::Helper::Shell.new
awscli = ZAWS::AWSCLI.new(shellout)
awscli = ZAWS::AWSCLI.new(shellout,false)
@aws = ZAWS::AWS.new(shellout, awscli)
@out = $stdout
@print_exit_code = false
Expand Down
2 changes: 1 addition & 1 deletion lib/zaws/command/vpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VPC < Thor
def initialize(*args)
super
shellout=ZAWS::Helper::Shell.new
awscli = ZAWS::AWSCLI.new(shellout)
awscli = ZAWS::AWSCLI.new(shellout,false)
@aws = ZAWS::AWS.new(shellout, awscli)
@out = $stdout
@print_exit_code = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ module ZAWS
class AWSCLI
attr_accessor :home

def initialize(shellout)
def initialize(shellout,keep_filestore_empty=false)
@shellout=shellout
@keep_filestore_empty=keep_filestore_empty
end

def filestore
@filestore ||= ZAWS::Repository::Filestore.new()
@filestore ||= ZAWS::Repository::Filestore.new(@keep_filestore_empty)
@filestore.timeout = 600
return @filestore if @keep_filestore_empty
@home ||= ENV['HOME']
@filestore.location="#{@home}/.awsdata"
unless File.directory?(@filestore.location)
FileUtils.mkdir_p(@filestore.location)
end
@filestore.timeout = 600
return @filestore
end

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def execute(region, view, filters={}, textout=nil, verbose=nil,profile=nil)
comline = comline + " --profile #{profile}" if profile
comline = comline + " --filter" if filters.length > 0
filters.each do |key, item|
comline = comline + " 'Name=#{key},Values=#{item}'"
comline = comline + " \"Name=#{key},Values=#{item}\""
end
unless @awscli.data_ec2.instance.load_cached(comline, verbose)
@awscli.data_ec2.instance.load(comline, @shellout.cli(comline, verbose), verbose)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def subnet
end

def instance
@_Instance ||= (ZAWS::AWSCLI::Data::EC2::Instance.new(@shellout, self))
@_Instance ||= (ZAWS::AWSCLI::Data::EC2::Instance.new(@shellout, self.filestore))
return @_Instance
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class Data
class EC2
class Instance

def initialize(shellout, ec2)
def initialize(shellout, filestore)
@shellout=shellout
@ec2=ec2
@filestore=filestore
@instance_hash=nil
end

Expand All @@ -15,7 +15,7 @@ def validJSON
end

def load_cached(command,verbose)
fileinstances = @ec2.filestore.retrieve("instance",command)
fileinstances = @filestore.retrieve("instance",command)
if fileinstances.nil?
return false
else
Expand All @@ -31,7 +31,7 @@ def load(command, data, verbose,cache=true)
begin
@instance_hash =JSON.parse(data)
create_lookup_hashes()
@ec2.filestore.store("instance",@instance_raw_data,Time.now + @ec2.filestore.timeout,command) if cache
@filestore.store("instance",@instance_raw_data,Time.now + @filestore.timeout,command) if cache
rescue JSON::ParserError => e
end
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions lib/zaws/external/awscli/generators/api/aws/aws.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module ZAWS
class External
class AWSCLI
class Generators
class API
class AWS
class AWS
def initialize
@subcommand=nil
@output=nil
@region=nil
self
end

def with_output(output)
@output=output
self
end

def with_region(region)
@region=region
self
end

def with_subcommand(subcommand)
@subcommand=subcommand
self
end

def get_command
command = "aws "
command = "#{command}--output #{@output} " if @output
command = "#{command}--region #{@region} " if @region
command = "#{command}#{@subcommand.get_command}" if @subcommand
return command.strip
end
end
end
end
end
end
end
end

38 changes: 38 additions & 0 deletions lib/zaws/external/awscli/generators/api/ec2/create_tags.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module ZAWS
class External
class AWSCLI
class Generators
class API
class EC2
class CreateTags
def initialize
@resource
@tags
self
end

def resource(resource)
@resource=resource
self
end

def tags(tags)
@tags=tags.get_tags_array
self
end

def get_command
command = "ec2 create-tags"
command = "#{command} --resources #{@resource}" if @resource
command = "#{command} --tags \"Key=#{@tags[0]['Key']},Value=#{@tags[0]['Value']}\" " if @tags
return command
end

end
end
end
end
end
end
end

31 changes: 31 additions & 0 deletions lib/zaws/external/awscli/generators/api/ec2/describe_instances.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module ZAWS
class External
class AWSCLI
class Generators
class API
class EC2
class DescribeInstances
def initialize
@filter=nil
self
end

def filter(filter)
@filter=filter
self
end

def get_command
command = "ec2 describe-instances"
command = "#{command} #{@filter.get_command}" if @filter
return command
end

end
end
end
end
end
end
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module ZAWS
class External
class AWSCLI
class Generators
class API
class EC2
class DescribeSecurityGroups
def initialize
@filter=nil
self
end

def filter(filter)
@filter=filter
self
end

def get_command
command = "ec2 describe-security-groups"
command = "#{command} #{@filter.get_command}" if @filter
return command
end

end
end
end
end
end
end
end

Loading

0 comments on commit 0fbb7a4

Please sign in to comment.