I’m trying to figure out how to search for assets via the insightVM Cloud API v4, but haven’t been having much luck.
When trying to search for assets by hostname, I receive a list of 4 seemingly random assets in response, and I don’t know why - the hostnames are different, the IP addresses are all different - the query doesn’t seem to be related to the assets being returned.
Here’s my query, where my.asset.ca
is the asset that I want to search for:
{
'asset': "asset.name = 'my.asset.ca'"
}
The 4 search results seem to be unrelated to the query, the page size is 10, and it looks like 50,000 results are returned - I’m guessing I’m receiving 4 results rather than a minimum of 10 because I haven’t implemented pagination, or, something.
In Exposure Analytics, my query returns a single asset - the correct asset.
Maybe the query is malformed, or I don’t understand the calling paradigm?
Here’s the Python script that I’m using to query the API:
import requests
import json
url = 'https://ca.api.insight.rapid7.com/vm/v4/integration/assets/'
api_key = ''
headers = {
'X-Api-Key': api_key,
}
params = {
'asset': "asset.name = 'my.asset.ca'"
}
response = requests.post(url, headers=headers, params=params, verify=False)
response.raise_for_status()
reply = response.json()
print(json.dumps(reply, indent=4, sort_keys=True))
Maybe our TAM could help out here?