git-watchtower 1.11.5 → 1.11.7

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": "git-watchtower",
3
- "version": "1.11.5",
3
+ "version": "1.11.7",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
@@ -87,7 +87,7 @@ function sortBranches(branches, prStatusMap) {
87
87
  if (!aMerged && bMerged && !a.isDeleted) return -1;
88
88
  if (a.isNew && !b.isNew) return -1;
89
89
  if (!a.isNew && b.isNew) return 1;
90
- return b.date - a.date;
90
+ return (b.date || 0) - (a.date || 0);
91
91
  });
92
92
  }
93
93
 
@@ -38,6 +38,12 @@ function compareVersions(a, b) {
38
38
  return 0;
39
39
  }
40
40
 
41
+ /**
42
+ * Maximum response body size for npm registry queries (64 KiB).
43
+ * The expected response is a small JSON object (~200 bytes).
44
+ */
45
+ const MAX_RESPONSE_SIZE = 64 * 1024;
46
+
41
47
  /**
42
48
  * Check npm registry for a newer version of git-watchtower
43
49
  * @returns {Promise<string|null>} Latest version string if newer, or null
@@ -54,7 +60,16 @@ function checkForUpdate() {
54
60
  return;
55
61
  }
56
62
  let data = '';
57
- res.on('data', (chunk) => { data += chunk; });
63
+ let size = 0;
64
+ res.on('data', (chunk) => {
65
+ size += chunk.length;
66
+ if (size > MAX_RESPONSE_SIZE) {
67
+ req.destroy();
68
+ resolve(null);
69
+ return;
70
+ }
71
+ data += chunk;
72
+ });
58
73
  res.on('end', () => {
59
74
  try {
60
75
  const { version } = JSON.parse(data);