@grainulation/harvest 1.0.4 → 1.1.1

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/lib/farmer.js CHANGED
@@ -11,7 +11,7 @@ let _warnedNoToken = false;
11
11
  /**
12
12
  * POST an activity event to farmer.
13
13
  * Graceful failure -- catch and warn, never crash.
14
- * @param {string} farmerUrl - Base URL of farmer (e.g. http://localhost:9090)
14
+ * @param {string} farmerUrl - Base URL of farmer
15
15
  * @param {object} event - Event object (e.g. { type: "analyze", data: {...} })
16
16
  * @param {object} [opts] - Options
17
17
  * @param {string} [opts.token] - Bearer token for Authorization header
@@ -89,7 +89,7 @@ function notify(farmerUrl, event, opts) {
89
89
  * CLI handler for `harvest connect farmer`.
90
90
  * Reads/writes .farmer.json in targetDir.
91
91
  * @param {string} targetDir - Working directory
92
- * @param {string[]} args - CLI arguments (e.g. ["farmer", "--url", "http://..."])
92
+ * @param {string[]} args - CLI arguments (e.g. ["farmer", "--url", "<farmer-url>"])
93
93
  */
94
94
  async function connect(targetDir, args) {
95
95
  const subcommand = args[0];
package/lib/server.js CHANGED
@@ -556,6 +556,14 @@ ${ROUTES.map((r) => "<tr><td><code>" + r.method + "</code></td><td><code>" + r.p
556
556
  let filePath = url.pathname;
557
557
  filePath = join(PUBLIC_DIR, filePath);
558
558
 
559
+ // Prevent directory traversal
560
+ const resolved = resolve(filePath);
561
+ if (!resolved.startsWith(PUBLIC_DIR + "/") && resolved !== PUBLIC_DIR) {
562
+ res.writeHead(403);
563
+ res.end("Forbidden");
564
+ return;
565
+ }
566
+
559
567
  if (existsSync(filePath) && !statSync(filePath).isDirectory()) {
560
568
  const ext = extname(filePath);
561
569
  const mime = MIME[ext] || "application/octet-stream";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grainulation/harvest",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "description": "Analytics and retrospective layer for research sprints -- learn from every decision you've made",
5
5
  "main": "lib/analyzer.js",
6
6
  "exports": {