-
Notifications
You must be signed in to change notification settings - Fork 5
AIML-226: Fix tool names exceeding Claude API 64-char limit #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a53381e
2ad7250
0383a49
e1d7d22
08c2259
b0685c8
4b89984
9b971bb
8c62632
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,3 +40,4 @@ build/ | |
|
|
||
| ### Beads ### | ||
| .beads/ | ||
| test-plan-*.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -221,89 +221,72 @@ public List<VulnLight> listVulnsByAppId( | |
|
|
||
|
|
||
|
|
||
| @Tool(name = "list_vulnerabilities_by_application_and_session_metadata", description = "Takes an application name ( app_name ) and session metadata in the form of name / value. and returns a list of vulnerabilities matching that application name and session metadata.") | ||
| public List<VulnLight> listVulnsInAppByNameAndSessionMetadata( | ||
| @ToolParam(description = "Application name") String app_name, | ||
| @Tool(name = "list_vulns_by_app_and_metadata", description = "Takes an application ID (appID) and session metadata in the form of name / value and returns a list of vulnerabilities matching that application ID and session metadata. Use list_applications_with_name first to get the application ID from a name.") | ||
| public List<VulnLight> listVulnsByAppIdAndSessionMetadata( | ||
| @ToolParam(description = "Application ID") String appID, | ||
| @ToolParam(description = "Session metadata field name") String session_Metadata_Name, | ||
| @ToolParam(description = "Session metadata field value") String session_Metadata_Value) throws IOException { | ||
| logger.info("Listing vulnerabilities for application: {}", app_name); | ||
| ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName,httpProxyHost, httpProxyPort); | ||
| logger.info("Listing vulnerabilities for application: {}", appID); | ||
|
|
||
| logger.info("metadata : " + session_Metadata_Name+session_Metadata_Value); | ||
|
|
||
| logger.debug("Searching for application ID matching name: {}", app_name); | ||
|
|
||
| Optional<Application> application = SDKHelper.getApplicationByName(app_name, orgID, contrastSDK); | ||
| if(application.isPresent()) { | ||
| try { | ||
| List<VulnLight> vulns = listVulnsByAppId(application.get().getAppId()); | ||
| List<VulnLight> returnVulns = new ArrayList<>(); | ||
| for(VulnLight vuln : vulns) { | ||
| if(vuln.sessionMetadata()!=null) { | ||
| for(SessionMetadata sm : vuln.sessionMetadata()) { | ||
| for(MetadataItem metadataItem : sm.getMetadata()) { | ||
| if(metadataItem.getDisplayLabel().equalsIgnoreCase(session_Metadata_Name) && | ||
| metadataItem.getValue().equalsIgnoreCase(session_Metadata_Value)) { | ||
| returnVulns.add(vuln); | ||
| logger.debug("Found matching vulnerability with ID: {}", vuln.vulnID()); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| try { | ||
| List<VulnLight> vulns = listVulnsByAppId(appID); | ||
| List<VulnLight> returnVulns = new ArrayList<>(); | ||
| for(VulnLight vuln : vulns) { | ||
| if (vuln.sessionMetadata() == null) { | ||
| continue; | ||
| } | ||
| for (SessionMetadata sm : vuln.sessionMetadata()) { | ||
| for (MetadataItem metadataItem : sm.getMetadata()) { | ||
| if (metadataItem.getDisplayLabel().equalsIgnoreCase(session_Metadata_Name) && | ||
| metadataItem.getValue().equalsIgnoreCase(session_Metadata_Value)) { | ||
| returnVulns.add(vuln); | ||
| logger.debug("Found matching vulnerability with ID: {}", vuln.vulnID()); | ||
| break; | ||
| } | ||
| } | ||
| return returnVulns; | ||
| } catch (Exception e) { | ||
| logger.error("Error listing vulnerabilities for application: {}", app_name, e); | ||
| throw new IOException("Failed to list vulnerabilities: " + e.getMessage(), e); | ||
| } | ||
| } | ||
| } else { | ||
| logger.debug("Application with name {} not found, returning empty list", app_name); | ||
| return new ArrayList<>(); | ||
| return returnVulns; | ||
| } catch (Exception e) { | ||
| logger.error("Error listing vulnerabilities for application: {}", appID, e); | ||
| throw new IOException("Failed to list vulnerabilities: " + e.getMessage(), e); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| @Tool(name = "list_vulnerabilities_by_application_and_latest_session", description = "Takes an application name ( app_name ) and returns a list of vulnerabilities for the latest session matching that application name. This is useful for getting the most recent vulnerabilities without needing to specify session metadata.") | ||
| public List<VulnLight> listVulnsInAppByNameForLatestSession( | ||
| @ToolParam(description = "Application name") String app_name) throws IOException { | ||
| logger.info("Listing vulnerabilities for application: {}", app_name); | ||
| @Tool(name = "list_vulns_by_app_latest_session", description = "Takes an application ID (appID) and returns a list of vulnerabilities for the latest session matching that application ID. This is useful for getting the most recent vulnerabilities without needing to specify session metadata. Use list_applications_with_name first to get the application ID from a name.") | ||
| public List<VulnLight> listVulnsByAppIdForLatestSession( | ||
| @ToolParam(description = "Application ID") String appID) throws IOException { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't need a more complete description?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it does. I just consolidated methods, so this must be how this already was. All the tool descriptions and tool names are getting a full makeover. I am getting down to the the tools I want to keep before I invest in that. So yes, this will get a full description,. |
||
| logger.info("Listing vulnerabilities for application: {}", appID); | ||
ChrisEdwards marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName,httpProxyHost, httpProxyPort); | ||
|
|
||
| try { | ||
| SDKExtension extension = new SDKExtension(contrastSDK); | ||
| SessionMetadataResponse latest = extension.getLatestSessionMetadata(orgID, appID); | ||
|
|
||
| logger.debug("Searching for application ID matching name: {}", app_name); | ||
| Optional<Application> application = SDKHelper.getApplicationByName(app_name, orgID, contrastSDK); | ||
|
|
||
| if(application.isPresent()) { | ||
| try { | ||
| SDKExtension extension = new SDKExtension(contrastSDK); | ||
| SessionMetadataResponse latest = extension.getLatestSessionMetadata(orgID,application.get().getAppId()); | ||
|
|
||
| // Use SDK's native TraceFilterBody with agentSessionId field | ||
| var filterBody = new com.contrastsecurity.models.TraceFilterBody(); | ||
| if (latest != null && latest.getAgentSession() != null && latest.getAgentSession().getAgentSessionId() != null) { | ||
| filterBody.setAgentSessionId(latest.getAgentSession().getAgentSessionId()); | ||
| } | ||
| // Use SDK's native TraceFilterBody with agentSessionId field | ||
| com.contrastsecurity.models.TraceFilterBody filterBody = new com.contrastsecurity.models.TraceFilterBody(); | ||
| if(latest!=null&&latest.getAgentSession()!=null&&latest.getAgentSession().getAgentSessionId()!=null) { | ||
| filterBody.setAgentSessionId(latest.getAgentSession().getAgentSessionId()); | ||
| } | ||
|
|
||
| // Use SDK's native getTraces() with expand parameter | ||
| Traces tracesResponse = contrastSDK.getTraces( | ||
| orgID, | ||
| application.get().getAppId(), | ||
| filterBody, | ||
| EnumSet.of(TraceFilterForm.TraceExpandValue.SESSION_METADATA) | ||
| ); | ||
| // Use SDK's native getTraces() with expand parameter | ||
| Traces tracesResponse = contrastSDK.getTraces( | ||
| orgID, | ||
| appID, | ||
| filterBody, | ||
| EnumSet.of(TraceFilterForm.TraceExpandValue.SESSION_METADATA) | ||
| ); | ||
|
|
||
| List<VulnLight> vulns = tracesResponse.getTraces().stream() | ||
| .map(vulnerabilityMapper::toVulnLight) | ||
| .collect(Collectors.toList()); | ||
| return vulns; | ||
| } catch (Exception e) { | ||
| logger.error("Error listing vulnerabilities for application: {}", app_name, e); | ||
| throw new IOException("Failed to list vulnerabilities: " + e.getMessage(), e); | ||
| } | ||
| } else { | ||
| logger.debug("Application with name {} not found, returning empty list", app_name); | ||
| return new ArrayList<>(); | ||
| List<VulnLight> vulns = tracesResponse.getTraces().stream() | ||
| .map(vulnerabilityMapper::toVulnLight) | ||
| .collect(Collectors.toList()); | ||
| return vulns; | ||
| } catch (Exception e) { | ||
| logger.error("Error listing vulnerabilities for application: {}", appID, e); | ||
| throw new IOException("Failed to list vulnerabilities: " + e.getMessage(), e); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.