Search in sources :

Example 1 with FortifyAttributeDefinitionResponse

use of com.blackducksoftware.integration.fortify.model.FortifyAttributeDefinitionResponse in project hub-fortify-ssc-integration-service by blackducksoftware.

the class MappingParser method addCustomAttributes.

/**
 * Add the custom required attributes to fortify update attribute definition request
 *
 * @param updateAttributerequests
 * @return
 * @throws IOException
 * @throws IntegrationException
 */
public List<UpdateFortifyApplicationAttributesRequest> addCustomAttributes() throws IOException, IntegrationException {
    final FortifyAttributeDefinitionResponse fortifyAttributeDefinitionResponse = fortifyAttributeDefinitionApi.getAttributeDefinitions();
    final List<String> ignoreAttributes = Arrays.asList("Known Compliance Obligations", "Data Classification", "Application Classification", "Interfaces", "Development Languages", "Authentication System");
    final List<UpdateFortifyApplicationAttributesRequest> updateAttributerequests = new ArrayList<>();
    logger.debug(fortifyAttributeDefinitionResponse);
    for (final FortifyAttributeDefinition fortifyAttributeDefinition : fortifyAttributeDefinitionResponse.getApplicationAttributeDefinitions()) {
        if (DYNAMIC_SCAN_REQUEST.equalsIgnoreCase(fortifyAttributeDefinition.getCategory())) {
            continue;
        }
        if (Collections.binarySearch(ignoreAttributes, fortifyAttributeDefinition.getName(), String.CASE_INSENSITIVE_ORDER) == 0 && StringUtils.isEmpty(attributeConstants.getProperty(fortifyAttributeDefinition.getName()))) {
            logger.debug("Attribute name::" + fortifyAttributeDefinition.getName() + ", value::" + attributeConstants.getProperty(fortifyAttributeDefinition.getName()));
            updateAttributerequests.add(new UpdateFortifyApplicationAttributesRequest(fortifyAttributeDefinition.getId(), new ArrayList<Value>(), null));
        } else if (StringUtils.isEmpty(attributeConstants.getProperty(fortifyAttributeDefinition.getName()))) {
            throw new IntegrationException("Attribute value for " + fortifyAttributeDefinition.getName() + " is missing in " + propertyConstants.getAttributeFilePath());
        } else {
            updateAttributerequests.add(addCustomAttributes(fortifyAttributeDefinition));
        }
    }
    return updateAttributerequests;
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) UpdateFortifyApplicationAttributesRequest(com.blackducksoftware.integration.fortify.model.UpdateFortifyApplicationAttributesRequest) FortifyAttributeDefinition(com.blackducksoftware.integration.fortify.model.FortifyAttributeDefinitionResponse.FortifyAttributeDefinition) ArrayList(java.util.ArrayList) FortifyAttributeDefinitionResponse(com.blackducksoftware.integration.fortify.model.FortifyAttributeDefinitionResponse)

Example 2 with FortifyAttributeDefinitionResponse

use of com.blackducksoftware.integration.fortify.model.FortifyAttributeDefinitionResponse in project hub-fortify-ssc-integration-service by blackducksoftware.

the class FortifyAttributeDefinitionApiTest method getApplicationAttributeDefinition.

@Test
public void getApplicationAttributeDefinition() throws IOException, IntegrationException {
    FortifyAttributeDefinitionResponse fortifyAttributeDefintionResponse = fortifyAttributeDefinitionApi.getAttributeDefinitions();
    System.out.println(fortifyAttributeDefintionResponse);
    assertNotNull(fortifyAttributeDefintionResponse);
}
Also used : FortifyAttributeDefinitionResponse(com.blackducksoftware.integration.fortify.model.FortifyAttributeDefinitionResponse) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

FortifyAttributeDefinitionResponse (com.blackducksoftware.integration.fortify.model.FortifyAttributeDefinitionResponse)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 FortifyAttributeDefinition (com.blackducksoftware.integration.fortify.model.FortifyAttributeDefinitionResponse.FortifyAttributeDefinition)1 UpdateFortifyApplicationAttributesRequest (com.blackducksoftware.integration.fortify.model.UpdateFortifyApplicationAttributesRequest)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1