-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MONGOCRYPT-680 Create Silk asset group in release (#813)
* add `--branch` argument to `sbom-download` target Since an Augmented SBOM is required for every release, this is intended to keep a separate Silk asset group for a release branch. * add steps to create Silk asset group on a minor release
- Loading branch information
Showing
3 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o pipefail | ||
set -o nounset | ||
|
||
# Check for required commands: | ||
if ! command -v jq > /dev/null 2>&1; then | ||
echo "jq not found. Install jq" | ||
exit 1 | ||
fi | ||
|
||
if ! command -v curl > /dev/null 2>&1; then | ||
echo "curl not found. Install curl" | ||
exit 1 | ||
fi | ||
|
||
# Check for required environment variables: | ||
: "${silk_client_id:?}" | ||
: "${silk_client_secret:?}" | ||
: "${branch:?}" | ||
|
||
# Get Silk token: | ||
json_payload=$(cat <<EOF | ||
{ | ||
"client_id": "${silk_client_id}", | ||
"client_secret": "${silk_client_secret}" | ||
} | ||
EOF | ||
) | ||
silk_jwt_token=$(curl -s -X POST "https://silkapi.us1.app.silk.security/api/v1/authenticate" \ | ||
-H "Accept: application/json" \ | ||
-H "Content-Type: application/json" \ | ||
-d "$json_payload" \ | ||
| jq -r '.token') | ||
|
||
asset_id="libmongocrypt-${branch}" | ||
|
||
# Create Silk asset group: | ||
json_payload=$(cat <<EOF | ||
{ | ||
"active": true, | ||
"name": "libmongocrypt", | ||
"code_repo_url": "https://github.com/mongodb/libmongocrypt", | ||
"branch": "${branch}", | ||
"metadata": { | ||
"sbom_lite_path": "etc/cyclonedx.sbom.json" | ||
}, | ||
"file_paths": [], | ||
"asset_id": "${asset_id}" | ||
} | ||
EOF | ||
) | ||
reply=$(curl --silent -X 'POST' \ | ||
'https://silkapi.us1.app.silk.security/api/v1/raw/asset_group' \ | ||
-H "Accept: application/json" \ | ||
-H "Authorization: ${silk_jwt_token}" \ | ||
-H 'Content-Type: application/json' \ | ||
-d "$json_payload") | ||
|
||
if silkid=$(echo "$reply" | jq ".silk_id"); then | ||
echo "Created silk asset group with asset_id=$asset_id and silk_id=$silkid" | ||
else | ||
echo "Reply does not contain expected 'silk_id': $reply" | ||
exit 1 | ||
fi | ||
|