Skip to content

Commit 3251539

Browse files
authored
Merge pull request #4 from git-stunts/feature/docker-guard-package
Feature/docker-guard-package
2 parents 7719ce1 + 7b0face commit 3251539

10 files changed

Lines changed: 117 additions & 59 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased] - 2026-01-08
9+
10+
### Added
11+
- **Shared Docker Guard**: Added `@git-stunts/docker-guard` with `isDockerEnvironment`/`ensureDocker`, exported banner text, and injectable logger/exit hooks so every repo can reuse the same safety net.
12+
### Changed
13+
- **Plumbing Guard Wiring**: `@git-stunts/plumbing` now imports the shared guard via `test/support/ensure-docker.js`, `vitest.config.js`, and `test/deno_entry.js`, removing the in-repo Minecraft `src/infrastructure/DockerGuard.js`.
14+
15+
## [2.8.0] - 2026-01-07
16+
17+
### Added
18+
- **DockerGuard**: Introduced a critical safety service (`src/infrastructure/DockerGuard.js`) that prevents execution on the host machine to protect against unintended system modifications.
19+
- **Dockerized Workflow**: Added `Dockerfile.node`, `Dockerfile.bun`, `Dockerfile.deno`, and `docker-compose.yml` to standardize isolated testing environments.
20+
21+
### Changed
22+
- **Command Whitelist Expansion**: Added `log` to the `CommandSanitizer` allowed list to support high-performance graph traversals.
23+
- **Strict Host Enforcement**: Updated `package.json` with a `pretest` script that enforces the `GIT_STUNTS_DOCKER` environment variable.
24+
825
## [2.7.0] - 2026-01-07
926

1027
### Added

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ A low-level, robust, and environment-agnostic Git plumbing library for the moder
2020
- **OOM Protection**: Integrated safety buffering (`GitStream.collect`) with configurable byte limits.
2121
- **Dockerized CI**: Parallel test execution across all runtimes using isolated containers.
2222

23+
## 🛡️ Safety First: Docker Execution
24+
25+
This library performs low-level Git manipulations. To protect your host system and ensure a reproducible environment, **execution on the host is strictly prohibited.**
26+
27+
All tests and commands should be run inside the provided Docker containers:
28+
29+
```bash
30+
docker-compose run --rm node-test
31+
```
32+
33+
The system will automatically fail if `GIT_STUNTS_DOCKER=1` is not set.
34+
35+
We load `@git-stunts/docker-guard` (v0.1.0+) before every suite (`test/support/ensure-docker.js`), so invoking `ensureDocker()` happens automatically for Vitest/Bun/Deno. You can copy the same pattern in other packages:
36+
37+
```javascript
38+
import { ensureDocker } from '@git-stunts/docker-guard';
39+
40+
ensureDocker();
41+
```
42+
2343
## 🏗️ Design Principles
2444

2545
1. **Git as a Subsystem**: Git is treated as an external, untrusted dependency. Every command and environment variable is sanitized.

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ services:
55
dockerfile: Dockerfile.node
66
environment:
77
- NODE_ENV=test
8+
- GIT_STUNTS_DOCKER=1
89

910
bun-test:
1011
build:
1112
context: .
1213
dockerfile: Dockerfile.bun
14+
environment:
15+
- GIT_STUNTS_DOCKER=1
1316

1417
deno-test:
1518
build:
1619
context: .
1720
dockerfile: Dockerfile.deno
21+
environment:
22+
- GIT_STUNTS_DOCKER=1

package-lock.json

Lines changed: 36 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"@eslint/js": "^9.17.0",
3636
"eslint": "^9.17.0",
3737
"prettier": "^3.4.2",
38-
"vitest": "^3.0.0"
38+
"vitest": "^3.0.0",
39+
"@git-stunts/docker-guard": "^0.1.0"
3940
},
4041
"files": [
4142
"src",
@@ -51,8 +52,22 @@
5152
"NOTICE",
5253
"SECURITY.md"
5354
],
54-
"repository": { "type": "git", "url": "git+https://github.com/git-stunts/plumbing.git" },
55+
"repository": {
56+
"type": "git",
57+
"url": "git+https://github.com/git-stunts/plumbing.git"
58+
},
5559
"homepage": "https://github.com/git-stunts/plumbing#readme",
56-
"bugs": { "url": "https://github.com/git-stunts/plumbing/issues" },
57-
"keywords": ["git", "plumbing", "content-addressable", "dag", "merkle", "node", "deno", "bun"]
58-
}
60+
"bugs": {
61+
"url": "https://github.com/git-stunts/plumbing/issues"
62+
},
63+
"keywords": [
64+
"git",
65+
"plumbing",
66+
"content-addressable",
67+
"dag",
68+
"merkle",
69+
"node",
70+
"deno",
71+
"bun"
72+
]
73+
}

src/domain/services/CommandSanitizer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export default class CommandSanitizer {
4242
'check-ignore',
4343
'check-attr',
4444
'init',
45-
'config'
45+
'config',
46+
'log'
4647
]);
4748

4849
/**

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
* @fileoverview Integration tests for GitPlumbing
33
*/
44

5+
import { ensureDocker } from '@git-stunts/docker-guard';
6+
7+
ensureDocker();
8+
9+
import './test/deno_shim.js';
510
import { mkdtempSync, rmSync } from 'node:fs';
611
import path from 'node:path';
712
import os from 'node:os';

test/deno_entry.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./support/ensure-docker.js";
12
import "./deno_shim.js";
23

34
// Import all tests to run them in one Deno process with the shim
@@ -21,4 +22,4 @@ import "./domain/services/GitCommandBuilder.test.js";
2122
import "./domain/services/GitErrorClassifier.test.js";
2223
import "./domain/services/GitPersistenceService.test.js";
2324
import "./domain/value-objects/GitFileMode.test.js";
24-
import "./domain/value-objects/GitObjectType.test.js";
25+
import "./domain/value-objects/GitObjectType.test.js";

test/support/ensure-docker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ensureDocker } from '@git-stunts/docker-guard';
2+
3+
ensureDocker();

vitest.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
setupFiles: ['test/support/ensure-docker.js']
6+
}
7+
});

0 commit comments

Comments
 (0)