Skip to content

Commit b6ebbde

Browse files
authored
chore(ci): label security tests and generate summary report MONGOSH-1787 (#2030)
1 parent 7867b39 commit b6ebbde

File tree

12 files changed

+180
-0
lines changed

12 files changed

+180
-0
lines changed

.github/workflows/cron-tasks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ jobs:
6666
git add .evergreen.yml
6767
git commit --no-allow-empty -m "chore: update evergreen config" || true
6868
69+
- name: Update Security Test Summary
70+
run: |
71+
npm run update-security-test-summary
72+
git add docs/security-test-summary.md
73+
git commit --no-allow-empty -m "chore: update security test summary" || true
74+
6975
- name: Regenerate CLI usage text in README files
7076
run: |
7177
npm run update-cli-usage-text packages/*/*.md *.md

docs/security-test-summary.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# MongoDB Shell Security Testing Summary
2+
3+
This document lists specific instances of security-relevant testing that is being
4+
performed for the MongoDB Shell. All parts of the MongoDB Shell source code
5+
are subject to integration and unit testing on every change made to the project,
6+
including the specific instances listed below.
7+
8+
# Security Tests
9+
10+
## Loading the MongoDB `crypt_shared` library securely
11+
12+
mongosh loads the `crypt_shared` MongoDB library at runtime. In order to do so securely,
13+
we verify that the path resolution logic used for it adheres to expectations, and e.g.
14+
the shared library will not be loaded if it comes with incorrect filesystem permissions.
15+
16+
<!-- Source File: `packages/cli-repl/src/crypt-library-paths.spec.ts` -->
17+
18+
19+
## Authentication End-to-End Tests
20+
21+
While mongosh is a client-side application and therefore, in many cases not responsible
22+
for correct authentication, we still consider any failure in our authentication tests
23+
a potential warning sign for security-relevant impact.
24+
25+
<!-- Source File: `packages/e2e-tests/test/e2e-auth.spec.ts` -->
26+
27+
28+
## OIDC Authentication End-to-End Tests
29+
30+
In addition to our regular tests for the different authentication mechanisms supported
31+
by MongoDB, we give special consideration to our OpenID Connect database authentication
32+
feature, as it involves client applications performing actions based on directions
33+
received from the database server.
34+
35+
Additional, since the shell supports connections to multiple different endpoints in the
36+
same application, these tests ensure that OIDC authentication for distinct endpoints
37+
happens in isolation.
38+
39+
<!-- Source File: `packages/e2e-tests/test/e2e-oidc.spec.ts` -->
40+
41+
42+
## TLS End-to-End Tests
43+
44+
Our TLS tests verify that core security properties of TLS connections
45+
are applied appropriately for mongosh, in particular certificate validation
46+
and compliance with user-specified behavior that is specific to TLS connectivity.
47+
48+
<!-- Source File: `packages/e2e-tests/test/e2e-tls.spec.ts` -->
49+
50+
51+
## Shell History Redaction Tests
52+
53+
The MongoDB Shell redacts items from the shell history file when it detects
54+
potentially sensitive information in them. Our tests verify this behavior.
55+
56+
<!-- Source File: `packages/history/src/history.spec.ts` -->
57+

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"update-node-js-versions": "npx @pkgjs/nv ls v20 > .evergreen/node-20-latest.json && npx @pkgjs/nv ls v16 > .evergreen/node-16-latest.json",
5555
"update-evergreen-config": "npm run test-evergreen-expansions && node .evergreen/generate-evergreen-yml.js .evergreen/evergreen.yml.in > .evergreen.yml",
5656
"update-cli-usage-text": "node scripts/update-cli-usage-text.js",
57+
"update-security-test-summary": "ts-node scripts/generate-security-test-summary.ts > docs/security-test-summary.md",
5758
"mark-ci-required-optional-dependencies": "ts-node scripts/mark-ci-required-optional-dependencies.ts",
5859
"write-node-js-dep": "node scripts/write-nodejs-dep > .sbom/node-js-dep.json",
5960
"scan-node-js": "mongodb-sbom-tools scan-node-js --version=$NODE_JS_VERSION > .sbom/node-js-vuln.json",

packages/cli-repl/src/crypt-library-paths.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import { EventEmitter } from 'events';
1010
import { promises as fs } from 'fs';
1111
import path from 'path';
1212

13+
/**
14+
* @securityTest Loading the MongoDB `crypt_shared` library securely
15+
*
16+
* mongosh loads the `crypt_shared` MongoDB library at runtime. In order to do so securely,
17+
* we verify that the path resolution logic used for it adheres to expectations, and e.g.
18+
* the shared library will not be loaded if it comes with incorrect filesystem permissions.
19+
*/
1320
describe('getCryptLibraryPaths', function () {
1421
let bus: MongoshBus;
1522
let events: any[];

packages/e2e-tests/test/e2e-auth.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ function createAssertUserAuth(
8484
};
8585
}
8686

87+
/**
88+
* @securityTest Authentication End-to-End Tests
89+
*
90+
* While mongosh is a client-side application and therefore, in many cases not responsible
91+
* for correct authentication, we still consider any failure in our authentication tests
92+
* a potential warning sign for security-relevant impact.
93+
*/
8794
describe('Auth e2e', function () {
8895
skipIfApiStrict(); // connectionStatus is unversioned.
8996

packages/e2e-tests/test/e2e-oidc.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ import { expect } from 'chai';
1212
import { createServer as createHTTPSServer } from 'https';
1313
import { getCertPath, useTmpdir } from './repl-helpers';
1414

15+
/**
16+
* @securityTest OIDC Authentication End-to-End Tests
17+
*
18+
* In addition to our regular tests for the different authentication mechanisms supported
19+
* by MongoDB, we give special consideration to our OpenID Connect database authentication
20+
* feature, as it involves client applications performing actions based on directions
21+
* received from the database server.
22+
*
23+
* Additionally, since the shell supports connections to multiple different endpoints in the
24+
* same application, these tests ensure that OIDC authentication for distinct endpoints
25+
* happens in isolation.
26+
*/
1527
describe('OIDC auth e2e', function () {
1628
skipIfApiStrict(); // connectionStatus is unversioned.
1729

packages/e2e-tests/test/e2e-tls.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const SERVER_KEY = getCertPath('server.bundle.pem');
3838
const SERVER_INVALIDHOST_KEY = getCertPath('server-invalidhost.bundle.pem');
3939
const CRL_INCLUDING_SERVER = getCertPath('ca-server.crl');
4040

41+
/**
42+
* @securityTest TLS End-to-End Tests
43+
*
44+
* Our TLS tests verify that core security properties of TLS connections
45+
* are applied appropriately for mongosh, in particular certificate validation
46+
* and compliance with user-specified behavior that is specific to TLS connectivity.
47+
*/
4148
describe('e2e TLS', function () {
4249
let homedir: string;
4350
let env: Record<string, string>;

packages/e2e-tests/test/e2e.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,7 @@ describe('e2e', function () {
15301530
expect((await fs.stat(historyPath)).mode & 0o077).to.equal(0);
15311531
});
15321532

1533+
// Security-relevant test -- description covered `history` package tests.
15331534
it('redacts secrets', async function () {
15341535
await shell.executeLine('db.auth("myusername", "mypassword")');
15351536
await shell.executeLine('a = 42');

packages/history/src/history.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { changeHistory } from './history';
22
import { expect } from 'chai';
33

4+
/**
5+
* @securityTest Shell History Redaction Tests
6+
*
7+
* The MongoDB Shell redacts items from the shell history file when it detects
8+
* potentially sensitive information in them. Our tests verify this behavior.
9+
*/
410
describe('changeHistory', function () {
511
const history = ['db.shipwrecks.findOne()', 'use ships'];
612

packages/service-provider-server/src/cli-service-provider.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ describe('CliServiceProvider', function () {
10081008
});
10091009
});
10101010

1011+
// Security-relevant tests -- description covered in e2e-oidc tests.
10111012
describe('processDriverOptions', function () {
10121013
it('shares user configuration options from an existing CliServiceProvider instance', function () {
10131014
const cloneableOidcOptions = {

0 commit comments

Comments
 (0)