Skip to content

Commit ee15682

Browse files
authored
RUST-1925 SSDLC compliance for libmongocrypt Rust binding (#29)
1 parent 2aede9b commit ee15682

File tree

9 files changed

+121
-1
lines changed

9 files changed

+121
-1
lines changed

.evergreen/check-semgrep.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
source ./.evergreen/configure-rust.sh
6+
7+
. ${DRIVERS_TOOLS}/.evergreen/find-python3.sh
8+
PYTHON=$(find_python3)
9+
10+
if [[ -f "semgrep/bin/activate" ]]; then
11+
echo 'using existing virtualenv'
12+
. semgrep/bin/activate
13+
else
14+
echo 'Creating new virtualenv'
15+
${PYTHON} -m venv semgrep
16+
echo 'Activating new virtualenv'
17+
. semgrep/bin/activate
18+
python3 -m pip install semgrep
19+
fi
20+
21+
OPTS="--config p/rust --exclude-rule rust.lang.security.unsafe-usage.unsafe-usage"
22+
23+
# Generate a SARIF report
24+
semgrep ${OPTS} --sarif > mongo-rust-libmongocrypt.json.sarif
25+
# And human-readable output
26+
semgrep ${OPTS} --error

.evergreen/config.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pre:
3131
export PROJECT_DIRECTORY="$(pwd)"
3232
export MONGOCRYPT_LIB_DIR="$PROJECT_DIRECTORY/native/${libmongocrypt_os}/lib"
3333
export LD_LIBRARY_PATH="$MONGOCRYPT_LIB_DIR:$LD_LIBRARY_PATH"
34+
export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
3435
3536
cat <<EOT > expansion.yml
3637
PREPARE_SHELL: |
@@ -39,6 +40,7 @@ pre:
3940
export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
4041
export MONGOCRYPT_LIB_DIR="$MONGOCRYPT_LIB_DIR"
4142
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
43+
export DRIVERS_TOOLS="$DRIVERS_TOOLS"
4244
EOT
4345
cat expansion.yml
4446
- command: expansions.update
@@ -109,6 +111,16 @@ tasks:
109111
${PREPARE_SHELL}
110112
.evergreen/run-valgrind.sh
111113
114+
- name: "semgrep"
115+
commands:
116+
- command: shell.exec
117+
type: test
118+
params:
119+
working_dir: "src"
120+
script: |
121+
${PREPARE_SHELL}
122+
.evergreen/check-semgrep.sh
123+
112124
buildvariants:
113125
- name: ubuntu
114126
display_name: "Ubuntu 18.04"
@@ -119,6 +131,7 @@ buildvariants:
119131
- name: ".compile"
120132
- name: ".test"
121133
- name: "valgrind"
134+
- name: "semgrep"
122135
- name: macos
123136
display_name: "MacOS 10.14"
124137
run_on: macos-1014

.evergreen/install-dependencies.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ tar xzf libmongocrypt-all.tar.gz
3333

3434
if [ "Windows_NT" == "$OS" ]; then
3535
chmod +x ${MONGOCRYPT_LIB_DIR}/../bin/*.dll
36-
fi
36+
fi
37+
38+
## drivers-tools
39+
40+
if [[ -z "$DRIVERS_TOOLS" ]]; then
41+
echo >&2 "\$DRIVERS_TOOLS must be set"
42+
exit 1
43+
fi
44+
45+
rm -rf $DRIVERS_TOOLS
46+
git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS

.evergreen/sign-release.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set +x
5+
6+
if [[ -z "$CRATE" ]]; then
7+
echo >&2 "CRATE is required"
8+
exit 1
9+
fi
10+
if [[ -z "$ARTIFACTORY_PASSWORD" ]]; then
11+
echo >&2 "ARTIFACTORY_PASSWORD is required"
12+
exit 1
13+
fi
14+
if [[ -z "$ARTIFACTORY_USERNAME" ]]; then
15+
echo >&2 "ARTIFACTORY_USERNAME is required"
16+
exit 1
17+
fi
18+
if [[ -z "$GARASIGN_USERNAME" ]]; then
19+
echo >&2 "GARASIGN_USERNAME is required"
20+
exit 1
21+
fi
22+
if [[ -z "$GARASIGN_PASSWORD" ]]; then
23+
echo >&2 "GARASIGN_PASSWORD is required"
24+
exit 1
25+
fi
26+
27+
CRATE_VERSION=$(cargo metadata --format-version=1 --no-deps | jq --raw-output '.packages[0].version')
28+
29+
echo "${ARTIFACTORY_PASSWORD}" | docker login --password-stdin --username ${ARTIFACTORY_USERNAME} artifactory.corp.mongodb.com
30+
31+
echo "GRS_CONFIG_USER1_USERNAME=${GARASIGN_USERNAME}" >> "signing-envfile"
32+
echo "GRS_CONFIG_USER1_PASSWORD=${GARASIGN_PASSWORD}" >> "signing-envfile"
33+
34+
docker run \
35+
--env-file=signing-envfile \
36+
--rm \
37+
-v $(pwd):$(pwd) \
38+
-w $(pwd) \
39+
artifactory.corp.mongodb.com/release-tools-container-registry-local/garasign-gpg \
40+
/bin/bash -c "gpgloader && gpg --yes -v --armor -o ${CRATE}-${CRATE_VERSION}.sig --detach-sign target/package/${CRATE}-${CRATE_VERSION}.crate"
41+
42+
rm signing-envfile

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
semgrep
2+
mongo-rust-libmongocrypt.json.sarif
3+
.rustup
4+
.cargo

RELEASING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ New versions of both the `mongocrypt-sys` and `mongocrypt` crates can be release
99

1010
VERSION=<version to be published> \
1111
TOKEN=<crates.io auth token> \
12+
ARTIFACTORY_USERNAME=<artifactory username> \
13+
ARTIFACTORY_PASSWORD=<artifactory password> \
14+
GARASIGN_USERNAME=<garasign username> \
15+
GARASIGN_PASSWORD=<garasign password> \
1216
CRATE=<mongocrypt | mongocrypt-sys> \
1317
./publish.sh
1418

mongocrypt-sys/sbom.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"serialNumber": "urn:uuid:8eec5dde-14e8-49de-bb5d-a7a9613098f5",
3+
"version": 1,
4+
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
5+
"bomFormat": "CycloneDX",
6+
"specVersion": "1.5",
7+
"metadata": {
8+
"timestamp": "2024-05-01T15:43:13Z"
9+
}
10+
}

mongocrypt/sbom.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"serialNumber": "urn:uuid:ac436a86-72bd-487e-89ba-7e0f224d8026",
3+
"version": 1,
4+
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
5+
"bomFormat": "CycloneDX",
6+
"specVersion": "1.5",
7+
"metadata": {
8+
"timestamp": "2024-05-01T15:43:13Z"
9+
}
10+
}

publish.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ git checkout $CRATE-$VERSION
2424

2525
cd $CRATE
2626
cargo publish --token $TOKEN "$@"
27+
$(dirname $0).evergreen/sign-release.sh
2728

2829
git checkout main

0 commit comments

Comments
 (0)