private Advisory parseAdvisory ( JSONObject object ) { final Advisory advisory = new Advisory ( ) ; advisory . setId ( object . getInt ( "id" ) ) ; advisory . setOverview ( object . optString ( "overview" , null ) ) ; advisory . setReferences ( object . optString ( "references" , null ) ) ; advisory . setCreated ( object . optString ( "created" , null ) ) ; advisory . setUpdated ( object . optString ( "updated" , null ) ) ; advisory . setRecommendation ( object . optString ( "recommendation" , null ) ) ; advisory . setTitle ( object . optString ( "title" , null ) ) ; //advisory.setFoundBy(object.optString("author", null)); //advisory.setReportedBy(object.optString("author", null)); advisory . setModuleName ( object . optString ( "module_name" , null ) ) ; advisory . setVulnerableVersions ( object . optString ( "vulnerable_versions" , null ) ) ; advisory . setPatchedVersions ( object . optString ( "patched_versions" , null ) ) ; advisory . setAccess ( object . optString ( "access" , null ) ) ; advisory . setSeverity ( object . optString ( "severity" , null ) ) ; advisory . setCwe ( object . optString ( "cwe" , null ) ) ; final JSONArray findings = object . optJSONArray ( "findings" ) ; for ( int i = 0 ; i < findings . length ( ) ; i ++ ) { final JSONObject finding = findings . getJSONObject ( i ) ; final String version = finding . optString ( "version" , null ) ; final JSONArray paths = finding . optJSONArray ( "paths" ) ; for ( int j = 0 ; j < paths . length ( ) ; j ++ ) { final String path = paths . getString ( j ) ; if ( path != null && path . equals ( advisory . getModuleName ( ) ) ) { advisory . setVersion ( version ) ; } } } final JSONArray jsonCves = object . optJSONArray ( "cves" ) ; final List < String > stringCves = new ArrayList <> ( ) ; if ( jsonCves != null ) { for ( int j = 0 ; j < jsonCves . length ( ) ; j ++ ) { stringCves . add ( jsonCves . getString ( j ) ) ; } advisory . setCves ( stringCves ) ; } return advisory ; }
Parses the advisory from Node Audit .