@mastra/daytona 0.2.1 → 0.3.0
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 +54 -0
- package/dist/index.cjs +21 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/dist/sandbox/mounts/s3.d.ts +5 -0
- package/dist/sandbox/mounts/s3.d.ts.map +1 -1
- package/dist/sandbox/mounts/types.d.ts +8 -0
- package/dist/sandbox/mounts/types.d.ts.map +1 -1
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -36,6 +36,21 @@ function validateEndpoint(endpoint) {
|
|
|
36
36
|
throw new Error(`Invalid endpoint URL scheme: "${parsed.protocol}". Only http: and https: are allowed.`);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
function validatePrefix(prefix) {
|
|
40
|
+
let normalized = prefix;
|
|
41
|
+
while (normalized.startsWith("/")) normalized = normalized.slice(1);
|
|
42
|
+
while (normalized.endsWith("/")) normalized = normalized.slice(0, -1);
|
|
43
|
+
if (!normalized) {
|
|
44
|
+
throw new Error("Mount prefix cannot be empty after normalization.");
|
|
45
|
+
}
|
|
46
|
+
if (normalized.includes("//") || normalized.split("/").some((s) => s === "." || s === "..")) {
|
|
47
|
+
throw new Error(`Invalid mount prefix: "${prefix}". Path traversal is not allowed.`);
|
|
48
|
+
}
|
|
49
|
+
if (/[\x00-\x1f\x7f]/.test(normalized)) {
|
|
50
|
+
throw new Error(`Invalid mount prefix: "${prefix}". Control characters are not allowed.`);
|
|
51
|
+
}
|
|
52
|
+
return normalized;
|
|
53
|
+
}
|
|
39
54
|
async function runCommand(sandbox, command, options) {
|
|
40
55
|
const result = await sandbox.process.executeCommand(
|
|
41
56
|
command,
|
|
@@ -129,7 +144,12 @@ Sandbox network response: ${checkOutput}` : "")
|
|
|
129
144
|
mountOptions.push("ro");
|
|
130
145
|
logger.debug(`${LOG_PREFIX} Mounting as read-only`);
|
|
131
146
|
}
|
|
132
|
-
|
|
147
|
+
let bucketArg = config.bucket;
|
|
148
|
+
if (config.prefix) {
|
|
149
|
+
const normalizedPrefix = validatePrefix(config.prefix);
|
|
150
|
+
bucketArg = `${config.bucket}:/${normalizedPrefix}`;
|
|
151
|
+
}
|
|
152
|
+
const mountCmd = `s3fs ${shellQuote(bucketArg)} ${quotedMountPath} -o ${mountOptions.join(" -o ")}`;
|
|
133
153
|
logger.debug(`${LOG_PREFIX} Mounting S3:`, hasCredentials ? mountCmd.replace(credentialsPath, "***") : mountCmd);
|
|
134
154
|
const result = await run(mountCmd, 6e4);
|
|
135
155
|
logger.debug(`${LOG_PREFIX} s3fs result:`, {
|