Create a Risk Profile Policy by API

Coverity on Polaris

Version
latest
Here's now to configure a new Risk Profile Policy for use across your organization.
Use the following request:

curl -X POST "https://{subdomain}.cop.blackduck.com/api/risk-profile-service/v0/policies"\
 -H "accept: application/vnd.api+json" -H "Content-Type: application/vnd.api+json" -H 'Authorization: Bearer {JWT}  -d\
{
    "data": {
        "id": "d176923e-ce35-11eb-b8bc-0242ac130003",
        "type": "risk-profile-policy",
        "attributes": {
            "description": "Test Policy for webgoat",
            "distribution": "OPEN_SOURCE",
            "name": "docs webgoat risk policy 2",
            "phase": "RELEASED",
            "risk-profile-scales": [
                {
                    "end-range": 100,
                    "severity": "HIGH",
                    "start-range": 80
                },
                {
                    "end-range": 79,
                    "severity": "MEDIUM",
                    "start-range": 40
                },
                {
                    "end-range": 39,
                    "severity": "LOW",
                    "start-range": 10
                }
            ],
            "tier": "TIER1",
            "weight-attributes": [
                {
                    "attribute-type": "SEVERITY",
                    "attribute-name": "HIGH",
                    "weight": 3
                },
                {
                    "attribute-type": "SEVERITY",
                    "attribute-name": "MEDIUM",
                    "weight": 2
                },
                {
                    "attribute-type": "SEVERITY",
                    "attribute-name": "LOW",
                    "weight": 1
                },
                {
                    "attribute-type": "DOMAIN",
                    "attribute-name": "SAST",
                    "weight": 1
                }
            ]
        },
        "relationships": {
            "applications": {
                "data": [ ],
                "meta": {
                    "total": 0
                }
            }
        }
    }
}      
                    

Insert your long-lasting token in place of {JWT} in the second line.

In the request above, the following are mandatory:
  • Policy name (data.attributes.name)
  • Weights for all the available severities: high, medium, and low. (All are stored under data.attributes.weight-attributes and "attribute-type": "SEVERITY")
  • A weight for at least one tool domain (Stored under data.attributes.weight-attributes and "attribute-type": "DOMAIN")

All other attributes (under data.attributes) are optional.

Response:

The response echoes your request.

{
    "data": {
        "id": "d176923e-ce35-11eb-b8bc-0242ac130003",
        "type": "risk-profile-policy",
        "attributes": {
            "description": "Test Policy for webgoat",
            "distribution": "OPEN_SOURCE",
            "name": "docs webgoat risk policy 2",
            "phase": "RELEASED",
            "risk-profile-scales": [
                {
                    "end-range": 100,
                    "severity": "HIGH",
                    "start-range": 80
                },
                {
                    "end-range": 79,
                    "severity": "MEDIUM",
                    "start-range": 40
                },
                {
                    "end-range": 39,
                    "severity": "LOW",
                    "start-range": 10
                }
            ],
            "tier": "TIER1",
            "weight-attributes": [
                {
                    "attribute-type": "SEVERITY",
                    "attribute-name": "HIGH",
                    "weight": 3
                },
                {
                    "attribute-type": "SEVERITY",
                    "attribute-name": "MEDIUM",
                    "weight": 2
                },
                {
                    "attribute-type": "SEVERITY",
                    "attribute-name": "LOW",
                    "weight": 1
                },
                {
                    "attribute-type": "DOMAIN",
                    "attribute-name": "SAST",
                    "weight": 1
                }
            ]
        },
        "relationships": {
            "applications": {
                "data": [],
                "meta": {
                    "total": 0
                }
            }
        }
    }
}