@@ -102,7 +102,7 @@ public Vulnerability getVulnerabilityById(String vulnID, String appID) throws IO
102
102
List <LibraryExtended > libs = SDKHelper .getLibsForID (appID ,orgID , new SDKExtension (contrastSDK ));
103
103
List <LibraryLibraryObservation > lobs = new ArrayList <>();
104
104
for (LibraryExtended lib : libs ) {
105
- LibraryLibraryObservation llob = new LibraryLibraryObservation (lib ,new SDKExtension ( contrastSDK ). getLibraryObservations ( orgID , appID , lib .getHash (),50 ));
105
+ LibraryLibraryObservation llob = new LibraryLibraryObservation (lib , SDKHelper . getLibraryObservationsWithCache ( lib .getHash (), appID , orgID , 50 , new SDKExtension ( contrastSDK ) ));
106
106
lobs .add (llob );
107
107
}
108
108
List <StackLib > stackLibs = new ArrayList <>();
@@ -157,7 +157,7 @@ public Vulnerability getVulnerability(String vulnID, String app_name) throws IOE
157
157
Optional <String > appID = Optional .empty ();
158
158
logger .debug ("Searching for application ID matching name: {}" , app_name );
159
159
160
- for (Application app : contrastSDK . getApplications (orgID ). getApplications ( )) {
160
+ for (Application app : SDKHelper . getApplicationsWithCache (orgID , contrastSDK )) {
161
161
if (app .getName ().toLowerCase ().contains (app_name .toLowerCase ())) {
162
162
appID = Optional .of (app .getId ());
163
163
logger .debug ("Found matching application - ID: {}, Name: {}" , app .getId (), app .getName ());
@@ -176,7 +176,6 @@ public Vulnerability getVulnerability(String vulnID, String app_name) throws IOE
176
176
public List <VulnLight > listVulnsByAppId (String appID ) throws IOException {
177
177
logger .info ("Listing vulnerabilities for application ID: {}" , appID );
178
178
ContrastSDK contrastSDK = SDKHelper .getSDK (hostName , apiKey , serviceKey , userName );
179
-
180
179
try {
181
180
List <Trace > traces = contrastSDK .getTraces (orgID , appID , new TraceFilterBody ()).getTraces ();
182
181
logger .debug ("Found {} vulnerability traces for application ID: {}" , traces .size (), appID );
@@ -203,7 +202,7 @@ public List<VulnLight> listVulnsInAppByName(String app_name) throws IOException
203
202
Optional <String > appID = Optional .empty ();
204
203
logger .debug ("Searching for application ID matching name: {}" , app_name );
205
204
206
- for (Application app : contrastSDK . getApplications (orgID ). getApplications ( )) {
205
+ for (Application app : SDKHelper . getApplicationsWithCache (orgID , contrastSDK )) {
207
206
if (app .getName ().toLowerCase ().contains (app_name .toLowerCase ())) {
208
207
appID = Optional .of (app .getId ());
209
208
logger .debug ("Found matching application - ID: {}, Name: {}" , app .getId (), app .getName ());
@@ -225,11 +224,11 @@ public List<VulnLight> listVulnsInAppByName(String app_name) throws IOException
225
224
226
225
227
226
@ Tool (name = "list_applications" , description = "Takes an application name (app_name) returns a list of active applications matching that name. Please remember to display the name, status and ID." )
228
- public List <ApplicationData > getActiveApplications (String app_name ) throws IOException {
227
+ public List <ApplicationData > getApplications (String app_name ) throws IOException {
229
228
logger .info ("Listing active applications matching name: {}" , app_name );
230
229
ContrastSDK contrastSDK = SDKHelper .getSDK (hostName , apiKey , serviceKey , userName );
231
230
try {
232
- List <Application > applications = contrastSDK . getApplications (orgID ). getApplications ( );
231
+ List <Application > applications = SDKHelper . getApplicationsWithCache (orgID , contrastSDK );
233
232
logger .debug ("Retrieved {} total applications from Contrast" , applications .size ());
234
233
235
234
List <ApplicationData > filteredApps = new ArrayList <>();
@@ -255,16 +254,16 @@ public List<ApplicationData> getActiveApplications() throws IOException {
255
254
logger .info ("Listing all applications" );
256
255
ContrastSDK contrastSDK = SDKHelper .getSDK (hostName , apiKey , serviceKey , userName );
257
256
try {
258
- List <Application > applications = contrastSDK . getApplications (orgID ). getApplications ( );
257
+ List <Application > applications = SDKHelper . getApplicationsWithCache (orgID , contrastSDK );
259
258
logger .debug ("Retrieved {} total applications from Contrast" , applications .size ());
260
259
261
- List <ApplicationData > ReturnedApps = new ArrayList <>();
260
+ List <ApplicationData > returnedApps = new ArrayList <>();
262
261
for (Application app : applications ) {
263
- ReturnedApps .add (new ApplicationData (app .getName (), app .getStatus (), app .getId ()));
262
+ returnedApps .add (new ApplicationData (app .getName (), app .getStatus (), app .getId ()));
264
263
}
265
264
266
- logger .info ("Found {} applications matching' " , ReturnedApps .size ());
267
- return ReturnedApps ;
265
+ logger .info ("Found {} applications" , returnedApps .size ());
266
+ return returnedApps ;
268
267
269
268
} catch (Exception e ) {
270
269
logger .error ("Error listing all applications" , e );
0 commit comments