AnsweredAssumed Answered

Can Groovy Asset Tagging access/search static Asset Groups for hostnames?

Question asked by Jake VanMast on Feb 15, 2018

Qualys tagging by DNS hostname, via Asset Group, is broken (CRM#[19585]). I see a Groovy tagging example which could work around this issue:

 

    if(asset.getAssetType()!=Asset.AssetType.HOST)

        return false;

    def hostnameArray = ["host1.domain.com","host2.domain.com","host3.domain.com",]

    def name = asset.name.toLowerCase()

    if(hostnameArray.contains(name))

        return true

    return false

 

 

From what I've read, using map.containsKey() might scale better, however either method puts the hostname list in the script. For hostname list maintainability, I would rather check against a Qualys maintained list, like Asset Group, which supports User/Activity Log change tracking.

 

I see no documentation on the Qualys supported Groovy classes/methods in documentation or community, and most community Groovy threads end unanswered with customers asking for a Qualys Groovy library guide. Does anyone know if it's possible to access Asset Groups? 

 

    ### nonworking code, for example / pseudo code

    if(asset.getAssetType()!=Asset.AssetType.HOST)

        return false;

    import com.qualys.BLAH.asset.group;

    return new AssetGroup('MyGroup').names.contains(asset.name.toLowerCase())

 

 

I've not used Groovy before, is there some way to learn the available classes/methods with metaClass.properties and the Tag Edit/"Test Applicability" feature? Or is there a way to obtain the Java .jar and deconstruct to learn the implemented libraries?

Outcomes