Skip to content

Commit d729ab2

Browse files
chore: update BDBA token rotation schedule to every twelve weeks (#55)
On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com> <!-- markdownlint-disable MD041 --> #### What this PR does / why we need it update BDBA token rotation schedule to every twelve weeks --------- Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com> Co-authored-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
1 parent 5ae4532 commit d729ab2

File tree

2 files changed

+8
-39
lines changed

2 files changed

+8
-39
lines changed

.github/workflows/bdba.yaml

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ on:
1919
required: true
2020
BDBA_GROUP_ID:
2121
required: true
22-
BDBA_USERNAME:
23-
required: true
24-
BDBA_PASSWORD:
25-
required: true
2622

2723
permissions:
2824
actions: read
@@ -40,41 +36,14 @@ jobs:
4036
repository: open-component-model/ocm
4137
ref: main
4238

43-
# Generate new API token for BDB using the BDBA API
44-
- name: Generate new BDBA API token
45-
id: generate-bdba-token
46-
run: |
47-
# Generate new token from the Black Duck Binary Analysis API
48-
# Using the validity period of 86400 seconds (1 day)
49-
RESPONSE=$(curl -s -X PUT \
50-
-H "Content-Type: application/json" \
51-
-u "${{ secrets.BDBA_USERNAME }}:${{ secrets.BDBA_PASSWORD }}" \
52-
-d '{"validity": 86400}' \
53-
"https://bdba.tools.sap/api/key/")
54-
55-
# Extract token from response
56-
TOKEN=$(echo "$RESPONSE" | jq -r '.key.value')
57-
58-
# Verify token was generated successfully
59-
if [ -z "$TOKEN" ] || [ "$TOKEN" = "null" ]; then
60-
echo "Failed to generate new token. API response: $RESPONSE"
61-
exit 1
62-
fi
63-
64-
# Store token as step output
65-
echo "::add-mask::$TOKEN"
66-
echo "bdba_token=$TOKEN" >> "$GITHUB_OUTPUT"
67-
68-
echo "Successfully generated new BDBA API token"
69-
7039
# Download the CTF that has been uploaded from release workflow
7140
- name: Download CTF
7241
uses: actions/download-artifact@v4
7342
with:
7443
pattern: '${{ inputs.artifact_id }}'
7544
path: ${{ github.workspace }}/gen
7645

77-
# Since OCM cli is required to download CVs from CTF extract binary from CTF
46+
# Since OCM cli is required to download CVs from CTF, extract binary from CTF
7847
- name: Extract OCM Binary from CTF
7948
id: extract-ocm
8049
run: |
@@ -121,7 +90,7 @@ jobs:
12190
12291
# Upload the file using curl
12392
echo "Uploading $upload_name to BDBA"
124-
curl_output=$(curl -sS -X PUT -H "Authorization: Bearer ${{ steps.generate-bdba-token.outputs.bdba_token }}" -H "Group: ${{ secrets.BDBA_GROUP_ID }}" -H "Version: $version" -H "Delete-Binary: true" --data-binary "@$file" "$api_url")
93+
curl_output=$(curl -sS -X PUT -H "Authorization: Bearer ${{ secrets.BDBA_API_TOKEN }}" -H "Group: ${{ secrets.BDBA_GROUP_ID }}" -H "Version: $version" -H "Delete-Binary: true" --data-binary "@$file" "$api_url")
12594
12695
# Check if upload was successful and print results
12796
if [[ $(echo "$curl_output" | jq '.meta.code') == "200" ]]; then

.github/workflows/rotate-bdba-token.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ name: BDBA Token Rotation
44

55
on:
66
schedule:
7-
# Run on first of every month at 0:37 AM UTC
8-
- cron: '37 0 1 * *'
7+
- cron: '37 2 1 * *' # Run on every 1st of month 2:37 AM UTC
98
workflow_dispatch: # Allow manual trigger
109

1110
jobs:
@@ -22,16 +21,17 @@ jobs:
2221
- name: Checkout repository
2322
uses: actions/checkout@v4
2423

25-
# Generate new API token using the BDBA API
24+
# Generate new API token using the BDBA API
2625
- name: Generate new BDBA API token
2726
id: generate-bdba-token
27+
if: ${{ env.SHOULD_RUN == 'true' }}
2828
run: |
2929
# Generate new token from the Black Duck Binary Analysis API
30-
# Using the validity period of 3888000 seconds (45 days)
30+
# Using the validity period of 7257600 seconds (84 days / 12 weeks)
3131
RESPONSE=$(curl -s -X PUT \
3232
-H "Content-Type: application/json" \
33-
-u "${{ secrets.BDBA_USERNAME }}:${{ secrets.BDBA_PASSWORD }}" \
34-
-d '{"validity": 3888000}' \
33+
-H "Authorization: Bearer ${{ secrets.BDBA_API_TOKEN }}" \
34+
-d '{"validity": 7257600}' \
3535
"https://bdba.tools.sap/api/key/")
3636
3737
# Extract token from response

0 commit comments

Comments
 (0)