-
Notifications
You must be signed in to change notification settings - Fork 103
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
Only Cleanup!! v3 #295
Only Cleanup!! v3 #295
Conversation
@loginURL = loginURL | ||
@name = name | ||
@baseURL = baseURL | ||
@loginURL = loginURL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use snake_case for variable names.
@baseURL = baseURL | ||
@loginURL = loginURL | ||
@name = name | ||
@baseURL = baseURL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use snake_case for variable names.
@baseURL = baseURL | ||
@headers = {} | ||
@name = name | ||
@baseURL = baseURL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use snake_case for variable names.
@@ -4,22 +4,21 @@ module Nexpose | |||
module WebCredentials | |||
|
|||
module WebAppAuthType | |||
HTML_FORM = 'htmlform' # Represent HTML form credentials. | |||
HTML_FORM = 'htmlform' # Represent HTML form credentials. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
ALL_INSTANCES_IN_A_SPECIFIC_SITE = 'All Instances in a Specific Site' | ||
ALL_INSTANCES = 'All Instances' | ||
ALL_INSTANCES_ON_A_SPECIFIC_ASSET = 'All Instances on a Specific Asset' | ||
ALL_INSTANCES_IN_A_SPECIFIC_SITE = 'All Instances in a Specific Site' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
DELETED = 'Deleted' | ||
APPROVED = 'Approved' | ||
REJECTED = 'Rejected' | ||
DELETED = 'Deleted' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
REJECTED = 'Rejected' | ||
DELETED = 'Deleted' | ||
APPROVED = 'Approved' | ||
REJECTED = 'Rejected' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
APPROVED = 'Approved' | ||
REJECTED = 'Rejected' | ||
DELETED = 'Deleted' | ||
APPROVED = 'Approved' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
Nexpose::VulnException::Status.const_get(name).to_s.downcase==status.downcase || status.to_sym.downcase == name.downcase | ||
end | ||
def status_string_to_constant(status) | ||
Nexpose::VulnException::Status.constants.find do |name| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer detect over find.
valid_status << Nexpose::VulnException::Status.constants.map(&:to_s).map(&:downcase) | ||
valid_status.flatten.map(&:downcase).include?(status.downcase) | ||
end | ||
def is_valid_vuln_exception_status?(status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename is_valid_vuln_exception_status? to valid_vuln_exception_status?.
end | ||
end | ||
|
||
unless @restricted_report_sections.empty? | ||
sections = xml.add_element('RestrictedReportSections') | ||
@restricted_report_sections.each do |section| | ||
sections.add_element('RestrictedReportSection', {'name' => section}) | ||
sections.add_element('RestrictedReportSection', { 'name' => section }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
end | ||
end | ||
|
||
unless @restricted_report_formats.empty? | ||
formats = xml.add_element('RestrictedReportFormats') | ||
@restricted_report_formats.each do |format| | ||
formats.add_element('RestrictedReportFormat', {'name' => format}) | ||
formats.add_element('RestrictedReportFormat', { 'name' => format }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
end | ||
end | ||
|
||
unless @licensed_modules.empty? | ||
licensed_modules = xml.add_element('LicensedModules') | ||
@licensed_modules.each do |licensed_module| | ||
licensed_modules.add_element('LicensedModule', {'name' => licensed_module}) | ||
licensed_modules.add_element('LicensedModule', { 'name' => licensed_module }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
end | ||
end | ||
|
||
unless @global_scan_templates.empty? | ||
templates = xml.add_element('GlobalScanTemplates') | ||
@global_scan_templates.each do |template| | ||
templates.add_element('GlobalScanTemplate', {'name' => template}) | ||
templates.add_element('GlobalScanTemplate', { 'name' => template }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
end | ||
end | ||
|
||
unless @global_scan_engines.empty? | ||
engines = xml.add_element('GlobalScanEngines') | ||
@global_scan_engines.each do |engine| | ||
engines.add_element('GlobalScanEngine', {'name' => engine}) | ||
engines.add_element('GlobalScanEngine', { 'name' => engine }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
xml.add_attributes({'payment-application' => @payment_application, 'payment-version' => @payment_version, 'petroleum' => @petroleum, 'retail' => @retail, 'telecommunication' => @telecommunication, 'travel' => @travel}) | ||
xml.add_attributes({ 'acquirer-relationship' => @acquirer_relationship, 'agent-relationship' => @agent_relationship, | ||
'ecommerce' => @ecommerce, 'grocery' => @grocery, 'mail-order' => @mail_order }) | ||
xml.add_attributes({ 'payment-application' => @payment_application, 'payment-version' => @payment_version, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
@@ -284,20 +283,22 @@ def self.parse(xml) | |||
def as_xml | |||
xml = super | |||
xml.name = 'Merchant' | |||
xml.add_attributes({'acquirer-relationship' => @acquirer_relationship, 'agent-relationship' => @agent_relationship, 'ecommerce' => @ecommerce, 'grocery' => @grocery, 'mail-order' => @mail_order}) | |||
xml.add_attributes({'payment-application' => @payment_application, 'payment-version' => @payment_version, 'petroleum' => @petroleum, 'retail' => @retail, 'telecommunication' => @telecommunication, 'travel' => @travel}) | |||
xml.add_attributes({ 'acquirer-relationship' => @acquirer_relationship, 'agent-relationship' => @agent_relationship, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
end | ||
|
||
def as_xml | ||
xml = REXML::Element.new('Organization') | ||
xml.add_attributes({'company' => @company, 'email-address' => @email, 'first-name' => @first_name, 'last-name' => @last_name, 'phone-number' => @phone, 'title' => @title, 'url' => @url}) | ||
xml.add_attributes({ 'company' => @company, 'email-address' => @email, 'first-name' => @first_name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
address.country = xml.attributes['country'] | ||
end | ||
end | ||
|
||
def as_xml | ||
xml = REXML::Element.new('Address') | ||
xml.add_attributes({'city' => @city, 'country' => @country, 'line1' => @line1, 'line2' => @line2, 'state' => @state, 'zip' => @zip}) | ||
xml.add_attributes({ 'city' => @city, 'country' => @country, 'line1' => @line1, 'line2' => @line2, 'state' => @state, 'zip' => @zip }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
@@ -118,7 +116,8 @@ def delete(connection) | |||
|
|||
def as_xml | |||
xml = REXML::Element.new('SiloConfig') | |||
xml.add_attributes({'description' => @description, 'name' => @name, 'id' => @id, 'silo-profile-id' => @profile_id, 'max-assets' => @max_assets, 'max-users' => @max_users, 'max-hosted-assets' => @max_hosted_assets}) | |||
xml.add_attributes({ 'description' => @description, 'name' => @name, 'id' => @id, 'silo-profile-id' => @profile_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
@@ -54,8 +53,8 @@ def update_engine(engine_id) | |||
# each active scan on the engine. | |||
# | |||
def engine_activity(engine_id) | |||
xml = make_xml('EngineActivityRequest', {'engine-id' => engine_id}) | |||
r = execute(xml) | |||
xml = make_xml('EngineActivityRequest', { 'engine-id' => engine_id }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
@@ -10,8 +10,7 @@ class Connection | |||
# @return [Boolean] true if engine successfully deleted. | |||
# | |||
def delete_engine(engine_id, scope = 'silo') | |||
xml = make_xml('EngineDeleteRequest', | |||
{'engine-id' => engine_id, 'scope' => scope}) | |||
xml = make_xml('EngineDeleteRequest', { 'engine-id' => engine_id, 'scope' => scope }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
ON = 'poweredOn' | ||
OFF = 'poweredOff' | ||
ON = 'poweredOn' | ||
OFF = 'poweredOff' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
end | ||
|
||
module Value | ||
module PowerState | ||
ON = 'poweredOn' | ||
OFF = 'poweredOff' | ||
ON = 'poweredOn' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
@@ -45,7 +45,7 @@ module Field | |||
INSTANCE_TYPE = 'INSTANCE_TYPE' | |||
|
|||
# Valid Operators: IN, NOT_IN | |||
REGION ='REGION' | |||
REGION = 'REGION' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
@@ -10,11 +10,11 @@ class Connection | |||
# @return [Boolean] Whether group deletion succeeded. | |||
# | |||
def delete_asset_group(id) | |||
r = execute(make_xml('AssetGroupDeleteRequest', {'group-id' => id})) | |||
r = execute(make_xml('AssetGroupDeleteRequest', { 'group-id' => id })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
lib/nexpose/global_blackout.rb
Outdated
@@ -18,8 +18,7 @@ def save(nsc) | |||
|
|||
def to_h | |||
{ | |||
blackouts: | |||
(@blackout || []).map { |blackout| blackout.to_h } | |||
blackouts: (@blackout || []).map { |blackout| blackout.to_h } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass &:to_h as an argument to map instead of a block.
# TODO: A problem in Nexpose causes these values to not be constant. | ||
METASPLOIT = 'type:"exploit_source_type", name:"2"' | ||
DATABASE = 'type:"exploit_source_type", name:"1"' | ||
DATABASE = 'type:"exploit_source_type", name:"1"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
end | ||
|
||
# Constants for filtering on vulnerability exposure. | ||
module VulnerabilityExposure | ||
MALWARE = 'type:"malware_type", name:"malwarekit"' | ||
MALWARE = 'type:"malware_type", name:"malwarekit"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
UNKNOWN = '0' | ||
VIRTUAL = '1' | ||
UNKNOWN = '0' | ||
VIRTUAL = '1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
@@ -54,8 +53,8 @@ def update_engine(engine_id) | |||
# each active scan on the engine. | |||
# | |||
def engine_activity(engine_id) | |||
xml = make_xml('EngineActivityRequest', {'engine-id' => engine_id}) | |||
r = execute(xml) | |||
xml = make_xml('EngineActivityRequest', { 'engine-id' => engine_id }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
@@ -10,8 +10,7 @@ class Connection | |||
# @return [Boolean] true if engine successfully deleted. | |||
# | |||
def delete_engine(engine_id, scope = 'silo') | |||
xml = make_xml('EngineDeleteRequest', | |||
{'engine-id' => engine_id, 'scope' => scope}) | |||
xml = make_xml('EngineDeleteRequest', { 'engine-id' => engine_id, 'scope' => scope }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
ON = 'poweredOn' | ||
OFF = 'poweredOff' | ||
ON = 'poweredOn' | ||
OFF = 'poweredOff' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
end | ||
|
||
module Value | ||
module PowerState | ||
ON = 'poweredOn' | ||
OFF = 'poweredOff' | ||
ON = 'poweredOn' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
@@ -45,7 +45,7 @@ module Field | |||
INSTANCE_TYPE = 'INSTANCE_TYPE' | |||
|
|||
# Valid Operators: IN, NOT_IN | |||
REGION ='REGION' | |||
REGION = 'REGION' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
@@ -10,11 +10,11 @@ class Connection | |||
# @return [Boolean] Whether group deletion succeeded. | |||
# | |||
def delete_asset_group(id) | |||
r = execute(make_xml('AssetGroupDeleteRequest', {'group-id' => id})) | |||
r = execute(make_xml('AssetGroupDeleteRequest', { 'group-id' => id })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant curly braces around a hash parameter.
lib/nexpose/global_blackout.rb
Outdated
@@ -18,8 +18,7 @@ def save(nsc) | |||
|
|||
def to_h | |||
{ | |||
blackouts: | |||
(@blackout || []).map { |blackout| blackout.to_h } | |||
blackouts: (@blackout || []).map { |blackout| blackout.to_h } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass &:to_h as an argument to map instead of a block.
# TODO: A problem in Nexpose causes these values to not be constant. | ||
METASPLOIT = 'type:"exploit_source_type", name:"2"' | ||
DATABASE = 'type:"exploit_source_type", name:"1"' | ||
DATABASE = 'type:"exploit_source_type", name:"1"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
end | ||
|
||
# Constants for filtering on vulnerability exposure. | ||
module VulnerabilityExposure | ||
MALWARE = 'type:"malware_type", name:"malwarekit"' | ||
MALWARE = 'type:"malware_type", name:"malwarekit"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
UNKNOWN = '0' | ||
VIRTUAL = '1' | ||
UNKNOWN = '0' | ||
VIRTUAL = '1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeze mutable objects assigned to constants.
end | ||
|
||
def integration_status_proc(nexpose_connection:, scan_id:, status:) | ||
Proc.new { nexpose_connection.scan_status(scan_id).downcase == status.downcase } | ||
proc { nexpose_connection.scan_status(scan_id).downcase == status.downcase } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use casecmp instead of downcase ==.
end | ||
def status_string_to_constant(status) | ||
Nexpose::VulnException::Status.constants.find do |name| | ||
Nexpose::VulnException::Status.const_get(name).to_s.downcase == status.downcase || status.to_sym.downcase == name.downcase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use casecmp instead of downcase ==.
This time for real, only cleanup/formatting fixes.
Link to
%Q{
converting to%(
info