codex-overleaf-link 1.9.0 → 1.9.2
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.
- package/README.md +30 -30
- package/extension/bootstrap/manifest.template.json +1 -1
- package/extension/src/content/contentRuntime.js +10 -8
- package/extension/src/content/runTimelineView.js +7 -2
- package/extension/src/shared/agentTranscript.js +18 -4
- package/extension/src/shared/compatibility.js +1 -1
- package/native-host/src/codexSessionRunner.js +52 -9
- package/native-host/src/mirrorWorkspace.js +45 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<h1>Codex Overleaf Link</h1>
|
|
4
4
|
<p><strong>Empower Overleaf with Codex.</strong></p>
|
|
5
5
|
<p>
|
|
6
|
-
<img src="https://img.shields.io/badge/version-1.9.
|
|
6
|
+
<img src="https://img.shields.io/badge/version-1.9.2-blue" alt="version">
|
|
7
7
|
<img src="https://img.shields.io/badge/platform-macOS%20%2F%20Windows%20%2F%20Linux-lightgrey" alt="platform">
|
|
8
8
|
<img src="https://img.shields.io/badge/chrome-MV3-green" alt="chrome manifest v3">
|
|
9
9
|
<img src="https://img.shields.io/badge/node-%3E%3D20-brightgreen" alt="node version">
|
|
@@ -33,33 +33,33 @@ Either way, the final **Load unpacked** click is manual — Chrome does not let
|
|
|
33
33
|
|
|
34
34
|
### Option A — installer script (recommended)
|
|
35
35
|
|
|
36
|
-
One command installs the native host **and**
|
|
36
|
+
One command installs the managed native host **and** managed extension runtime. On macOS/Linux it also creates the visible `~/Codex Overleaf Link Extension` shortcut pointing to the managed extension, copies that path to your clipboard, and opens `chrome://extensions` for you. Future signed stable updates target this same managed directory.
|
|
37
37
|
|
|
38
38
|
macOS / Linux:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
CODEX_OVERLEAF_REF=v1.9.
|
|
41
|
+
CODEX_OVERLEAF_REF=v1.9.2 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.2/install.sh)"
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
Windows PowerShell:
|
|
45
45
|
|
|
46
46
|
```powershell
|
|
47
|
-
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.
|
|
48
|
-
$env:CODEX_OVERLEAF_REF='v1.9.
|
|
47
|
+
iwr https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.2/install.ps1 -OutFile install.ps1
|
|
48
|
+
$env:CODEX_OVERLEAF_REF='v1.9.2'
|
|
49
49
|
powershell -ExecutionPolicy Bypass -File install.ps1
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
Then, in the `chrome://extensions` tab the script opened: enable **Developer mode**, click **Load unpacked**, and choose the prepared extension folder (its path is already on your clipboard). That is the only manual step.
|
|
53
53
|
|
|
54
|
-
### Option B — npm
|
|
54
|
+
### Option B — npm managed install
|
|
55
55
|
|
|
56
|
-
`npm exec` installs
|
|
56
|
+
`npm exec` installs the same managed native host and extension runtime without keeping a source checkout. Use it if you prefer a pinned npm package.
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
59
|
+
npm exec --yes codex-overleaf-link@1.9.2 -- install-managed
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Then
|
|
62
|
+
Then, in `chrome://extensions`, enable **Developer mode**, click **Load unpacked**, and select the managed extension path printed by the command. The Release extension zip remains available for explicitly unmanaged/manual installations.
|
|
63
63
|
|
|
64
64
|
### Open Overleaf
|
|
65
65
|
|
|
@@ -80,31 +80,31 @@ Then load `extension/` as an unpacked extension in Chrome. If Chrome assigns a d
|
|
|
80
80
|
|
|
81
81
|
</details>
|
|
82
82
|
|
|
83
|
-
## npm
|
|
83
|
+
## npm Managed CLI
|
|
84
84
|
|
|
85
|
-
npm installs, updates,
|
|
85
|
+
npm installs, updates, and uninstalls the coordinated managed extension/native pair. Diagnostics still target the native host. The legacy `install-native` command remains available only for explicitly unmanaged extension directories.
|
|
86
86
|
|
|
87
87
|
| Action | Command |
|
|
88
88
|
|--------|---------|
|
|
89
|
-
| Install / update | `npm exec --yes codex-overleaf-link@1.9.
|
|
90
|
-
| Diagnose | `npm exec --yes codex-overleaf-link@1.9.
|
|
91
|
-
| Uninstall | `npm exec --yes codex-overleaf-link@1.9.
|
|
89
|
+
| Install / update | `npm exec --yes codex-overleaf-link@1.9.2 -- install-managed` |
|
|
90
|
+
| Diagnose | `npm exec --yes codex-overleaf-link@1.9.2 -- doctor` |
|
|
91
|
+
| Uninstall | `npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-managed` |
|
|
92
92
|
|
|
93
93
|
Use `--extension-id <chrome-extension-id>` only for a custom/dev unpacked extension id that differs from the official bundled id.
|
|
94
94
|
|
|
95
95
|
## Update
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
Managed installations discover signed stable updates automatically and apply them only while all Overleaf tabs and the native host are idle. Re-run `install-managed` only for recovery or migration, including when the panel reports **Native host update required**. Explicitly unmanaged installations still require a manual extension/native update. After recovery, reload the extension in `chrome://extensions` and refresh Overleaf.
|
|
98
98
|
|
|
99
99
|
## GitHub Release Artifacts
|
|
100
100
|
|
|
101
|
-
The v1.9.
|
|
101
|
+
The v1.9.2 GitHub Release contains:
|
|
102
102
|
|
|
103
|
-
- `codex-overleaf-link-extension-v1.9.
|
|
104
|
-
- `codex-overleaf-native-host-v1.9.
|
|
105
|
-
- `codex-overleaf-link-1.9.
|
|
106
|
-
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v1.9.
|
|
107
|
-
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.
|
|
103
|
+
- `codex-overleaf-link-extension-v1.9.2.zip`: loadable Chrome extension package for manual unpacked installation.
|
|
104
|
+
- `codex-overleaf-native-host-v1.9.2.tar.gz`: native host runtime files used by the installer and release verification.
|
|
105
|
+
- `codex-overleaf-link-1.9.2.tgz`: npm native host CLI package for pinned install, doctor, and uninstall flows.
|
|
106
|
+
- `install.sh`: release-pinned macOS / Linux installer that defaults to `v1.9.2` when run directly from the release artifact.
|
|
107
|
+
- `install.ps1`: release-pinned Windows PowerShell installer that defaults to `v1.9.2` when run directly from the release artifact.
|
|
108
108
|
- `uninstall-native-host.mjs`: native host uninstaller that removes the Chrome Native Messaging manifest, bridge executable, and runtime copy.
|
|
109
109
|
- `nativeHostPlatform.js`, `manifest.js`, `runtimeInstaller.js`: helper files required by the loose uninstaller asset.
|
|
110
110
|
- `SHA256SUMS` and `release-manifest.json`: checksum and artifact metadata for release verification.
|
|
@@ -115,7 +115,7 @@ The v1.9.0 GitHub Release contains:
|
|
|
115
115
|
Remove the native host (use `--browser chromium` on Linux Chromium):
|
|
116
116
|
|
|
117
117
|
```bash
|
|
118
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
118
|
+
npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-managed
|
|
119
119
|
```
|
|
120
120
|
|
|
121
121
|
The same command works on Windows PowerShell. If you installed from a manual checkout or source installer, you can also run `npm run uninstall:native` inside the repo, use `node ~/.codex-overleaf/source/scripts/uninstall-native-host.mjs` on macOS / Linux, or use `node $env:LOCALAPPDATA\CodexOverleaf\source\scripts\uninstall-native-host.mjs` on Windows PowerShell.
|
|
@@ -150,13 +150,13 @@ Then remove the extension from `chrome://extensions`. To delete local data: on m
|
|
|
150
150
|
Linux Chromium install or update:
|
|
151
151
|
|
|
152
152
|
```bash
|
|
153
|
-
CODEX_OVERLEAF_REF=v1.9.
|
|
153
|
+
CODEX_OVERLEAF_REF=v1.9.2 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Ghqqqq/codex-overleaf-link/v1.9.2/install.sh)" -- --browser chromium
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
Linux Chromium uninstall:
|
|
157
157
|
|
|
158
158
|
```bash
|
|
159
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
159
|
+
npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-managed --browser chromium
|
|
160
160
|
```
|
|
161
161
|
|
|
162
162
|
## Features
|
|
@@ -291,7 +291,7 @@ Composer attachments are turn-scoped Codex context. Limits are 8 attachments per
|
|
|
291
291
|
Re-run any [native host installer](#install), reload the extension in `chrome://extensions`, then refresh the Overleaf tab. This also fixes extension/native version mismatch and native protocol mismatch.
|
|
292
292
|
|
|
293
293
|
```bash
|
|
294
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
294
|
+
npm exec --yes codex-overleaf-link@1.9.2 -- install-managed
|
|
295
295
|
```
|
|
296
296
|
|
|
297
297
|
**The Windows popup or panel shows a Bash recovery command**
|
|
@@ -340,8 +340,8 @@ Use this matrix for release-candidate signoff and compatibility reports. Record
|
|
|
340
340
|
| Browser/channel/version | Google Chrome channel and version. | Google Chrome channel and version. | Google Chrome channel and version. | Chromium channel/package and version. |
|
|
341
341
|
| Install mode | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout. | Manual unpacked extension from GitHub Release zip or checkout; native host installed with `--browser chromium`. |
|
|
342
342
|
| Extension id | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. | Bundled id `illdpneeeopfffmiepaejglgmhpmdhdc`, or actual custom id passed with `--extension-id`. |
|
|
343
|
-
| Installer/update command | `npm exec --yes codex-overleaf-link@1.9.
|
|
344
|
-
| Uninstall command | `npm exec --yes codex-overleaf-link@1.9.
|
|
343
|
+
| Installer/update command | `npm exec --yes codex-overleaf-link@1.9.2 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.2 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.2 -- install-managed` | `npm exec --yes codex-overleaf-link@1.9.2 -- install-managed --browser chromium` |
|
|
344
|
+
| Uninstall command | `npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-managed` | `npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-managed --browser chromium` |
|
|
345
345
|
| Manifest/registry path | `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/com.codex.overleaf.json` | `HKCU\Software\Google\Chrome\NativeMessagingHosts\com.codex.overleaf` -> `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime\com.codex.overleaf.json` | `~/.config/google-chrome/NativeMessagingHosts/com.codex.overleaf.json` | `~/.config/chromium/NativeMessagingHosts/com.codex.overleaf.json` |
|
|
346
346
|
| Bridge/runtime/source path | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `%LOCALAPPDATA%\CodexOverleaf\codex-overleaf-bridge.cmd`; runtime `%LOCALAPPDATA%\CodexOverleaf\native-host-runtime`; source `%LOCALAPPDATA%\CodexOverleaf\source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. | Bridge `~/.codex-overleaf/codex-overleaf-bridge`; runtime `~/.codex-overleaf/native-host-runtime`; source `~/.codex-overleaf/source`. |
|
|
347
347
|
| Node/Git/Codex/TeX | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. | Node.js >= 20; Git; Codex CLI installed and logged in; TeX optional. |
|
|
@@ -377,7 +377,7 @@ Contributions are welcome. Please open an issue before submitting large changes
|
|
|
377
377
|
The recommended v1.9 installation owns one stable unpacked-extension directory and a versioned native-host directory:
|
|
378
378
|
|
|
379
379
|
```bash
|
|
380
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
380
|
+
npm exec --yes codex-overleaf-link@1.9.2 -- install-managed
|
|
381
381
|
```
|
|
382
382
|
|
|
383
383
|
Load the printed extension path once from `chrome://extensions`. Starting with the next signed stable release, Codex Overleaf Link checks GitHub Releases automatically, downloads and verifies the coordinated extension/native-host bundle, waits until every connected Overleaf tab is saved and idle, and then updates both components together. A failed health check restores the previous version automatically.
|
|
@@ -387,11 +387,11 @@ The stable updater ignores drafts and prereleases, performs no telemetry, and ca
|
|
|
387
387
|
The legacy native-only installer remains available for source or unmanaged extension directories:
|
|
388
388
|
|
|
389
389
|
```bash
|
|
390
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
390
|
+
npm exec --yes codex-overleaf-link@1.9.2 -- install-native
|
|
391
391
|
```
|
|
392
392
|
|
|
393
393
|
Legacy native-only installations can be removed with:
|
|
394
394
|
|
|
395
395
|
```bash
|
|
396
|
-
npm exec --yes codex-overleaf-link@1.9.
|
|
396
|
+
npm exec --yes codex-overleaf-link@1.9.2 -- uninstall-native
|
|
397
397
|
```
|
|
@@ -88,11 +88,8 @@
|
|
|
88
88
|
buildSnapshotRestoreUndo,
|
|
89
89
|
buildUndoCheckpoint
|
|
90
90
|
} = window.CodexOverleafUndoOperations;
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
mapAgentEventToActivity,
|
|
94
|
-
translateRawError
|
|
95
|
-
} = window.CodexOverleafAgentTranscript;
|
|
91
|
+
const { buildHumanCompletionReport, mapAgentEventToActivity, stripEmptyHtmlCommentPlaceholders,
|
|
92
|
+
translateRawError } = window.CodexOverleafAgentTranscript;
|
|
96
93
|
const i18n = window.CodexOverleafI18n;
|
|
97
94
|
const nativeChannel = window.CodexOverleafNativeChannel.create({
|
|
98
95
|
chrome,
|
|
@@ -7040,19 +7037,24 @@
|
|
|
7040
7037
|
const existing = [...events].reverse().find(item => item.kind === 'stream' && item.streamKey === streamKey);
|
|
7041
7038
|
if (existing) {
|
|
7042
7039
|
const nextTitle = sanitizeAssistantVisibleText(event.title);
|
|
7043
|
-
|
|
7040
|
+
const nextRole = sanitizeAssistantVisibleText(event.streamRole) || existing.streamRole;
|
|
7041
|
+
const combinedTitle = event.replaceText
|
|
7044
7042
|
? nextTitle
|
|
7045
7043
|
: sanitizeAssistantVisibleText(appendStreamText(existing.title, nextTitle));
|
|
7044
|
+
existing.title = nextRole === 'reasoning' ? stripEmptyHtmlCommentPlaceholders(combinedTitle) : combinedTitle;
|
|
7046
7045
|
existing.status = sanitizeAssistantVisibleText(event.status) || existing.status || 'running';
|
|
7047
7046
|
existing.timestamp = event.timestamp || existing.timestamp;
|
|
7048
|
-
existing.streamRole =
|
|
7047
|
+
existing.streamRole = nextRole;
|
|
7049
7048
|
return existing;
|
|
7050
7049
|
}
|
|
7051
7050
|
|
|
7051
|
+
const streamRole = sanitizeAssistantVisibleText(event.streamRole);
|
|
7052
|
+
const title = sanitizeAssistantVisibleText(event.title);
|
|
7052
7053
|
const next = {
|
|
7053
7054
|
...event,
|
|
7054
7055
|
streamKey,
|
|
7055
|
-
|
|
7056
|
+
streamRole,
|
|
7057
|
+
title: streamRole === 'reasoning' ? stripEmptyHtmlCommentPlaceholders(title) : title
|
|
7056
7058
|
};
|
|
7057
7059
|
delete next.appendText;
|
|
7058
7060
|
delete next.replaceText;
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
renderMarkdownBlockText,
|
|
31
31
|
sanitizeAssistantVisibleText,
|
|
32
32
|
sanitizeAssistantVisibleValue,
|
|
33
|
+
stripEmptyHtmlCommentPlaceholders = value => value,
|
|
33
34
|
buildMarkdownInlineNodes,
|
|
34
35
|
getPanel,
|
|
35
36
|
getState,
|
|
@@ -504,14 +505,18 @@
|
|
|
504
505
|
}
|
|
505
506
|
|
|
506
507
|
function sanitizeRunEventForRender(event = {}) {
|
|
508
|
+
const streamRole = sanitizeAssistantVisibleText(event.streamRole);
|
|
509
|
+
const title = sanitizeAssistantVisibleText(event.title);
|
|
507
510
|
return {
|
|
508
511
|
...event,
|
|
509
|
-
title:
|
|
512
|
+
title: streamRole === 'reasoning'
|
|
513
|
+
? stripEmptyHtmlCommentPlaceholders(title)
|
|
514
|
+
: title,
|
|
510
515
|
status: sanitizeAssistantVisibleText(event.status),
|
|
511
516
|
detail: sanitizeAssistantVisibleValue(event.detail),
|
|
512
517
|
technicalDetail: sanitizeAssistantVisibleValue(event.technicalDetail),
|
|
513
518
|
streamKey: sanitizeAssistantVisibleText(event.streamKey),
|
|
514
|
-
streamRole
|
|
519
|
+
streamRole
|
|
515
520
|
};
|
|
516
521
|
}
|
|
517
522
|
function renderActivityLine(input) {
|
|
@@ -355,7 +355,10 @@
|
|
|
355
355
|
return mapThreadItemEvent(params.item, method === 'item/started', event, locale);
|
|
356
356
|
}
|
|
357
357
|
if (method === 'item/agentMessage/delta' || method === 'item/reasoning/summaryTextDelta') {
|
|
358
|
-
const title = cleanStreamDeltaText(
|
|
358
|
+
const title = cleanStreamDeltaText(
|
|
359
|
+
params.delta || '',
|
|
360
|
+
method === 'item/reasoning/summaryTextDelta'
|
|
361
|
+
);
|
|
359
362
|
if (!title.length) {
|
|
360
363
|
return technicalOnly(event, locale);
|
|
361
364
|
}
|
|
@@ -458,7 +461,7 @@
|
|
|
458
461
|
}
|
|
459
462
|
}
|
|
460
463
|
if (item.type === 'reasoning') {
|
|
461
|
-
const summary = normalizeStringList(item.summary).at(-1);
|
|
464
|
+
const summary = stripEmptyHtmlCommentPlaceholders(normalizeStringList(item.summary).at(-1));
|
|
462
465
|
if (!started && summary) {
|
|
463
466
|
return {
|
|
464
467
|
kind: 'stream',
|
|
@@ -1140,10 +1143,20 @@
|
|
|
1140
1143
|
return String(text || '').replace(/\s+/g, ' ').trim();
|
|
1141
1144
|
}
|
|
1142
1145
|
|
|
1143
|
-
function cleanStreamDeltaText(text) {
|
|
1144
|
-
|
|
1146
|
+
function cleanStreamDeltaText(text, stripReasoningPlaceholders = false) {
|
|
1147
|
+
const normalized = String(text || '')
|
|
1145
1148
|
.replace(/\r\n?/g, '\n')
|
|
1146
1149
|
.replace(/\u00a0/g, ' ');
|
|
1150
|
+
return stripReasoningPlaceholders
|
|
1151
|
+
? stripEmptyHtmlCommentPlaceholders(normalized)
|
|
1152
|
+
: normalized;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
function stripEmptyHtmlCommentPlaceholders(text) {
|
|
1156
|
+
return String(text || '')
|
|
1157
|
+
.replace(/<!--[\t \r\n]*-->/g, '')
|
|
1158
|
+
.replace(/(^|\n)[\t ]*<!--[\t ]*$/g, '$1')
|
|
1159
|
+
.replace(/(^|\n)[\t ]*-->[\t ]*$/g, '$1');
|
|
1147
1160
|
}
|
|
1148
1161
|
|
|
1149
1162
|
function cleanVisibleMarkdownText(text) {
|
|
@@ -1571,6 +1584,7 @@
|
|
|
1571
1584
|
formatFailureBlock,
|
|
1572
1585
|
formatHumanReport,
|
|
1573
1586
|
mapAgentEventToActivity,
|
|
1587
|
+
stripEmptyHtmlCommentPlaceholders,
|
|
1574
1588
|
translateRawError
|
|
1575
1589
|
};
|
|
1576
1590
|
});
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const MIN_NATIVE_VERSION = '1.0.0';
|
|
13
13
|
const MIN_COMPATIBLE_NATIVE_VERSION = '1.0.0';
|
|
14
14
|
const MIN_COMPATIBLE_EXTENSION_VERSION = '1.0.0';
|
|
15
|
-
const BUILD_TARGET_VERSION = '1.9.
|
|
15
|
+
const BUILD_TARGET_VERSION = '1.9.2';
|
|
16
16
|
const DEFAULT_CHROME_EXTENSION_ID = 'illdpneeeopfffmiepaejglgmhpmdhdc';
|
|
17
17
|
const REQUIRED_CAPABILITIES = Object.freeze([
|
|
18
18
|
'bridgePing',
|
|
@@ -1125,8 +1125,8 @@ function isAllowedLocalCommand(params = {}) {
|
|
|
1125
1125
|
}
|
|
1126
1126
|
|
|
1127
1127
|
const allowed = new Set([
|
|
1128
|
-
'rg', 'grep', 'cat', '
|
|
1129
|
-
'wc', 'diff', 'sort', 'tr', '
|
|
1128
|
+
'rg', 'grep', 'cat', 'head', 'tail', 'nl', 'find', 'ls',
|
|
1129
|
+
'wc', 'diff', 'sort', 'tr', 'printf', 'cut', 'uniq',
|
|
1130
1130
|
'stat', 'file', 'basename', 'dirname', 'realpath',
|
|
1131
1131
|
'shasum', 'md5', 'md5sum',
|
|
1132
1132
|
'latexmk', 'pdflatex', 'xelatex', 'lualatex', 'bibtex', 'biber',
|
|
@@ -1201,13 +1201,34 @@ function isUnsafeShellToken(token) {
|
|
|
1201
1201
|
function hasDisallowedCommandArguments(executable, args = []) {
|
|
1202
1202
|
const flags = args.map(String);
|
|
1203
1203
|
if (executable === 'find') {
|
|
1204
|
-
return flags.some(flag => [
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
}
|
|
1209
|
-
if (executable === '
|
|
1210
|
-
return flags.some(
|
|
1204
|
+
return flags.some(flag => [
|
|
1205
|
+
'-exec', '-execdir', '-delete', '-ok', '-okdir',
|
|
1206
|
+
'-fprint', '-fprint0', '-fprintf', '-fls'
|
|
1207
|
+
].includes(flag));
|
|
1208
|
+
}
|
|
1209
|
+
if (executable === 'rg') {
|
|
1210
|
+
return flags.some(flag => flag === '--pre' || flag.startsWith('--pre='));
|
|
1211
|
+
}
|
|
1212
|
+
if (executable === 'sort') {
|
|
1213
|
+
return flags.some(flag => flag === '-o'
|
|
1214
|
+
|| flag.startsWith('-o')
|
|
1215
|
+
|| flag === '--output'
|
|
1216
|
+
|| flag.startsWith('--output=')
|
|
1217
|
+
|| flag === '-T'
|
|
1218
|
+
|| flag.startsWith('-T')
|
|
1219
|
+
|| flag === '--temporary-directory'
|
|
1220
|
+
|| flag.startsWith('--temporary-directory='));
|
|
1221
|
+
}
|
|
1222
|
+
if (executable === 'latexmk') {
|
|
1223
|
+
return !flags.includes('-norc')
|
|
1224
|
+
|| flags.some(isUnsafeLatexmkArgument)
|
|
1225
|
+
|| flags.some(isUnsafeTexEngineArgument);
|
|
1226
|
+
}
|
|
1227
|
+
if (['pdflatex', 'xelatex', 'lualatex'].includes(executable)) {
|
|
1228
|
+
if (executable === 'lualatex' && !flags.some(flag => flag === '--safer' || flag === '-safer')) {
|
|
1229
|
+
return true;
|
|
1230
|
+
}
|
|
1231
|
+
return flags.some(isUnsafeTexEngineArgument);
|
|
1211
1232
|
}
|
|
1212
1233
|
if (executable === 'shasum' || executable === 'md5sum') {
|
|
1213
1234
|
return flags.some(flag => flag === '-c' || flag === '--check');
|
|
@@ -1215,6 +1236,28 @@ function hasDisallowedCommandArguments(executable, args = []) {
|
|
|
1215
1236
|
return false;
|
|
1216
1237
|
}
|
|
1217
1238
|
|
|
1239
|
+
function isUnsafeLatexmkArgument(value) {
|
|
1240
|
+
const flag = String(value || '').toLowerCase();
|
|
1241
|
+
return /^-(?:e|r)(?:$|=)/.test(flag)
|
|
1242
|
+
|| /^-(?:usepretex|useposttex)(?:$|=)/.test(flag)
|
|
1243
|
+
|| /^-(?:pdflatex|xelatex|lualatex|latex|bibtex|biber|makeindex|dvi_filter|ps_filter|pdf_previewer)(?:$|=)/.test(flag);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
function isUnsafeTexEngineArgument(value) {
|
|
1247
|
+
const flag = String(value || '').toLowerCase();
|
|
1248
|
+
if (/(?:shell-escape|shell-restricted|write18)/.test(flag)) {
|
|
1249
|
+
return true;
|
|
1250
|
+
}
|
|
1251
|
+
if (/^--?(?:output-directory|aux-directory|outdir|auxdir)(?:$|=)/.test(flag)) {
|
|
1252
|
+
return true;
|
|
1253
|
+
}
|
|
1254
|
+
if (flag === '-jobname' || flag === '--jobname') {
|
|
1255
|
+
return true;
|
|
1256
|
+
}
|
|
1257
|
+
const jobName = flag.match(/^--?jobname=(.*)$/)?.[1] || '';
|
|
1258
|
+
return Boolean(jobName && (jobName.includes('..') || /[\\/]/.test(jobName)));
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1218
1261
|
function pathBasename(value) {
|
|
1219
1262
|
return String(value || '').split(/[\\/]/).pop();
|
|
1220
1263
|
}
|
|
@@ -42,8 +42,13 @@ async function syncOverleafToMirror({ projectId, project, rootDir }) {
|
|
|
42
42
|
const previous = readBaseline(mirror.baselinePath);
|
|
43
43
|
const fullProjectSnapshot = project?.capabilities?.fullProjectSnapshot !== false;
|
|
44
44
|
|
|
45
|
+
const mirrorRoot = path.dirname(mirror.projectRoot);
|
|
46
|
+
assertSafeMirrorPathBeforeCreate(mirror.workspacePath, mirrorRoot);
|
|
47
|
+
assertSafeMirrorPathBeforeCreate(mirror.metadataPath, mirrorRoot);
|
|
45
48
|
fs.mkdirSync(mirror.workspacePath, { recursive: true });
|
|
46
49
|
fs.mkdirSync(mirror.metadataPath, { recursive: true });
|
|
50
|
+
assertSafeMirrorPathBeforeCreate(mirror.workspacePath, mirrorRoot);
|
|
51
|
+
assertSafeMirrorPathBeforeCreate(mirror.metadataPath, mirrorRoot);
|
|
47
52
|
|
|
48
53
|
if (fullProjectSnapshot) {
|
|
49
54
|
for (const filePath of listWorkspaceFiles(mirror.workspacePath)) {
|
|
@@ -52,6 +57,7 @@ async function syncOverleafToMirror({ projectId, project, rootDir }) {
|
|
|
52
57
|
}
|
|
53
58
|
const target = resolveWorkspacePath(mirror.workspacePath, filePath);
|
|
54
59
|
if (fs.existsSync(target)) {
|
|
60
|
+
assertSafeWorkspaceTarget(mirror.workspacePath, target, filePath);
|
|
55
61
|
fs.rmSync(target, { force: true });
|
|
56
62
|
removeEmptyParents(path.dirname(target), mirror.workspacePath);
|
|
57
63
|
}
|
|
@@ -63,6 +69,7 @@ async function syncOverleafToMirror({ projectId, project, rootDir }) {
|
|
|
63
69
|
|
|
64
70
|
for (const file of files) {
|
|
65
71
|
const target = resolveWorkspacePath(mirror.workspacePath, file.path);
|
|
72
|
+
assertSafeWorkspaceTarget(mirror.workspacePath, target, file.path);
|
|
66
73
|
const prev = previousByPath.get(file.path);
|
|
67
74
|
const nextHash = hashProjectFile(file);
|
|
68
75
|
if (prev && prev.hash === nextHash && workspaceFileMatchesBaseline(target, prev)) {
|
|
@@ -530,6 +537,9 @@ function listWorkspaceFiles(workspacePath) {
|
|
|
530
537
|
}
|
|
531
538
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
532
539
|
const absolute = path.join(dir, entry.name);
|
|
540
|
+
if (entry.isSymbolicLink()) {
|
|
541
|
+
throw new Error(`Unsafe mirror symlink: ${relative}`);
|
|
542
|
+
}
|
|
533
543
|
if (entry.isDirectory()) {
|
|
534
544
|
walk(absolute, relative);
|
|
535
545
|
} else if (entry.isFile()) {
|
|
@@ -753,6 +763,7 @@ async function applyFileOverlays({ projectId, overlays, rootDir }) {
|
|
|
753
763
|
}
|
|
754
764
|
const normalizedPath = normalizeRelativePath(overlay.path);
|
|
755
765
|
const target = resolveWorkspacePath(mirror.workspacePath, normalizedPath);
|
|
766
|
+
assertSafeWorkspaceTarget(mirror.workspacePath, target, normalizedPath);
|
|
756
767
|
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
757
768
|
fs.writeFileSync(target, overlay.content, 'utf8');
|
|
758
769
|
|
|
@@ -803,6 +814,9 @@ async function confirmWritebackFiles({ projectId, paths, rootDir }) {
|
|
|
803
814
|
} catch (error) {
|
|
804
815
|
return { ok: false, reason: 'unsafe_path', path: normalizedPath };
|
|
805
816
|
}
|
|
817
|
+
if (!isSafeWorkspaceWriteTarget(mirror.workspacePath, target)) {
|
|
818
|
+
return { ok: false, reason: 'unsafe_path', path: normalizedPath };
|
|
819
|
+
}
|
|
806
820
|
let content;
|
|
807
821
|
try {
|
|
808
822
|
content = fs.readFileSync(target, 'utf8');
|
|
@@ -1017,6 +1031,34 @@ function isSafeWorkspaceWriteTarget(workspacePath, target) {
|
|
|
1017
1031
|
}
|
|
1018
1032
|
}
|
|
1019
1033
|
|
|
1034
|
+
function assertSafeWorkspaceTarget(workspacePath, target, filePath = '') {
|
|
1035
|
+
if (!isSafeWorkspaceWriteTarget(workspacePath, target)) {
|
|
1036
|
+
throw new Error(`Unsafe mirror path: ${filePath || target}`);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
function assertSafeMirrorPathBeforeCreate(target, boundary) {
|
|
1041
|
+
const root = path.resolve(boundary);
|
|
1042
|
+
const resolvedTarget = path.resolve(target);
|
|
1043
|
+
if (resolvedTarget === root || !resolvedTarget.startsWith(root + path.sep)) {
|
|
1044
|
+
throw new Error(`Unsafe mirror root path: ${target}`);
|
|
1045
|
+
}
|
|
1046
|
+
let current = root;
|
|
1047
|
+
const parts = path.relative(root, resolvedTarget).split(path.sep).filter(Boolean);
|
|
1048
|
+
for (let index = -1; index < parts.length; index += 1) {
|
|
1049
|
+
if (index >= 0) {
|
|
1050
|
+
current = path.join(current, parts[index]);
|
|
1051
|
+
}
|
|
1052
|
+
if (!fs.existsSync(current)) {
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
const stat = fs.lstatSync(current);
|
|
1056
|
+
if (stat.isSymbolicLink() || (index < parts.length - 1 && !stat.isDirectory())) {
|
|
1057
|
+
throw new Error(`Unsafe mirror root path: ${current}`);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1020
1062
|
function markMirrorDirty({ projectId, rootDir, reason = 'dirty_mirror' }) {
|
|
1021
1063
|
const mirror = getProjectMirror(projectId, { rootDir });
|
|
1022
1064
|
const baseline = readBaseline(mirror.baselinePath);
|
|
@@ -1040,6 +1082,9 @@ function verifyWorkspaceMatchesBaseline(workspacePath, baselineFiles = []) {
|
|
|
1040
1082
|
if (!fs.existsSync(target)) {
|
|
1041
1083
|
return { ok: false, reason: 'workspace_mismatch', path: file.path };
|
|
1042
1084
|
}
|
|
1085
|
+
if (!isSafeWorkspaceWriteTarget(workspacePath, target)) {
|
|
1086
|
+
return { ok: false, reason: 'unsafe_path', path: file.path };
|
|
1087
|
+
}
|
|
1043
1088
|
if (file.kind === 'binary') {
|
|
1044
1089
|
if (hashBytes(fs.readFileSync(target)) !== file.hash) {
|
|
1045
1090
|
return { ok: false, reason: 'workspace_mismatch', path: file.path };
|