@grainulation/harvest 1.0.4 → 1.1.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.
Files changed (2) hide show
  1. package/lib/server.js +8 -0
  2. package/package.json +1 -1
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.0",
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": {