blackducksoftware / hub-client-go

Hub Client for Go (golang)
Apache License 2.0
9 stars 19 forks source link

Failing to consume "listing policy rules of a BOM component version" API #55

Closed akashnagesh closed 4 years ago

akashnagesh commented 4 years ago

Failing to consume the response for /api/projects/{projectId}/versions/{projectVersionId}/components/{componentId}/versions/{componentVersionId}/policy-rules

This is because PolicyRule.Expression.ExpressionParameter.Data was expected to be an map[string]IntOrString type. But this doesn't seem to be always true.

A sample response where this fails:

{
   "name":"VULN_LEVEL_EXPLOIT",
   "operation":"EQ",
   "parameters":{
      "values":[
         "TRUE"
      ],
      "data":[
         {
            "data":true
         }
      ]
   },
   "displayName":"Exploit Available"
}

Here "data" is a boolean because of which we will fail to unmarshal this response.

Changing the PolicyRule.Expression.ExpressionParameter.Data type to be a map[string]interface{} would perhaps fix this issue.

tandr commented 4 years ago

There is definitely needs to be more info - versions of hub, APIs, maybe an example of json

akashnagesh commented 4 years ago

Tested this against hub 2020.1 and 2020.4. It was reproducible on both these versions.

API version used was V6.

After talking to folks from the hub team, it appears that the hub-client was incorrect to assume the data type of PolicyRule.Expression.ExpressionParameter.Data to be a map[string]IntOrString

Also, there is no mention of PolicyRule.Expression.ExpressionParameter.Data in hub api docs at all. There's a different bug tracking this issue.