I had several assets added via API that should not have been. I am now trying to write a groovy tag for assets that are not in the VM or WAS modules so I can remove them.
Is there any documentation on Groovy as used with Qualys?
Try this, create a new Groovy Script-let TAG say NOTINVM or something then for the code use:
// Skip testing on non-VM hosts. return (asset.getAssetType()!=Asset.AssetType.HOST);
That is all. It should return the result of the evaluation so if the Asset is not in VM I think this will work. I will look for the documentation I have but it is old. You may want to see if your TAM can find something more updated and post.
I appreciate the response, but this doesn't cover the WAS module, or any of the other modules that might be in use. I was hoping there was something like:
return !asset.getActivatedForModule().contains(Module.ModuleType.VM) && !asset.getActivatedForModule().contains(Module.ModuleType.WAS) && ... ;
but without documentation I'm just guessing at the available methods and constants.
I know this is a 2-year late reply but we just did this ourselves. Here's the Groovy code we used:
if(asset.getAssetType()!=Asset.AssetType.HOST) return false;last_scan_string = asset.resultsForQid(45038L);if(last_scan_string != "") return true;
This checks to see if there is any date stamp returned. Hosts without VM will never have any QID data and therefore the value will always be null. Ergo the code above will apply the tag to any host where this value is not blank.
Retrieving data ...