Skip to content

Add new method to get all the applications #1

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

Merged
merged 3 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/contrast_security_app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# DISCLAIMER: This workflow file has been auto-generated and committed to the repo by the GitHub App from Contrast Security.
# Manual edits to this file could cause the integration to produce unexpected behavior or break.
# Version: 1.0.1
# Last updated: 2025-06-12T13:52:06.657445917Z
name: Contrast Security App Workflow
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
jobs:
fingerprint_repo:
if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-22.04
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Run Contrast SCA Fingerprint
id: fingerprint
uses: Contrast-Security-OSS/contrast-sca-action@v3
with:
apiKey: ${{ secrets.CONTRAST_GITHUB_APP_API_KEY }}
authHeader: ${{ secrets.CONTRAST_GITHUB_APP_AUTH_HEADER }}
orgId: ${{ vars.CONTRAST_GITHUB_APP_ORG_ID }}
apiUrl: ${{ vars.CONTRAST_GITHUB_APP_TS_URL }}
repoUrl: ${{ github.server_url }}/${{ github.repository }}
repoName: ${{ github.repository }}
externalId: ${{ vars.CONTRAST_GITHUB_APP_ID }}
command: fingerprint
outputs:
fingerprint: ${{ steps.fingerprint.outputs.fingerprint }}
analyze_dependencies:
if: ${{ needs.fingerprint_repo.outputs.fingerprint != '' }}
needs: fingerprint_repo
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
manifest:
- ${{ fromJson(needs.fingerprint_repo.outputs.fingerprint) }}
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Run Contrast SCA Audit
uses: Contrast-Security-OSS/contrast-sca-action@v3
with:
apiKey: ${{ secrets.CONTRAST_GITHUB_APP_API_KEY }}
authHeader: ${{ secrets.CONTRAST_GITHUB_APP_AUTH_HEADER }}
orgId: ${{ vars.CONTRAST_GITHUB_APP_ORG_ID }}
apiUrl: ${{ vars.CONTRAST_GITHUB_APP_TS_URL }}
filePath: ${{ matrix.manifest.filePath }}
repositoryId: ${{ matrix.manifest.repositoryId }}
projectGroupId: ${{ matrix.manifest.projectGroupId }}
23 changes: 23 additions & 0 deletions src/main/java/com/contrast/labs/ai/mcp/contrast/AssessService.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,27 @@ public List<ApplicationData> getActiveApplications(String appName) throws IOExce
throw new IOException("Failed to list applications: " + e.getMessage(), e);
}
}


@Tool(name = "list_all_applications", description = "Takes no argument and list all the applications")
public List<ApplicationData> getActiveApplications() throws IOException {
logger.info("Listing all applications");
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
try {
List<Application> applications = contrastSDK.getApplications(orgID).getApplications();
logger.debug("Retrieved {} total applications from Contrast", applications.size());

List<ApplicationData> ReturnedApps = new ArrayList<>();
for(Application app : applications) {
ReturnedApps.add(new ApplicationData(app.getName(), app.getStatus(), app.getId()));
}

logger.info("Found {} applications matching'", ReturnedApps.size());
return ReturnedApps;

} catch (Exception e) {
logger.error("Error listing all applications", e);
throw new IOException("Failed to list applications: " + e.getMessage(), e);
}
}
}
Loading