pi-landstrip 0.11.3 → 0.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.ts +22 -22
  2. package/package.json +1 -1
  3. package/sandbox.json +6 -46
package/index.ts CHANGED
@@ -116,28 +116,14 @@ const DEFAULT_CONFIG: SandboxConfig = {
116
116
  allowLocalBinding: false,
117
117
  allowAllUnixSockets: false,
118
118
  allowUnixSockets: [],
119
- allowedDomains: [
120
- 'npmjs.org',
121
- '*.npmjs.org',
122
- 'registry.npmjs.org',
123
- 'registry.yarnpkg.com',
124
- 'pypi.org',
125
- '*.pypi.org',
126
- 'github.com',
127
- '*.github.com',
128
- 'api.github.com',
129
- 'raw.githubusercontent.com',
130
- 'crates.io',
131
- '*.crates.io',
132
- 'static.crates.io',
133
- ],
119
+ allowedDomains: [],
134
120
  deniedDomains: [],
135
121
  },
136
122
  filesystem: {
137
123
  denyRead: ['/Users', '/home'],
138
- allowRead: ['.', '~/.config', '~/.gitconfig', '~/.local', '~/.cargo', '/dev/null'],
139
- allowWrite: ['.', '/tmp', '/dev/null'],
140
- denyWrite: ['.env', '.env.*', '*.pem', '*.key'],
124
+ allowRead: ['.', '~/.gitconfig', '/dev/null'],
125
+ allowWrite: ['.', '/dev/null'],
126
+ denyWrite: ['**/.env', '**/.env.*', '**/*.pem', '**/*.key'],
141
127
  },
142
128
  };
143
129
 
@@ -196,16 +182,30 @@ function loadConfig(cwd: string): SandboxConfig {
196
182
  return deepMerge(deepMerge(DEFAULT_CONFIG, globalConfig), projectConfig);
197
183
  }
198
184
 
185
+ function mergeArray(base: string[], override?: string[]): string[] {
186
+ if (!override) return base;
187
+ return [...new Set([...base, ...override])];
188
+ }
189
+
199
190
  function deepMerge(base: SandboxConfig, overrides: Partial<SandboxConfig>): SandboxConfig {
191
+ const network = overrides.network;
192
+ const filesystem = overrides.filesystem;
193
+
200
194
  return {
201
195
  enabled: overrides.enabled ?? base.enabled,
202
196
  network: {
203
- ...base.network,
204
- ...overrides.network,
197
+ allowNetwork: network?.allowNetwork ?? base.network.allowNetwork,
198
+ allowLocalBinding: network?.allowLocalBinding ?? base.network.allowLocalBinding,
199
+ allowAllUnixSockets: network?.allowAllUnixSockets ?? base.network.allowAllUnixSockets,
200
+ allowUnixSockets: mergeArray(base.network.allowUnixSockets, network?.allowUnixSockets),
201
+ allowedDomains: mergeArray(base.network.allowedDomains, network?.allowedDomains),
202
+ deniedDomains: mergeArray(base.network.deniedDomains, network?.deniedDomains),
205
203
  },
206
204
  filesystem: {
207
- ...base.filesystem,
208
- ...overrides.filesystem,
205
+ denyRead: mergeArray(base.filesystem.denyRead, filesystem?.denyRead),
206
+ allowRead: mergeArray(base.filesystem.allowRead, filesystem?.allowRead),
207
+ allowWrite: mergeArray(base.filesystem.allowWrite, filesystem?.allowWrite),
208
+ denyWrite: mergeArray(base.filesystem.denyWrite, filesystem?.denyWrite),
209
209
  },
210
210
  };
211
211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-landstrip",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
4
4
  "description": "Landlock-based sandboxing for pi with interactive permission prompts",
5
5
  "keywords": [
6
6
  "landstrip",
package/sandbox.json CHANGED
@@ -2,56 +2,16 @@
2
2
  "enabled": true,
3
3
  "network": {
4
4
  "allowNetwork": false,
5
- "allowLocalBinding": true,
5
+ "allowLocalBinding": false,
6
6
  "allowAllUnixSockets": false,
7
7
  "allowUnixSockets": [],
8
- "allowedDomains": [
9
- "github.com",
10
- "*.github.com",
11
- "api.github.com",
12
- "raw.githubusercontent.com",
13
- "objects.githubusercontent.com",
14
- "codeload.github.com",
15
- "registry.npmjs.org",
16
- "npmjs.org",
17
- "*.npmjs.org",
18
- "nodejs.org",
19
- "*.nodejs.org",
20
- "crates.io",
21
- "*.crates.io",
22
- "static.crates.io"
23
- ],
8
+ "allowedDomains": [],
24
9
  "deniedDomains": []
25
10
  },
26
11
  "filesystem": {
27
- "denyRead": ["/home"],
28
- "allowRead": [
29
- ".",
30
- "/tmp",
31
- "/var/tmp",
32
- "/dev/null",
33
- "~/.config",
34
- "~/.gitconfig",
35
- "~/.local",
36
- "~/.cargo",
37
- "~/.rustup",
38
- "~/.npm",
39
- "~/.cache",
40
- "~/.bun",
41
- "~/.node-gyp"
42
- ],
43
- "allowWrite": [
44
- ".",
45
- "/tmp",
46
- "/var/tmp",
47
- "/dev/null",
48
- "~/.cargo",
49
- "~/.rustup",
50
- "~/.npm",
51
- "~/.cache",
52
- "~/.bun",
53
- "~/.node-gyp"
54
- ],
55
- "denyWrite": [".env", ".env.*", "*.pem", "*.key"]
12
+ "denyRead": ["/Users", "/home"],
13
+ "allowRead": [".", "~/.gitconfig", "/dev/null"],
14
+ "allowWrite": [".", "/dev/null"],
15
+ "denyWrite": ["**/.env", "**/.env.*", "**/*.pem", "**/*.key"]
56
16
  }
57
17
  }