-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-5904 update scripts and release instructions for SilkBomb 2.0 #1882
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 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
61f36f2
Remove create-silk-asset-group and related references
eramongodb 038c6c2
Update Earthly sbom-generate for SilkBomb 2.0
eramongodb 3cc9c0a
Add Earthly sbom-validate
eramongodb 43cd03c
Remove Earthly sbom-download
eramongodb 4d49baa
Add SBOM task to EVG config
eramongodb 06fdcaf
Remove obsolete `ARG --required sbom_branch`
eramongodb 3ccd3e3
Remove unnecessary FROM alpine:3.20
eramongodb 6e0fe23
Reuse wording for instructions to download an augmented SBOM
eramongodb 91ded68
Remove unnecessary check for jq
eramongodb 5bf1b53
Add Earthly sbom-generate-new-serial-number
eramongodb b6e1dac
Fix dev documentation syntax errors and broken references
eramongodb b51b47e
Additional backticks in releasing.rst
eramongodb 3caf834
Remove language implying automation and asynchrony for augmented SBOM…
eramongodb 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 was deleted.
Oops, something went wrong.
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,119 @@ | ||
from config_generator.etc.distros import find_small_distro | ||
from config_generator.etc.function import Function, merge_defns | ||
from config_generator.etc.utils import bash_exec | ||
|
||
from shrub.v3.evg_build_variant import BuildVariant | ||
from shrub.v3.evg_command import BuiltInCommand, EvgCommandType, expansions_update, s3_put | ||
from shrub.v3.evg_task import EvgTask, EvgTaskRef | ||
|
||
from pydantic import ConfigDict | ||
from typing import Optional | ||
|
||
|
||
TAG = 'sbom' | ||
|
||
|
||
class CustomCommand(BuiltInCommand): | ||
command: str | ||
model_config = ConfigDict(arbitrary_types_allowed=True) | ||
|
||
|
||
def ec2_assume_role( | ||
role_arn: Optional[str] = None, | ||
policy: Optional[str] = None, | ||
duration_seconds: Optional[int] = None, | ||
command_type: Optional[EvgCommandType] = None, | ||
) -> CustomCommand: | ||
return CustomCommand( | ||
command="ec2.assume_role", | ||
params={ | ||
"role_arn": role_arn, | ||
"policy": policy, | ||
"duration_seconds": duration_seconds, | ||
}, | ||
type=command_type, | ||
) | ||
|
||
|
||
class SBOM(Function): | ||
name = 'sbom' | ||
commands = [ | ||
ec2_assume_role( | ||
command_type=EvgCommandType.SETUP, | ||
role_arn='${kondukto_role_arn}', | ||
), | ||
bash_exec( | ||
command_type=EvgCommandType.SETUP, | ||
include_expansions_in_env=[ | ||
'AWS_ACCESS_KEY_ID', | ||
'AWS_SECRET_ACCESS_KEY', | ||
'AWS_SESSION_TOKEN', | ||
], | ||
script='''\ | ||
set -o errexit | ||
set -o pipefail | ||
kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)" | ||
printf "KONDUKTO_TOKEN: %s\\n" "$kondukto_token" >|expansions.kondukto.yml | ||
''', | ||
), | ||
expansions_update( | ||
command_type=EvgCommandType.SETUP, | ||
file='expansions.kondukto.yml', | ||
), | ||
bash_exec( | ||
command_type=EvgCommandType.TEST, | ||
working_dir='mongoc', | ||
include_expansions_in_env=[ | ||
'artifactory_password', | ||
'artifactory_username', | ||
'branch_name', | ||
'KONDUKTO_TOKEN', | ||
], | ||
script='.evergreen/scripts/sbom.sh', | ||
), | ||
s3_put( | ||
command_type=EvgCommandType.TEST, | ||
aws_key='${aws_key}', | ||
aws_secret='${aws_secret}', | ||
bucket='mciuploads', | ||
content_type='application/json', | ||
display_name='Augmented SBOM', | ||
local_file='mongoc/augmented-sbom.json', | ||
permissions='public-read', | ||
remote_file='${project}/${build_variant}/${revision}/${version_id}/${build_id}/sbom/augmented-sbom.json', | ||
), | ||
] | ||
|
||
@classmethod | ||
def call(cls, **kwargs): | ||
return cls.default_call(**kwargs) | ||
|
||
|
||
def functions(): | ||
return merge_defns( | ||
SBOM.defn(), | ||
) | ||
|
||
|
||
def tasks(): | ||
distro_name = 'rhel80' | ||
distro = find_small_distro(distro_name) | ||
|
||
yield EvgTask( | ||
name='sbom', | ||
tags=[TAG, distro_name], | ||
run_on=distro.name, | ||
commands=[ | ||
SBOM.call(), | ||
], | ||
) | ||
|
||
|
||
def variants(): | ||
return [ | ||
BuildVariant( | ||
name=TAG, | ||
display_name='SBOM', | ||
tasks=[EvgTaskRef(name=f'.{TAG}')], | ||
), | ||
] |
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
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
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be moved to an |
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,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
: "${artifactory_username:?}" | ||
: "${artifactory_password:?}" | ||
: "${branch_name:?}" | ||
: "${KONDUKTO_TOKEN:?}" | ||
|
||
command -v podman >/dev/null || { | ||
echo "missing required program podman" 1>&2 | ||
exit 1 | ||
} | ||
|
||
podman login --password-stdin --username "${artifactory_username:?}" artifactory.corp.mongodb.com <<<"${artifactory_password:?}" | ||
|
||
silkbomb="artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:2.0" | ||
|
||
# Ensure latest version of SilkBomb is being used. | ||
podman pull "${silkbomb:?}" | ||
|
||
silkbomb_augment_flags=( | ||
--repo mongodb/mongo-c-driver | ||
--branch "${branch_name:?}" | ||
--sbom-in /pwd/etc/cyclonedx.sbom.json | ||
--sbom-out /pwd/augmented-sbom.json | ||
|
||
# Any notable updates to the Augmented SBOM version should be done manually after careful inspection. | ||
# Otherwise, it should be equal to the SBOM Lite version, which should normally be `1`. | ||
--no-update-sbom-version | ||
) | ||
|
||
# First validate the SBOM Lite. | ||
podman run -it --rm -v "$(pwd):/pwd" "${silkbomb:?}" \ | ||
validate --purls /pwd/etc/purls.txt --sbom-in /pwd/etc/cyclonedx.sbom.json --exclude jira | ||
|
||
# Then download the Augmented SBOM. Allow the timestamp to be updated. | ||
podman run -it --rm -v "$(pwd):/pwd" --env 'KONDUKTO_TOKEN' "${silkbomb:?}" \ | ||
augment "${silkbomb_augment_flags[@]:?}" | ||
|
||
[[ -f ./augmented-sbom.json ]] || { | ||
echo "failed to download Augmented SBOM" 1>&2 | ||
exit 1 | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that silk asset groups are no longer required with Silkbomb 2?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. The
--repo
and--branch
flags are now sufficient to associate uploaded/augmented SBOMs with a given project and branch. Asset group management is no longer necessary. 👏