squirrelscan 0.0.116 → 0.0.118

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squirrelscan",
3
- "version": "0.0.116",
3
+ "version": "0.0.118",
4
4
  "description": "Website QA tool built for coding agents. 300+ rules across SEO, performance, security, accessibility & agent experience, from the CLI, cloud, or MCP.",
5
5
  "bin": {
6
6
  "squirrel": "bin/squirrel.js"
@@ -17,6 +17,7 @@ const { spawnSync } = require("child_process");
17
17
  const { getPlatform, getBinaryExtension } = require("../lib/platform");
18
18
 
19
19
  const REPO = "squirrelscan/squirrelscan";
20
+ const MAX_REDIRECTS = 3;
20
21
 
21
22
  // Colors for terminal output
22
23
  const supportsColor = process.stdout.isTTY;
@@ -34,13 +35,41 @@ const error = (msg) => {
34
35
  };
35
36
 
36
37
  /**
37
- * HTTPS GET with redirect following
38
+ * HTTPS GET with bounded redirect following.
38
39
  */
39
- function httpsGet(url) {
40
+ function httpsGet(url, get = https.get) {
41
+ return httpsGetAt(url, 0, get);
42
+ }
43
+
44
+ function httpsGetAt(url, redirects, get) {
40
45
  return new Promise((resolve, reject) => {
41
- const request = https.get(url, { headers: { "User-Agent": "squirrelscan-npm" } }, (res) => {
46
+ let current;
47
+ try {
48
+ current = new URL(url);
49
+ } catch {
50
+ reject(new Error(`Invalid download URL: ${url}`));
51
+ return;
52
+ }
53
+ if (current.protocol !== "https:") {
54
+ reject(new Error(`Refusing non-HTTPS download URL: ${current.href}`));
55
+ return;
56
+ }
57
+
58
+ const request = get(current.href, { headers: { "User-Agent": "squirrelscan-npm" } }, (res) => {
42
59
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
43
- return httpsGet(res.headers.location).then(resolve).catch(reject);
60
+ res.resume();
61
+ if (redirects >= MAX_REDIRECTS) {
62
+ reject(new Error(`Too many redirects (maximum ${MAX_REDIRECTS}): ${current.href}`));
63
+ return;
64
+ }
65
+ let next;
66
+ try {
67
+ next = new URL(res.headers.location, current);
68
+ } catch {
69
+ reject(new Error(`Invalid redirect URL: ${res.headers.location}`));
70
+ return;
71
+ }
72
+ return httpsGetAt(next.href, redirects + 1, get).then(resolve).catch(reject);
44
73
  }
45
74
 
46
75
  if (res.statusCode !== 200) {
@@ -241,7 +270,7 @@ async function main() {
241
270
  info("Install agent integrations explicitly with 'squirrel skills install'");
242
271
  }
243
272
 
244
- module.exports = { normalizeVersion, resolveVersion };
273
+ module.exports = { httpsGet, normalizeVersion, resolveVersion };
245
274
 
246
275
  if (require.main === module) {
247
276
  main().catch((err) => {