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

No method to save search criteria for a dynamic site? #317

Open
jdbristow opened this issue Feb 15, 2018 · 4 comments
Open

No method to save search criteria for a dynamic site? #317

jdbristow opened this issue Feb 15, 2018 · 4 comments

Comments

@jdbristow
Copy link

Documentation for Site#save indicates changes to discovery connection and asset filter must be made through an alternate method -- DiscoveryConnection#update_site -- but this method does not exist.

Site#save appears to be working correctly with a set discovery_config, but failing with any set search_criteria.

Am I missing something?

@gschneider-r7
Copy link
Contributor

It looks like it's supposed to use the search_criteria field which needs to be a Nexpose::Criteria object. The comment about using the DiscoveryConnection #update_site method is very outdated (in fact it was wrong originally... the original method was Site#save_dynamic_criteria).

Do you have example criteria you are saving that doesn't work?

@jdbristow
Copy link
Author

I've tried several permutations, mostly using IP_ADDRESS and ASSET (name). Here's one example:

criterion = Nexpose::Criterion.new(Nexpose::Search::Field::ASSET, Nexpose::Search::Operator::CONTAINS, "foo")
site.search_criteria = Nexpose::Criteria.new(criterion)

Regardless of the criteria I use, if I set site.search_criteria, the resulting POST to /api/2.1/site_configurations/ fails with a Nexpose::APIError

nsc.log indicates a NullPointerException:

java.lang.NullPointerException: null
        at com.rapid7.nexpose.nsc.api.legacy.v2.v2_0.APIEnums.getEnum(Unknown Source) ~[nsc.jar:na]
        at com.rapid7.nexpose.nsc.api.legacy.v2.v2_0.APIEnums.getEnum(Unknown Source) ~[nsc.jar:na]
        at com.rapid7.nexpose.nsc.api.legacy.v2.v2_0.assembler.SearchCriteriaResourceAssembler.toDiscoverySearchCriteria(Unknown Source) ~[nsc.jar:na]
        at com.rapid7.nexpose.nsc.api.legacy.v2.v2_1.assembler.SiteConfigurationResourceAssembler.toSiteConfig(Unknown Source) ~[nsc.jar:na]
        at com.rapid7.nexpose.nsc.api.legacy.v2.v2_1.controller.SiteConfigurationResourceController.createSiteConfiguration(Unknown Source) ~[nsc.jar:na]

@gschneider-r7
Copy link
Contributor

The error is not that helpful of course, but it seems like you may be using invalid criteria. Which connection type is this for?

Aside from DHCP and Sonar connections most fields appear to be defined here: https://github.com/rapid7/nexpose-client/blob/master/lib/nexpose/discovery/filter.rb

@jdbristow
Copy link
Author

I'm using an AWS connection, so you are correct - i was using invalid criteria. That said, using the criteria identified for AWS connections in nexpose/discovery/filter.rb yields the same results. I've tried instance_name, instance_type, and instance_state to no avail.

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

No branches or pull requests

2 participants