Created
January 18, 2018 12:23
-
-
Save SyCode7/8acb252d540ef15828e69d0f39242e11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ReportCollector { | |
public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException { | |
// ArrayList | |
Layers layers = new Layers(); | |
Layer layer = new Layer(); | |
// List<Layers> de.security.reports.ScanReport.getLayers() | |
File reportFile = new File("reports/json/analysis-postgres-latest.json"); | |
FileReader reader = new FileReader(reportFile); | |
JSONObject obj = new JSONObject(); | |
ObjectMapper mapper = new ObjectMapper(); | |
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |
ScanReport tester = mapper.readValue(reportFile, ScanReport.class); | |
List<Layers> layerList = tester.getLayers(); | |
List<Feature> featureList; | |
List<Vulnerability> vulnerabilities = null; | |
for (Layers layers2 : layerList) { | |
featureList = layers2.getLayer().getFeatures(); | |
System.out.println("Number of features: " + featureList.size()); | |
System.out.println("***************************************************************"); | |
for (Feature feature : featureList) { | |
System.out.println("Feature name :" + feature.getName()); | |
if (feature.getVulnerabilities().equals(" ") || feature.getVulnerabilities().isEmpty() | |
|| feature.getVulnerabilities().size() == 0) { | |
System.out.println("no vulnerability found"); | |
} else { | |
vulnerabilities = feature.getVulnerabilities(); | |
// if vulnerabilities.ex | |
// if(vulnerabilities.isEmpty() ||vulnerabilities.equals(" ") || | |
// vulnerabilities.size() == 0) { | |
System.out.println("------------------------------------------------------------"); | |
for (Vulnerability vulnerability : vulnerabilities) { | |
System.out.println(" === Vulnerabilities === "); | |
System.out.println("CVE: " + vulnerability.getName()); | |
System.out.println("Namespace: " + vulnerability.getNamespaceName()); | |
System.out.println("Description: " + vulnerability.getDescription()); | |
System.out.println("Link: " + vulnerability.getLink()); | |
System.out.println("Fixed by: " + vulnerability.getFixedBy()); | |
System.out.println("Metadata: " + vulnerability.getMetadata()); | |
System.out.println("Severity: " + vulnerability.getSeverity()); | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment