Skip to content

Commit 527c25e

Browse files
Merge pull request #1 from svevia/main
Add new method to get all the applications
2 parents 6c25aed + be6b3d7 commit 527c25e

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# DISCLAIMER: This workflow file has been auto-generated and committed to the repo by the GitHub App from Contrast Security.
2+
# Manual edits to this file could cause the integration to produce unexpected behavior or break.
3+
# Version: 1.0.1
4+
# Last updated: 2025-06-12T13:52:06.657445917Z
5+
name: Contrast Security App Workflow
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
types: [opened, synchronize, reopened]
13+
branches:
14+
- main
15+
jobs:
16+
fingerprint_repo:
17+
if: ${{ github.actor != 'dependabot[bot]' }}
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- name: Clone repository
21+
uses: actions/checkout@v4
22+
- name: Run Contrast SCA Fingerprint
23+
id: fingerprint
24+
uses: Contrast-Security-OSS/contrast-sca-action@v3
25+
with:
26+
apiKey: ${{ secrets.CONTRAST_GITHUB_APP_API_KEY }}
27+
authHeader: ${{ secrets.CONTRAST_GITHUB_APP_AUTH_HEADER }}
28+
orgId: ${{ vars.CONTRAST_GITHUB_APP_ORG_ID }}
29+
apiUrl: ${{ vars.CONTRAST_GITHUB_APP_TS_URL }}
30+
repoUrl: ${{ github.server_url }}/${{ github.repository }}
31+
repoName: ${{ github.repository }}
32+
externalId: ${{ vars.CONTRAST_GITHUB_APP_ID }}
33+
command: fingerprint
34+
outputs:
35+
fingerprint: ${{ steps.fingerprint.outputs.fingerprint }}
36+
analyze_dependencies:
37+
if: ${{ needs.fingerprint_repo.outputs.fingerprint != '' }}
38+
needs: fingerprint_repo
39+
runs-on: ubuntu-22.04
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
manifest:
44+
- ${{ fromJson(needs.fingerprint_repo.outputs.fingerprint) }}
45+
steps:
46+
- name: Clone repository
47+
uses: actions/checkout@v4
48+
- name: Run Contrast SCA Audit
49+
uses: Contrast-Security-OSS/contrast-sca-action@v3
50+
with:
51+
apiKey: ${{ secrets.CONTRAST_GITHUB_APP_API_KEY }}
52+
authHeader: ${{ secrets.CONTRAST_GITHUB_APP_AUTH_HEADER }}
53+
orgId: ${{ vars.CONTRAST_GITHUB_APP_ORG_ID }}
54+
apiUrl: ${{ vars.CONTRAST_GITHUB_APP_TS_URL }}
55+
filePath: ${{ matrix.manifest.filePath }}
56+
repositoryId: ${{ matrix.manifest.repositoryId }}
57+
projectGroupId: ${{ matrix.manifest.projectGroupId }}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,27 @@ public List<ApplicationData> getActiveApplications(String app_name) throws IOExc
248248
throw new IOException("Failed to list applications: " + e.getMessage(), e);
249249
}
250250
}
251+
252+
253+
@Tool(name = "list_all_applications", description = "Takes no argument and list all the applications")
254+
public List<ApplicationData> getActiveApplications() throws IOException {
255+
logger.info("Listing all applications");
256+
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
257+
try {
258+
List<Application> applications = contrastSDK.getApplications(orgID).getApplications();
259+
logger.debug("Retrieved {} total applications from Contrast", applications.size());
260+
261+
List<ApplicationData> ReturnedApps = new ArrayList<>();
262+
for(Application app : applications) {
263+
ReturnedApps.add(new ApplicationData(app.getName(), app.getStatus(), app.getId()));
264+
}
265+
266+
logger.info("Found {} applications matching'", ReturnedApps.size());
267+
return ReturnedApps;
268+
269+
} catch (Exception e) {
270+
logger.error("Error listing all applications", e);
271+
throw new IOException("Failed to list applications: " + e.getMessage(), e);
272+
}
273+
}
251274
}

0 commit comments

Comments
 (0)