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

Blackout always shows enabled = true #264

Closed
peterjmcg opened this issue Mar 28, 2017 · 8 comments
Closed

Blackout always shows enabled = true #264

peterjmcg opened this issue Mar 28, 2017 · 8 comments
Labels

Comments

@peterjmcg
Copy link

When reading the 'enabled' field from Blackout it always returns 'true'. Possible solution is to add hash[:enabled] to new(hash... in blackout.rb / self.from_hash

new(hash[:start_date], hash[:enabled], hash[:blackout_duration], type, interval)

Code was tested with client version 5.3.0 on Windows 10, ruby 2.2.6p396 (2016-11-15 revision 56800) [x64-mingw32], Nexpose release 6.4.27, using :

CSV.open("Blackouts.csv", "wb") do |csv|
csv << ["Site", "Blackout_start", "Duration", "Type", "Interval", "Enabled"]
end

Get blackouts

sites = @nsc.list_sites || []

@BlackoutExists = FALSE

sites.each do |site|

	site_name = Nexpose::Site.load(@nsc, site.id).name
	site_blackouts = Nexpose::Site.load(@nsc, site.id).blackouts
	if site_blackouts.size > 0
	
		@BlackoutExists = TRUE
		site_blackouts.each do |bo|

			CSV.open("Blackouts.csv", "a+") do |csv|
				csv << ["#{site_name}" , "#{Time.at(bo.blackout_start.to_i/1000).localtime.strftime("%c")}" , "#{Time.at(bo.blackout_duration).utc.strftime("%H:%M:%S")}", "#{bo.blackout_type}", "#{bo.blackout_interval}",  "#{bo.enabled.to_s=='true'}" ]
			end
		end	
	end	

end

if !@BlackoutExists
puts("No site blackouts created")
end

@sgreen-r7
Copy link
Contributor

@peterjmcg first off, thanks for reporting this. Darren was able to get a fix up, and it's pushed into master.

Do you have the ability to the master version of our gem, and verify our update fixes your issue? I can give you a step by step if you have never done it before. I would just like to verify the fix works for you before releasing it publicly in a new gem version. If it's an inconvenience for you, that's fine just let us know either way and we'll go from there.

Thank you again for reporting, and for the example code!

@peterjmcg
Copy link
Author

peterjmcg commented Mar 28, 2017 via email

@sgreen-r7
Copy link
Contributor

@peterjmcg sounds good, are you using a Gemfile per chance, or just a standard gem install nexpose from the command line?

@peterjmcg
Copy link
Author

peterjmcg commented Mar 28, 2017 via email

@sgreen-r7
Copy link
Contributor

sgreen-r7 commented Mar 28, 2017

@peterjmcg Okay, what you'll want to do, are the following steps.

  • clone the gem source.
  • cd into the directory the clone created
  • build the gem locally
  • install the gem you just built.
  • also after you verify this works, you'll want to uninstall this version of the gem
git clone git@github.com:rapid7/nexpose-client.git

cd nexpose-client

gem build nexpose.gemspec

gem install nexpose-5.3.2.gem

Then go ahead and run your tests, and let us know if that fixes the issue for you. We can push the gem live very quickly after you can confirm that it's fixed; so feel free to uninstall the gem you just built locally with the following:

gem uninstall nexpose-5.3.2

Thanks again, and let us know if you have any issues (my only unknown is if building a gem locally on windows works exactly the same and linux/osx). If you get stuck don't worry about it, just let us know and we'll go from there.

@peterjmcg
Copy link
Author

peterjmcg commented Mar 28, 2017 via email

@sgreen-r7
Copy link
Contributor

Sounds good @peterjmcg thanks for quick responses. I'll go ahead and make this public, and i'll update this thread and close it out once we're live.

@sgreen-r7
Copy link
Contributor

Thanks again @peterjmcg -- it's live!
https://github.com/rapid7/nexpose-client/releases/tag/v5.3.2

Let us know if you run into any other issues in the future, or feel free to ask questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants