-
Notifications
You must be signed in to change notification settings - Fork 0
API caller for AquaSec full repository scan #89
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
Changes from 11 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
cc490bf
Test of AquaSec API
tmikula-dev 345b1af
Test of AquaSec API
tmikula-dev 10807d7
Test of AquaSec API
tmikula-dev 66f5c89
AquaSec workflow fix
tmikula-dev 77f0e24
AquaSec workflow fix
tmikula-dev 2713be6
AquaSec workflow fix
tmikula-dev 8330826
AquaSec workflow fix
tmikula-dev 8d1b523
AquaSec workflow fix
tmikula-dev 371f052
AquaSec Scan update
tmikula-dev 057d3f8
AquaSec Scan update
tmikula-dev 0d3ff0e
AquaSec Scan update
tmikula-dev c099d52
AquaSec Scan update
tmikula-dev 445a2d4
AquaSec Scan update
tmikula-dev a661cb0
AquaSec Scan update
tmikula-dev e55896e
Merge branch 'refs/heads/master' into feature/78-API-caller-for-AquaS…
tmikula-dev f92d2d6
Fetching aquasec scan data logic + converting logic from json to sari…
tmikula-dev 0ec7cec
Scan summary table for GH comment logic
tmikula-dev 2a60d75
Bug fix
tmikula-dev 02a236b
Bug fix
tmikula-dev 61cc54f
Revert "Bug fix"
tmikula-dev b383bce
Bug fix
tmikula-dev 9ebfc65
Code rabbit suggestions implemented
tmikula-dev a692286
Generated comment bug fixes
tmikula-dev 0d9ddf0
Letting fingerprint logic on GH side
tmikula-dev a9aca29
Deleting obsolete trivy solution from the project
tmikula-dev aa38c44
Merge branch 'master' into feature/78-API-caller-for-AquaSec-scan
tmikula-dev 7a580f0
Reacting on the comments to implement SHA into the workflows
tmikula-dev bf05a69
Deleting the debugging dev script.
tmikula-dev 74da4b1
bug fix
tmikula-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: AquaSec Full Repository Scan | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| types: [ opened, synchronize ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
| security-events: write | ||
|
|
||
| jobs: | ||
| aquasec: | ||
| name: AquaSec Full Repository Scan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Retrieve AquaSec Scan Results | ||
| env: | ||
| AQUA_KEY: ${{ secrets.AQUA_KEY }} | ||
| AQUA_SECRET: ${{ secrets.AQUA_SECRET }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| echo "=== Authenticating with AquaSec ===" | ||
|
|
||
| METHOD="POST" | ||
| AUTH_ENDPOINT="https://eu-1.api.cloudsploit.com/v2/tokens" | ||
| TIMESTAMP=$(date -u +%s) | ||
| POST_BODY='{ | ||
| "group_id": 1155, | ||
| "allowed_endpoints": ["GET", "POST"], | ||
| "validity": 240, | ||
| "csp_roles": ["developer", "devops"] | ||
| }' | ||
| STRING_TO_SIGN="${TIMESTAMP}${METHOD}/v2/tokens${POST_BODY}" | ||
| SIGNATURE=$(echo -n "$STRING_TO_SIGN" | openssl dgst -sha256 -hmac "$AQUA_SECRET" -hex | sed 's/.*= //g') | ||
|
|
||
|
|
||
| AUTH_RESPONSE=$(curl -s -X "$METHOD" "$AUTH_ENDPOINT" \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "X-API-Key: $AQUA_KEY" \ | ||
| -H "X-Signature: $SIGNATURE" \ | ||
| -H "X-Timestamp: $TIMESTAMP" \ | ||
| -d "$POST_BODY") | ||
|
|
||
| RESPONSE_STATUS=$(echo "$AUTH_RESPONSE" | jq -r '.status') | ||
|
|
||
| if [ "$RESPONSE_STATUS" = "200" ]; then | ||
| echo "Login successful." | ||
| BEARER_TOKEN=$(echo "$AUTH_RESPONSE" | jq -r '.data') | ||
| echo "::add-mask::$BEARER_TOKEN" | ||
| else | ||
| echo "Login failed" | ||
| exit 1 | ||
| fi | ||
tmikula-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| echo "=== Receiving AquaSec Scan Results ===" | ||
|
|
||
| SCAN_RESULTS_ENDPOINT="https://eu-central-1.edge.cloud.aquasec.com/codesec/api/v1/scans/results" | ||
| SCAN_RESULTS=$(curl -s -X GET \ | ||
| "$SCAN_RESULTS_ENDPOINT?repositoryIds=${{ github.repository_id }} \ | ||
| -H "Authorization: Bearer $BEARER_TOKEN" \ | ||
| -H "Accept: application/json") | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if [ -z "$SCAN_RESULTS" ]; then | ||
| echo "Failed to retrieve scan results" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "=== Scan Results ===" | ||
| echo "$SCAN_RESULTS" | jq '.' | ||
tmikula-dev marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.