Skip to content

Commit 6c25aed

Browse files
Merge pull request #2 from javixeneize/pr-app
Minor fixes to avoid LLMs confusion
2 parents 202265f + 9eaeae8 commit 6c25aed

File tree

5 files changed

+43
-42
lines changed

5 files changed

+43
-42
lines changed

src/main/java/com/contrast/labs/ai/mcp/contrast/ADRService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public ProtectData getProtectData(String applicationName) throws IOException {
5858

5959
// Get application ID from name
6060
logger.debug("Looking up application ID for name: {}", applicationName);
61-
String appID = SDKHelper.getAppIDFromAppName(applicationName, orgID, contrastSDK);
61+
String appID = SDKHelper.getAppIDFromapp_name(applicationName, orgID, contrastSDK);
6262
if (appID == null || appID.isEmpty()) {
6363
logger.warn("No application ID found for application: {}", applicationName);
6464
return null;

src/main/java/com/contrast/labs/ai/mcp/contrast/AssessService.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public class AssessService {
7070
private String orgID;
7171

7272

73-
@Tool(name = "get_vulnerability", description = "takes a vulnerability ID ( vulnID ) and Application ID ( appID ) and returns details about the specific security vulnerability. If based on the stacktrace, the vulnerability looks like it is in code that is not in the codebase, the vulnerability may be in a 3rd party library, review the CVE data attached to that stackframe you believe the vulnerability exists in and if possible upgrade that library to the next non vulnerable version based on the remediation guidance.")
74-
public Vulnerability getVulnerability(String vulnID, String appID) throws IOException {
73+
@Tool(name = "get_vulnerability_by_id", description = "takes a vulnerability ID ( vulnID ) and Application ID ( appID ) and returns details about the specific security vulnerability. If based on the stacktrace, the vulnerability looks like it is in code that is not in the codebase, the vulnerability may be in a 3rd party library, review the CVE data attached to that stackframe you believe the vulnerability exists in and if possible upgrade that library to the next non vulnerable version based on the remediation guidance.")
74+
public Vulnerability getVulnerabilityById(String vulnID, String appID) throws IOException {
7575
logger.info("Retrieving vulnerability details for vulnID: {} in application ID: {}", vulnID, appID);
7676
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
7777
logger.debug("ContrastSDK initialized with host: {}", hostName);
@@ -150,30 +150,30 @@ private Optional<LibraryLibraryObservation> findMatchingLibraryData(String stack
150150
return Optional.empty();
151151
}
152152

153-
@Tool(name = "get_vulnerability_by_app_name", description = "Takes a vulnerability ID (vulnID) and application name (appName) and returns details about the specific security vulnerability. If based on the stacktrace, the vulnerability looks like it is in code that is not in the codebase, the vulnerability may be in a 3rd party library, review the CVE data attached to that stackframe you believe the vulnerability exists in and if possible upgrade that library to the next non vulnerable version based on the remediation guidance.")
154-
public Vulnerability getVulnerabilityByAppName(String vulnID, String appName) throws IOException {
155-
logger.info("Retrieving vulnerability details for vulnID: {} in application: {}", vulnID, appName);
153+
@Tool(name = "get_vulnerability", description = "Takes a vulnerability ID (vulnID) and application name (app_name) and returns details about the specific security vulnerability. If based on the stacktrace, the vulnerability looks like it is in code that is not in the codebase, the vulnerability may be in a 3rd party library, review the CVE data attached to that stackframe you believe the vulnerability exists in and if possible upgrade that library to the next non vulnerable version based on the remediation guidance.")
154+
public Vulnerability getVulnerability(String vulnID, String app_name) throws IOException {
155+
logger.info("Retrieving vulnerability details for vulnID: {} in application: {}", vulnID, app_name);
156156
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
157157
Optional<String> appID = Optional.empty();
158-
logger.debug("Searching for application ID matching name: {}", appName);
158+
logger.debug("Searching for application ID matching name: {}", app_name);
159159

160160
for(Application app : contrastSDK.getApplications(orgID).getApplications()) {
161-
if(app.getName().toLowerCase().contains(appName.toLowerCase())) {
161+
if(app.getName().toLowerCase().contains(app_name.toLowerCase())) {
162162
appID = Optional.of(app.getId());
163163
logger.debug("Found matching application - ID: {}, Name: {}", app.getId(), app.getName());
164164
break;
165165
}
166166
}
167167
if(appID.isPresent()) {
168-
return getVulnerability(vulnID, appID.get());
168+
return getVulnerabilityById(vulnID, appID.get());
169169
} else {
170-
logger.error("Application with name {} not found", appName);
171-
throw new IllegalArgumentException("Application with name " + appName + " not found");
170+
logger.error("Application with name {} not found", app_name);
171+
throw new IllegalArgumentException("Application with name " + app_name + " not found");
172172
}
173173
}
174174

175-
@Tool(name = "list_vulnerabilities", description = "Takes a Application ID ( appID ) and returns a list of vulnerabilities, please remember to include the vulnID in the response.")
176-
public List<VulnLight> listVulnsInApp(String appID) throws IOException {
175+
@Tool(name = "list_vulnerabilities_with_id", description = "Takes a Application ID ( appID ) and returns a list of vulnerabilities, please remember to include the vulnID in the response.")
176+
public List<VulnLight> listVulnsByAppId(String appID) throws IOException {
177177
logger.info("Listing vulnerabilities for application ID: {}", appID);
178178
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
179179

@@ -194,56 +194,57 @@ public List<VulnLight> listVulnsInApp(String appID) throws IOException {
194194
}
195195
}
196196

197-
@Tool(name = "list_vulnerabilities_with_app_name", description = "Takes an application name ( appName ) and returns a list of vulnerabilities, please remember to include the vulnID in the response. ")
198-
public List<VulnLight> listVulnsInAppByName(String appName) throws IOException {
199-
logger.info("Listing vulnerabilities for application: {}", appName);
197+
198+
@Tool(name = "list_vulnerabilities", description = "Takes an application name ( app_name ) and returns a list of vulnerabilities, please remember to include the vulnID in the response. ")
199+
public List<VulnLight> listVulnsInAppByName(String app_name) throws IOException {
200+
logger.info("Listing vulnerabilities for application: {}", app_name);
200201
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
201202

202203
Optional<String> appID = Optional.empty();
203-
logger.debug("Searching for application ID matching name: {}", appName);
204+
logger.debug("Searching for application ID matching name: {}", app_name);
204205

205206
for(Application app : contrastSDK.getApplications(orgID).getApplications()) {
206-
if(app.getName().toLowerCase().contains(appName.toLowerCase())) {
207+
if(app.getName().toLowerCase().contains(app_name.toLowerCase())) {
207208
appID = Optional.of(app.getId());
208209
logger.debug("Found matching application - ID: {}, Name: {}", app.getId(), app.getName());
209210
break;
210211
}
211212
}
212213
if(appID.isPresent()) {
213214
try {
214-
return listVulnsInApp(appID.get());
215+
return listVulnsByAppId(appID.get());
215216
} catch (Exception e) {
216-
logger.error("Error listing vulnerabilities for application: {}", appName, e);
217+
logger.error("Error listing vulnerabilities for application: {}", app_name, e);
217218
throw new IOException("Failed to list vulnerabilities: " + e.getMessage(), e);
218219
}
219220
} else {
220-
logger.debug("Application with name {} not found, returning empty list", appName);
221+
logger.debug("Application with name {} not found, returning empty list", app_name);
221222
return new ArrayList<>();
222223
}
223224
}
224225

225226

226-
@Tool(name = "list_applications", description = "Takes an application name (appName) returns a list of active applications matching that name. Please remember to display the name, status and ID.")
227-
public List<ApplicationData> getActiveApplications(String appName) throws IOException {
228-
logger.info("Listing active applications matching name: {}", appName);
227+
@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 {
229+
logger.info("Listing active applications matching name: {}", app_name);
229230
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
230231
try {
231232
List<Application> applications = contrastSDK.getApplications(orgID).getApplications();
232233
logger.debug("Retrieved {} total applications from Contrast", applications.size());
233234

234235
List<ApplicationData> filteredApps = new ArrayList<>();
235236
for(Application app : applications) {
236-
if(app.getName().toLowerCase().contains(appName.toLowerCase())) {
237+
if(app.getName().toLowerCase().contains(app_name.toLowerCase())) {
237238
filteredApps.add(new ApplicationData(app.getName(), app.getStatus(), app.getId()));
238239
logger.debug("Found matching application - ID: {}, Name: {}, Status: {}",
239240
app.getId(), app.getName(), app.getStatus());
240241
}
241242
}
242243

243-
logger.info("Found {} applications matching '{}'", filteredApps.size(), appName);
244+
logger.info("Found {} applications matching '{}'", filteredApps.size(), app_name);
244245
return filteredApps;
245246
} catch (Exception e) {
246-
logger.error("Error listing applications matching name: {}", appName, e);
247+
logger.error("Error listing applications matching name: {}", app_name, e);
247248
throw new IOException("Failed to list applications: " + e.getMessage(), e);
248249
}
249250
}

src/main/java/com/contrast/labs/ai/mcp/contrast/SCAService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ public List<LibraryExtended> getApplicationLibrariesByID(String appID) throws IO
6767

6868

6969
@Tool(name = "list_application_libraries", description = "takes a application name and returns the libraries used in the application, note if class usage count is 0 the library is unlikely to be used")
70-
public List<LibraryExtended> getApplicationLibraries(String appName) throws IOException {
71-
logger.info("Retrieving libraries for application: {}", appName);
70+
public List<LibraryExtended> getApplicationLibraries(String app_name) throws IOException {
71+
logger.info("Retrieving libraries for application: {}", app_name);
7272
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
7373
logger.debug("ContrastSDK initialized with host: {}", hostName);
7474

7575
SDKExtension extendedSDK = new SDKExtension(contrastSDK);
7676
Optional<String> appID = Optional.empty();
77-
logger.debug("Searching for application ID matching name: {}", appName);
77+
logger.debug("Searching for application ID matching name: {}", app_name);
7878

7979
for(Application app : contrastSDK.getApplications(orgID).getApplications()) {
80-
if(app.getName().toLowerCase().contains(appName.toLowerCase())) {
80+
if(app.getName().toLowerCase().contains(app_name.toLowerCase())) {
8181
appID = Optional.of(app.getId());
8282
logger.info("Found matching application - ID: {}, Name: {}", app.getId(), app.getName());
8383
break;
@@ -86,7 +86,7 @@ public List<LibraryExtended> getApplicationLibraries(String appName) throws IOEx
8686
if(appID.isPresent()) {
8787
return SDKHelper.getLibsForID(appID.get(),orgID, extendedSDK);
8888
} else {
89-
logger.error("Application not found: {}", appName);
89+
logger.error("Application not found: {}", app_name);
9090
throw new IOException("Application not found");
9191
}
9292
}

src/main/java/com/contrast/labs/ai/mcp/contrast/sdkexstension/SDKHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ public static List<LibraryExtended> getLibsForID(String appID, String orgID, SDK
9090
return libs;
9191
}
9292

93-
public static String getAppIDFromAppName(String appName, String orgID, ContrastSDK contrastSDK) throws IOException {
93+
public static String getAppIDFromapp_name(String app_name, String orgID, ContrastSDK contrastSDK) throws IOException {
9494
// Check cache for existing result
95-
String cachedAppID = appIDCache.getIfPresent(appName);
95+
String cachedAppID = appIDCache.getIfPresent(app_name);
9696
if (cachedAppID != null) {
97-
logger.info("Cache hit for application name: {}", appName);
97+
logger.info("Cache hit for application name: {}", app_name);
9898
return cachedAppID;
9999
}
100-
logger.debug("Cache miss for application name: {}, searching for application ID", appName);
100+
logger.debug("Cache miss for application name: {}, searching for application ID", app_name);
101101
Optional<String> appID = Optional.empty();
102102
for (Application app : contrastSDK.getApplications(orgID).getApplications()) {
103-
if (app.getName().toLowerCase().contains(appName.toLowerCase())) {
103+
if (app.getName().toLowerCase().contains(app_name.toLowerCase())) {
104104
appID = Optional.of(app.getId());
105105
logger.info("Found matching application - ID: {}, Name: {}", app.getId(), app.getName());
106106
break;
@@ -109,10 +109,10 @@ public static String getAppIDFromAppName(String appName, String orgID, ContrastS
109109

110110
if (appID.isPresent()) {
111111
// Store result in cache
112-
appIDCache.put(appName, appID.get());
112+
appIDCache.put(app_name, appID.get());
113113
return appID.get();
114114
} else {
115-
logger.error("Application not found: {}", appName);
115+
logger.error("Application not found: {}", app_name);
116116
throw new IOException("Application not found");
117117
}
118118
}

src/main/java/com/contrast/labs/ai/mcp/contrast/sdkexstension/data/LibraryExtended.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public String getManifest() {
117117
private String appId;
118118

119119
@SerializedName("app_name")
120-
private String appName;
120+
private String app_name;
121121

122122
@SerializedName("app_context_path")
123123
private String appContextPath;
@@ -212,8 +212,8 @@ public String getAppId() {
212212
return appId;
213213
}
214214

215-
public String getAppName() {
216-
return appName;
215+
public String getapp_name() {
216+
return app_name;
217217
}
218218

219219
public String getAppContextPath() {

0 commit comments

Comments
 (0)