Skip to content

Commit 53f9fec

Browse files
authored
CDRIVER-5904 update scripts and release instructions for SilkBomb 2.0 (#1882)
* Remove create-silk-asset-group and related references * Remove Earthly sbom-download * Update Earthly sbom-generate for SilkBomb 2.0 * Add Earthly sbom-validate and sbom-generate-new-serial-number * Add SBOM task to EVG config
1 parent e5bc5a8 commit 53f9fec

File tree

11 files changed

+287
-440
lines changed

11 files changed

+287
-440
lines changed

.evergreen/config_generator/components/misc.py

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
from config_generator.etc.distros import find_small_distro
2+
from config_generator.etc.function import Function, merge_defns
3+
from config_generator.etc.utils import bash_exec
4+
5+
from shrub.v3.evg_build_variant import BuildVariant
6+
from shrub.v3.evg_command import BuiltInCommand, EvgCommandType, expansions_update, s3_put
7+
from shrub.v3.evg_task import EvgTask, EvgTaskRef
8+
9+
from pydantic import ConfigDict
10+
from typing import Optional
11+
12+
13+
TAG = 'sbom'
14+
15+
16+
class CustomCommand(BuiltInCommand):
17+
command: str
18+
model_config = ConfigDict(arbitrary_types_allowed=True)
19+
20+
21+
def ec2_assume_role(
22+
role_arn: Optional[str] = None,
23+
policy: Optional[str] = None,
24+
duration_seconds: Optional[int] = None,
25+
command_type: Optional[EvgCommandType] = None,
26+
) -> CustomCommand:
27+
return CustomCommand(
28+
command="ec2.assume_role",
29+
params={
30+
"role_arn": role_arn,
31+
"policy": policy,
32+
"duration_seconds": duration_seconds,
33+
},
34+
type=command_type,
35+
)
36+
37+
38+
class SBOM(Function):
39+
name = 'sbom'
40+
commands = [
41+
ec2_assume_role(
42+
command_type=EvgCommandType.SETUP,
43+
role_arn='${kondukto_role_arn}',
44+
),
45+
bash_exec(
46+
command_type=EvgCommandType.SETUP,
47+
include_expansions_in_env=[
48+
'AWS_ACCESS_KEY_ID',
49+
'AWS_SECRET_ACCESS_KEY',
50+
'AWS_SESSION_TOKEN',
51+
],
52+
script='''\
53+
set -o errexit
54+
set -o pipefail
55+
kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)"
56+
printf "KONDUKTO_TOKEN: %s\\n" "$kondukto_token" >|expansions.kondukto.yml
57+
''',
58+
),
59+
expansions_update(
60+
command_type=EvgCommandType.SETUP,
61+
file='expansions.kondukto.yml',
62+
),
63+
bash_exec(
64+
command_type=EvgCommandType.TEST,
65+
working_dir='mongoc',
66+
include_expansions_in_env=[
67+
'artifactory_password',
68+
'artifactory_username',
69+
'branch_name',
70+
'KONDUKTO_TOKEN',
71+
],
72+
script='.evergreen/scripts/sbom.sh',
73+
),
74+
s3_put(
75+
command_type=EvgCommandType.TEST,
76+
aws_key='${aws_key}',
77+
aws_secret='${aws_secret}',
78+
bucket='mciuploads',
79+
content_type='application/json',
80+
display_name='Augmented SBOM',
81+
local_file='mongoc/augmented-sbom.json',
82+
permissions='public-read',
83+
remote_file='${project}/${build_variant}/${revision}/${version_id}/${build_id}/sbom/augmented-sbom.json',
84+
),
85+
]
86+
87+
@classmethod
88+
def call(cls, **kwargs):
89+
return cls.default_call(**kwargs)
90+
91+
92+
def functions():
93+
return merge_defns(
94+
SBOM.defn(),
95+
)
96+
97+
98+
def tasks():
99+
distro_name = 'rhel80'
100+
distro = find_small_distro(distro_name)
101+
102+
yield EvgTask(
103+
name='sbom',
104+
tags=[TAG, distro_name],
105+
run_on=distro.name,
106+
commands=[
107+
SBOM.call(),
108+
],
109+
)
110+
111+
112+
def variants():
113+
return [
114+
BuildVariant(
115+
name=TAG,
116+
display_name='SBOM',
117+
tasks=[EvgTaskRef(name=f'.{TAG}')],
118+
),
119+
]

.evergreen/generated_configs/functions.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,54 @@ functions:
499499
args:
500500
- -c
501501
- .evergreen/scripts/compile.sh
502+
sbom:
503+
- command: ec2.assume_role
504+
type: setup
505+
params:
506+
role_arn: ${kondukto_role_arn}
507+
- command: subprocess.exec
508+
type: setup
509+
params:
510+
binary: bash
511+
include_expansions_in_env:
512+
- AWS_ACCESS_KEY_ID
513+
- AWS_SECRET_ACCESS_KEY
514+
- AWS_SESSION_TOKEN
515+
args:
516+
- -c
517+
- |
518+
set -o errexit
519+
set -o pipefail
520+
kondukto_token="$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)"
521+
printf "KONDUKTO_TOKEN: %s\n" "$kondukto_token" >|expansions.kondukto.yml
522+
- command: expansions.update
523+
type: setup
524+
params:
525+
file: expansions.kondukto.yml
526+
- command: subprocess.exec
527+
type: test
528+
params:
529+
binary: bash
530+
working_dir: mongoc
531+
include_expansions_in_env:
532+
- artifactory_password
533+
- artifactory_username
534+
- branch_name
535+
- KONDUKTO_TOKEN
536+
args:
537+
- -c
538+
- .evergreen/scripts/sbom.sh
539+
- command: s3.put
540+
type: test
541+
params:
542+
display_name: Augmented SBOM
543+
aws_key: ${aws_key}
544+
aws_secret: ${aws_secret}
545+
bucket: mciuploads
546+
content_type: application/json
547+
local_file: mongoc/augmented-sbom.json
548+
permissions: public-read
549+
remote_file: ${project}/${build_variant}/${revision}/${version_id}/${build_id}/sbom/augmented-sbom.json
502550
scan-build:
503551
- command: subprocess.exec
504552
type: test

.evergreen/generated_configs/tasks.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,27 +1410,6 @@ tasks:
14101410
tags: [clang-format]
14111411
commands:
14121412
- func: clang-format
1413-
- name: create-silk-asset-group
1414-
run_on:
1415-
- ubuntu2204-large
1416-
- debian10-large
1417-
- debian11-large
1418-
- amazon2
1419-
tags: [misc, pr-merge-gate]
1420-
commands:
1421-
- command: subprocess.exec
1422-
type: setup
1423-
params:
1424-
binary: ./tools/earthly.sh
1425-
working_dir: mongoc
1426-
env:
1427-
SILK_CLIENT_ID: ${silk_client_id}
1428-
SILK_CLIENT_SECRET: ${silk_client_secret}
1429-
args:
1430-
- --secret=SILK_CLIENT_ID
1431-
- --secret=SILK_CLIENT_SECRET
1432-
- +create-silk-asset-group
1433-
- --branch=${branch_name}
14341413
- name: cse-sasl-cyrus-darwinssl-macos-11-arm64-clang-compile
14351414
run_on: macos-11-arm64
14361415
tags: [cse-matrix-darwinssl, compile, macos-11-arm64, clang, cse, sasl-cyrus]
@@ -4934,6 +4913,11 @@ tasks:
49344913
- func: bootstrap-mongo-orchestration
49354914
- func: run-simple-http-server
49364915
- func: run-tests
4916+
- name: sbom
4917+
run_on: rhel80-small
4918+
tags: [sbom, rhel80]
4919+
commands:
4920+
- func: sbom
49374921
- name: scan-build-macos-14-arm64-clang
49384922
run_on: macos-14-arm64
49394923
tags: [scan-build-matrix, macos-14-arm64, clang]

.evergreen/generated_configs/variants.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ buildvariants:
174174
display_name: loadbalanced
175175
tasks:
176176
- name: .loadbalanced
177-
- name: misc
178-
display_name: Miscellaneous
179-
tasks:
180-
- name: .misc
181177
- name: mock-server-test
182178
display_name: Mock Server Test
183179
expansions:
@@ -282,6 +278,10 @@ buildvariants:
282278
expansions: {}
283279
tasks:
284280
- name: .sasl-matrix-winssl
281+
- name: sbom
282+
display_name: SBOM
283+
tasks:
284+
- name: .sbom
285285
- name: scan-build-matrix
286286
display_name: scan-build-matrix
287287
tasks:

.evergreen/scripts/sbom.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit
4+
set -o pipefail
5+
6+
: "${artifactory_username:?}"
7+
: "${artifactory_password:?}"
8+
: "${branch_name:?}"
9+
: "${KONDUKTO_TOKEN:?}"
10+
11+
command -v podman >/dev/null || {
12+
echo "missing required program podman" 1>&2
13+
exit 1
14+
}
15+
16+
podman login --password-stdin --username "${artifactory_username:?}" artifactory.corp.mongodb.com <<<"${artifactory_password:?}"
17+
18+
silkbomb="artifactory.corp.mongodb.com/release-tools-container-registry-public-local/silkbomb:2.0"
19+
20+
# Ensure latest version of SilkBomb is being used.
21+
podman pull "${silkbomb:?}"
22+
23+
silkbomb_augment_flags=(
24+
--repo mongodb/mongo-c-driver
25+
--branch "${branch_name:?}"
26+
--sbom-in /pwd/etc/cyclonedx.sbom.json
27+
--sbom-out /pwd/augmented-sbom.json
28+
29+
# Any notable updates to the Augmented SBOM version should be done manually after careful inspection.
30+
# Otherwise, it should be equal to the SBOM Lite version, which should normally be `1`.
31+
--no-update-sbom-version
32+
)
33+
34+
# First validate the SBOM Lite.
35+
podman run -it --rm -v "$(pwd):/pwd" "${silkbomb:?}" \
36+
validate --purls /pwd/etc/purls.txt --sbom-in /pwd/etc/cyclonedx.sbom.json --exclude jira
37+
38+
# Then download the Augmented SBOM. Allow the timestamp to be updated.
39+
podman run -it --rm -v "$(pwd):/pwd" --env 'KONDUKTO_TOKEN' "${silkbomb:?}" \
40+
augment "${silkbomb_augment_flags[@]:?}"
41+
42+
[[ -f ./augmented-sbom.json ]] || {
43+
echo "failed to download Augmented SBOM" 1>&2
44+
exit 1
45+
}

0 commit comments

Comments
 (0)