nexpose-client icon indicating copy to clipboard operation
nexpose-client copied to clipboard

Find sites that have not been scanned?

Open nbirnel opened this issue 8 years ago • 2 comments

Expected Behavior

I would like to be able to determine which sites have not been scanned. While the web UI shows "not scanned" for those sites, a Nexpose::SiteSummary has nothing I can see to indicate last scans. The closest I have been able to find is the idea of listing all paused and past scans, finding their sites, and removing that from the whole list of sites. Am I missing something, or is this just not supported?

Context

I have quite a few unscanned sites that I would like to delete - too many to want to do manually.

nbirnel avatar Mar 16 '17 23:03 nbirnel

Unfortunately there isn't a native API call for this, but you can work around that by using the gem to pull the same site listing details that the UI does:

sites = Nexpose::DataTable._get_dyn_table(nsc, '/data/site/dyntable?tableID=SiteSynopsis')
unscanned = sites.find_all { |site| site['Last Scan'] == '-1' }

The Last Scan field returned for the data table is a timestamp in long format (like unix time) as a string, and -1 is the placeholder value for sites that don't have a last scan date.

Note that I'm using a "private" method here, which ideally should only be consumed by the gem itself, but it is accessible to any scripts using the gem.

gschneider-r7 avatar Mar 16 '17 23:03 gschneider-r7

Almost a year too late but if still interested I think

nsc.last_scan(site.id) == nil

should also indicate a site never scanned.

peterjmcg avatar Feb 06 '18 20:02 peterjmcg