chromeflow 0.1.60 → 0.1.62
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/dist/tools/capture.js +16 -1
- package/package.json +1 -1
package/dist/tools/capture.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { appendFileSync, readFileSync, writeFileSync } from "fs";
|
|
3
3
|
import { tmpdir } from "os";
|
|
4
|
-
import { join } from "path";
|
|
4
|
+
import { join, resolve, relative, isAbsolute } from "path";
|
|
5
5
|
const PAGE_STATE_FILE = join(tmpdir(), "chromeflow_page_state.json");
|
|
6
6
|
function registerCaptureTools(server, bridge) {
|
|
7
7
|
server.tool(
|
|
@@ -161,6 +161,21 @@ ${lines.join("\n")}` }] };
|
|
|
161
161
|
},
|
|
162
162
|
async ({ key, value, envPath }) => {
|
|
163
163
|
try {
|
|
164
|
+
const cwd = process.cwd();
|
|
165
|
+
const resolved = isAbsolute(envPath) ? envPath : resolve(cwd, envPath);
|
|
166
|
+
const rel = relative(cwd, resolved);
|
|
167
|
+
if (rel.startsWith("..") || isAbsolute(rel)) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
`Refusing to write .env outside the project directory. Target "${resolved}" is not under "${cwd}". If this is intentional, move the project to include the target path.`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const filename = resolved.split("/").pop() ?? "";
|
|
173
|
+
if (!/^\.env(\.[\w-]+)?$/.test(filename)) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Refusing to write: "${filename}" doesn't look like an env file. Expected .env, .env.local, .env.<name>, etc.`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
envPath = resolved;
|
|
164
179
|
let existing = "";
|
|
165
180
|
try {
|
|
166
181
|
existing = readFileSync(envPath, "utf-8");
|
package/package.json
CHANGED