use of com.checkmarx.flow.dto.CxProfile in project cx-flow by checkmarx-ltd.
the class HelperService method loadCxProfiles.
@PostConstruct
public void loadCxProfiles() {
if (properties.isAutoProfile() && !ScanUtils.empty(properties.getProfileConfig())) {
log.debug("Loading CxProfile: {}", properties.getProfileConfig());
File profileConfig = new File(properties.getProfileConfig());
ObjectMapper mapper = new ObjectMapper();
// if override is provided, check if chars are more than 20 in length, implying base64 encoded json
try {
CxProfile[] cxProfiles = mapper.readValue(profileConfig, CxProfile[].class);
this.profiles = Arrays.asList(cxProfiles);
} catch (IOException e) {
log.warn("No CxProfile found - {}", e.getMessage());
}
}
}
use of com.checkmarx.flow.dto.CxProfile in project cx-flow by checkmarx-ltd.
the class HelperServiceTest method testGetPresetFromSources.
@Test
public void testGetPresetFromSources() {
FlowProperties properties = new FlowProperties();
CxProperties cxProperties = new CxProperties();
JiraProperties jiraProperties = new JiraProperties();
cxProperties.setScanPreset(Constants.CX_DEFAULT_PRESET);
CxScannerService cxScannerService = new CxScannerService(cxProperties, null, null, null, null);
HelperService helperService = new HelperService(properties, cxScannerService, jiraProperties, null);
Sources sources = new Sources();
Sources.Source src1 = new Sources.Source();
src1.setFile("abc.java");
src1.setPath("abc.java");
Sources.Source src2 = new Sources.Source();
src2.setFile("abc.html");
src2.setPath("abc.html");
Sources.Source src3 = new Sources.Source();
src3.setFile("abc.css");
src3.setPath("abc.css");
Sources.Source src4 = new Sources.Source();
src4.setFile("buildspec.yml");
src4.setPath("buildspec.yml");
Map<String, Integer> sourceWeight = new HashMap<>();
sourceWeight.put("Java", 65);
sourceWeight.put("CSS", 15);
sourceWeight.put("HTML", 20);
sources.setLanguageStats(sourceWeight);
sources.setSources(Arrays.asList(src1, src2, src3, src4));
ObjectMapper mapper = new ObjectMapper();
System.out.println(HelperService.class.getResource(".").getPath());
File file = new File(getClass().getClassLoader().getResource("CxProfile.json").getFile());
try {
CxProfile[] cxProfiles = mapper.readValue(file, CxProfile[].class);
helperService.setProfiles(Arrays.asList(cxProfiles));
String preset = helperService.getPresetFromSources(sources);
assertEquals(preset, "Checkmarx Express");
} catch (IOException e) {
fail("Unexpected IO Exception");
}
}
Aggregations