Closed noraj closed 4 years ago
It must be because facets
option is taking a string as an argument instead of a dictionary:
eg
const searchOpts = {
facets: 'port:100,country:100',
// minify: false,
};
instead of:
const searchOpts = {
facets: {
'port': 100,
'country': 100
}
// minify: false,
};
or
const searchOpts = {
facets: {
port: 100,
country: 100
}
// minify: false,
};
@jesusprubio What do you think about it?
- const opts = { facets: FACETS };
+ const opts = { facets: JSON.stringify(FACETS).replace(/["{}]/g, '') };
Thanks for the report. This is not an error, it respects the API expected format for the parameters.
A comma-separated list of properties to get summary information on. Property names can also be in the format of "property:count", where "count" is the number of facets that will be returned for a property (i.e. "country:100" to get the top 100 countries for a search query)
I think it has sense since the HTTP API expects a JSON, which is the same data structure we use in Node.js. Moreover, the count
part is optional, so we should accept null
or undefined
as a valid value, which is a bit strange. We could use an array instead, but it would be still stranger if you think in what we should allow as valid elements.
Describe the bug
count()
should return an object with{ matches: [], factes: {}, total: int }
, for example:But currently it is only returning matches and total but not facets.
See the official documentation https://developer.shodan.io/api
To Reproduce
Ouput:
Expected behavior
Returns
facets
.Environment