mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 06:34:31 +00:00
Memory: harden QMD memory_get path checks
This commit is contained in:
committed by
Vignesh
parent
b7f4755020
commit
c248da0317
@@ -280,6 +280,13 @@ export class QmdMemoryManager implements MemorySearchManager {
|
|||||||
const relPath = params.relPath?.trim();
|
const relPath = params.relPath?.trim();
|
||||||
if (!relPath) throw new Error("path required");
|
if (!relPath) throw new Error("path required");
|
||||||
const absPath = this.resolveReadPath(relPath);
|
const absPath = this.resolveReadPath(relPath);
|
||||||
|
if (!absPath.endsWith(".md")) {
|
||||||
|
throw new Error("path required");
|
||||||
|
}
|
||||||
|
const stat = await fs.lstat(absPath);
|
||||||
|
if (stat.isSymbolicLink() || !stat.isFile()) {
|
||||||
|
throw new Error("path required");
|
||||||
|
}
|
||||||
const content = await fs.readFile(absPath, "utf-8");
|
const content = await fs.readFile(absPath, "utf-8");
|
||||||
if (!params.from && !params.lines) {
|
if (!params.from && !params.lines) {
|
||||||
return { text: content, path: relPath };
|
return { text: content, path: relPath };
|
||||||
|
|||||||
Reference in New Issue
Block a user