-
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
Site api blackouts #150
Site api blackouts #150
Changes from 1 commit
dc4d97e
a2e7a3d
4526edb
0ff1790
f16e9d8
aa56ca3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,15 +305,15 @@ class Blackout < APIObject | |
# Whether or not this blackout is enabled. | ||
attr_accessor :enabled | ||
# Valid schedule types: daily, hourly, monthly-date, monthly-day, weekly. | ||
attr_accessor :type | ||
attr_accessor :blackout_type | ||
# The repeat interval based upon type. | ||
attr_accessor :interval | ||
attr_accessor :blackout_interval | ||
# The earliest date to generate the report on (in ISO 8601 format). | ||
attr_accessor :start | ||
attr_accessor :blackout_start | ||
# The amount of time, in minutes, a blackout period should last. | ||
attr_accessor :duration | ||
attr_accessor :blackout_duration | ||
# The timezone in which the blackout will start | ||
attr_accessor :timezone | ||
attr_accessor :blackout_timezone | ||
|
||
def initialize(start, enabled=true, duration, timezone, type, interval) | ||
@blackout_start = start | ||
|
@@ -326,7 +326,8 @@ def initialize(start, enabled=true, duration, timezone, type, interval) | |
|
||
def self.from_hash(hash) | ||
repeat_blackout_hash = hash[:repeat_blackout] | ||
blackout = new(hash[:start], hash[:duration], hash[:timezone], repeat_blackout_hash[:type], repeat_blackout_hash[:interval]) | ||
blackout = new(hash[:start_date], hash[:blackout_duration], hash[:timezone], repeat_blackout_hash[:type], repeat_blackout_hash[:interval]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [144/120] |
||
blackout | ||
end | ||
|
||
def to_h | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ def self.json_initializer(data) | |
def self.load(nsc) | ||
uri = '/api/2.1/silo_blackout/' | ||
resp = AJAX.get(nsc, uri, AJAX::CONTENT_TYPE::JSON) | ||
# puts resp | ||
hash = JSON.parse(resp, symbolize_names: true) | ||
blackout = self.json_initializer(hash).deserialize(hash) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant |
||
blackout.blackout = (hash[:blackouts] || []).map { |blackout| Nexpose::Blackout.from_hash(blackout) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shadowing outer local variable - |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -522,9 +522,9 @@ def self.load(nsc, id) | |
site.alerts = Alert.load_alerts(hash[:alerts]) | ||
site.tags = Tag.load_tags(hash[:tags]) | ||
site.web_credentials = hash[:web_credentials].map {|webCred| ( | ||
webCred[:service] == Nexpose::WebCredentials::WebAppAuthType::HTTP_HEADER ? | ||
Nexpose::WebCredentials::Headers.new(webCred[:name], webCred[:baseURL], webCred[:soft403Pattern], webCred[:id]).object_from_hash(nsc,webCred) : | ||
Nexpose::WebCredentials::HTMLForms.new(webCred[:name], webCred[:baseURL], webCred[:loginURL], webCred[:soft403Pattern], webCred[:id]).object_from_hash(nsc,webCred))} | ||
webCred[:service] == Nexpose::WebCredentials::WebAppAuthType::HTTP_HEADER ? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not a fan of this whole block here. Needs some better formatting for readability. I'll merge for now, but I want to take another look at this before we release 1.0. |
||
Nexpose::WebCredentials::Headers.new(webCred[:name], webCred[:baseURL], webCred[:soft403Pattern], webCred[:id]).object_from_hash(nsc,webCred) : | ||
Nexpose::WebCredentials::HTMLForms.new(webCred[:name], webCred[:baseURL], webCred[:loginURL], webCred[:soft403Pattern], webCred[:id]).object_from_hash(nsc,webCred))} | ||
|
||
site | ||
end | ||
|
@@ -556,20 +556,20 @@ def self.copy(connection, id) | |
# @return [Fixnum] Site ID assigned to this configuration, if successful. | ||
# | ||
def save(connection) | ||
new_site = @id == -1 | ||
new_site = @id == -1 | ||
|
||
if new_site | ||
resp = AJAX.post(connection, '/api/2.1/site_configurations/', to_json, AJAX::CONTENT_TYPE::JSON) | ||
@id = resp.to_i | ||
else | ||
resp = AJAX.put(connection, "/api/2.1/site_configurations/#{@id}", to_json, AJAX::CONTENT_TYPE::JSON) | ||
end | ||
if new_site | ||
resp = AJAX.post(connection, '/api/2.1/site_configurations/', to_json, AJAX::CONTENT_TYPE::JSON) | ||
@id = resp.to_i | ||
else | ||
resp = AJAX.put(connection, "/api/2.1/site_configurations/#{@id}", to_json, AJAX::CONTENT_TYPE::JSON) | ||
end | ||
|
||
# Retrieve the scan engine and shared credentials and add them to the site configuration | ||
site_config = Site.load(connection, @id) | ||
@engine_id = site_config.engine_id | ||
@shared_credentials = site_config.shared_credentials | ||
@alerts = site_config.alerts | ||
# Retrieve the scan engine and shared credentials and add them to the site configuration | ||
site_config = Site.load(connection, @id) | ||
@engine_id = site_config.engine_id | ||
@shared_credentials = site_config.shared_credentials | ||
@alerts = site_config.alerts | ||
|
||
@id | ||
end | ||
|
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.
Surrounding space missing in default value assignment.