Configuration changes

Pulled System.rb out to individual classes.
This commit is contained in:
thomashaw
2016-03-08 18:54:15 +00:00
parent 6a0107ee05
commit ddf8194397
16 changed files with 289 additions and 277 deletions

3
lib/objects/base_box.rb Normal file
View File

@@ -0,0 +1,3 @@
class Basebox
attr_accessor :name, :os, :distro, :vagrantbase, :url
end

24
lib/objects/network.rb Normal file
View File

@@ -0,0 +1,24 @@
class Network
attr_accessor :name, :range
def initialize(name="", range="")
@name = name
@range = range
end
def id
hash = @name + @range
return hash
# return string that connects everything to 1 massive string
end
def eql? other
# checks if name matches networks.xml from scenario.xml
other.kind_of?(self.class) && @name == other.name
end
def hash
@type.hash
end
end

22
lib/objects/service.rb Normal file
View File

@@ -0,0 +1,22 @@
class Service
attr_accessor :name, :type, :details, :puppets
def initialize(name="", type="", details="", puppets=[])
@name = name
@type = type
@details = details
@puppets = puppets
end
def eql? other
other.kind_of?(self.class) && @type == other.type
end
def hash
@type.hash
end
def id
return @type
end
end

28
lib/objects/system.rb Normal file
View File

@@ -0,0 +1,28 @@
class System
# can access from outside of class
attr_accessor :id, :os, :url,:basebox, :networks, :vulns, :services
#initalizes system variables
def initialize(id, os, basebox, url, vulns=[], networks=[], services=[])
@id = id
@os = os
@url = url
@basebox = basebox
@vulns = vulns
@networks = networks
@services = services
end
def is_valid_base
valid_base = Configuration.bases
valid_base.each do |b|
if @basebox == b.vagrantbase
@url = b.url
return true
end
end
return false
end
end

View File

@@ -3,11 +3,6 @@ require_relative('../constants.rb')
class Vulnerability
attr_accessor :type, :privilege, :access ,:puppets, :details, :ports, :name, :cve, :files, :scripts
def eql? other
# checks if type matches vulns.xml from scenario.xml
other.kind_of?(self.class) && @type == other.type
end
def initialize(type='', privilege='', access='', puppets=[], details='', ports=[], platform ='', name='', cve='', files=[], scripts=[])
@type = type
@privilege = privilege
@@ -22,6 +17,11 @@ class Vulnerability
@scripts = scripts
end
def eql? other
# checks if type matches vulns.xml from scenario.xml
other.kind_of?(self.class) && @type == other.type
end
def id
return @type + @privilege + @access
end