Skip to content

Commit b9915a4

Browse files
authored
RUST-1920 Annotate sarif report with mongodb ratings (#1134)
1 parent 9660ea8 commit b9915a4

File tree

5 files changed

+24
-15
lines changed

5 files changed

+24
-15
lines changed

.evergreen/check-semgrep.sh

100644100755
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,29 @@
22

33
set -o errexit
44

5-
source ./.evergreen/env.sh
6-
7-
. ${DRIVERS_TOOLS}/.evergreen/find-python3.sh
8-
PYTHON=$(find_python3)
5+
if [ -t 0 ] ; then
6+
# Interactive shell
7+
PYTHON3=${PYTHON3:-"python3"}
8+
else
9+
# Evergreen run (probably)
10+
source ./.evergreen/env.sh
11+
source ${DRIVERS_TOOLS}/.evergreen/find-python3.sh
12+
PYTHON3=$(find_python3)
13+
fi
914

1015
if [[ -f "semgrep/bin/activate" ]]; then
11-
echo 'using existing virtualenv'
16+
echo 'Using existing virtualenv...'
1217
. semgrep/bin/activate
1318
else
14-
echo 'Creating new virtualenv'
15-
${PYTHON} -m venv semgrep
16-
echo 'Activating new virtualenv'
19+
echo 'Creating new virtualenv...'
20+
${PYTHON3} -m venv semgrep
21+
echo 'Activating new virtualenv...'
1722
. semgrep/bin/activate
23+
echo 'Installing semgrep...'
1824
python3 -m pip install semgrep
1925
fi
2026

27+
# Show human-readable output
28+
semgrep --config p/rust --error
2129
# Generate a SARIF report
22-
semgrep --config p/rust --sarif > mongo-rust-driver.json.sarif
23-
# And human-readable output
24-
semgrep --config p/rust --error
30+
semgrep --config p/rust --quiet --sarif -o sarif.json

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ Cargo.lock
1212
# we install cargo and rustup in the project directory on Evergreen.
1313
.cargo
1414
.rustup
15-
mongocryptd.pid
15+
mongocryptd.pid
16+
semgrep/
17+
sarif.json

.semgrepignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
benchmarks/
2-
src/test/
2+
src/test/
3+
etc/

src/client/auth/scram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl ScramVersion {
317317
let normalized_password = match self {
318318
ScramVersion::Sha1 => {
319319
// nosemgrep: insecure-hashes
320-
let mut md5 = Md5::new();
320+
let mut md5 = Md5::new(); // mongodb rating: No Fix Needed
321321
md5.update(format!("{}:mongo:{}", username, password));
322322
Cow::Owned(hex::encode(md5.finalize()))
323323
}

src/runtime/tls_rustls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn make_rustls_config(cfg: TlsOptions) -> Result<rustls::ClientConfig> {
143143

144144
if let Some(true) = cfg.allow_invalid_certificates {
145145
// nosemgrep: rustls-dangerous
146-
config
146+
config // mongodb rating: No Fix Needed
147147
.dangerous()
148148
.set_certificate_verifier(Arc::new(NoCertVerifier {}));
149149
}

0 commit comments

Comments
 (0)