dsh-session-sync 0.2.28 → 0.2.29
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/CHANGELOG.md +8 -0
- package/lib/git.mjs +1 -1
- package/lib/mirror.mjs +18 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.29] - 2026-10-19
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **Mirror writes now reject parent-directory symlink escapes (issue #13).** `writeIfDifferent` resolves the parent chain and refuses any target outside `repoDir` (or `sessionRoot` for restore), in addition to the existing final-component check.
|
|
8
|
+
- **`git fetch` no longer force-updates the tracking ref (issue #13).** The refspec dropped its leading `+`; a remote that rewrote history now fails the fetch instead of silently force-updating and merging the rewritten tree.
|
|
9
|
+
- The token-as-username redaction half had already landed in 0.2.27.
|
|
10
|
+
|
|
3
11
|
## [0.2.28] - 2026-10-18
|
|
4
12
|
|
|
5
13
|
### Fixed
|
package/lib/git.mjs
CHANGED
|
@@ -262,7 +262,7 @@ export class GitBackend {
|
|
|
262
262
|
* @returns {Promise<boolean>} 是否拿到远端分支。
|
|
263
263
|
*/
|
|
264
264
|
async fetch(opts = {}) {
|
|
265
|
-
const result = await this.#git(['fetch', 'origin',
|
|
265
|
+
const result = await this.#git(['fetch', 'origin', `${this.#branch}:refs/remotes/origin/${this.#branch}`], { signal: opts.signal })
|
|
266
266
|
if (result.code === 0) return true
|
|
267
267
|
const stderr = String(result.stderr ?? '')
|
|
268
268
|
if (/couldn't find remote ref/i.test(stderr)) return false
|
package/lib/mirror.mjs
CHANGED
|
@@ -38,8 +38,22 @@ async function listFiles(root) {
|
|
|
38
38
|
return { files, skipped }
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
async function
|
|
41
|
+
/** 拒绝任何解析后落在 root 之外的写入(含父目录 symlink 逃逸)。 */
|
|
42
|
+
async function assertWriteInside(root, target) {
|
|
43
|
+
let rootReal
|
|
44
|
+
try { rootReal = await fs.realpath(root) } catch {
|
|
45
|
+
await fs.mkdir(root, { recursive: true })
|
|
46
|
+
rootReal = await fs.realpath(root)
|
|
47
|
+
}
|
|
48
|
+
await fs.mkdir(path.dirname(target), { recursive: true })
|
|
49
|
+
const parentReal = await fs.realpath(path.dirname(target))
|
|
50
|
+
const rel = path.relative(rootReal, parentReal)
|
|
51
|
+
if (rel.startsWith('..') || path.isAbsolute(rel)) throw new Error(`refusing to write outside ${rootReal}`)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 内容一致则跳过写(返回 false),否则覆写(返回 true)。root 可选,提供时做真实路径 containment。 */
|
|
55
|
+
async function writeIfDifferent(target, content, root) {
|
|
56
|
+
if (root !== undefined) await assertWriteInside(root, target)
|
|
43
57
|
try {
|
|
44
58
|
const st = await fs.lstat(target)
|
|
45
59
|
if (st.isSymbolicLink()) throw new Error('refusing to write through a symbolic link')
|
|
@@ -109,7 +123,7 @@ export async function mirrorSessionRoot(deps) {
|
|
|
109
123
|
}
|
|
110
124
|
const target = path.join(mirrorRoot, ...file.rel.split('/'))
|
|
111
125
|
targets.add(file.rel)
|
|
112
|
-
const wrote = await writeIfDifferent(target, await fs.readFile(file.absolute))
|
|
126
|
+
const wrote = await writeIfDifferent(target, await fs.readFile(file.absolute), deps.repoDir)
|
|
113
127
|
if (wrote) mirrored += 1
|
|
114
128
|
else unchanged += 1
|
|
115
129
|
}
|
|
@@ -281,7 +295,7 @@ export async function restoreSessionRoot(deps) {
|
|
|
281
295
|
existed = true
|
|
282
296
|
} catch { /* target absent */ }
|
|
283
297
|
const content = await fs.readFile(absolute)
|
|
284
|
-
const wrote = await writeIfDifferent(target, content)
|
|
298
|
+
const wrote = await writeIfDifferent(target, content, deps.sessionRoot)
|
|
285
299
|
if (wrote) restored += 1
|
|
286
300
|
else unchanged += 1
|
|
287
301
|
// Track only copies this plugin created (target absent before) or already
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-session-sync",
|
|
3
3
|
"description": "Cross-device sync for DeepSeek Harness sessions: a dedicated git mirror of the session store, append-only three-way merge with keep-both + fork conflict resolution, /sync command, sync_pull/sync_push/sync_status tools, and configurable auto push/pull",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.29",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/PerryLink/dsh-session-sync.git"
|