@blamejs/core 0.6.20 → 0.6.22
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/CHANGELOG.md +2 -0
- package/README.md +18 -10
- package/lib/archive.js +8 -7
- package/lib/bundler.js +8 -8
- package/lib/cache.js +105 -20
- package/lib/db-query.js +21 -2
- package/lib/db.js +15 -0
- package/lib/framework-schema.js +38 -6
- package/lib/http-client-cookie-jar.js +117 -17
- package/lib/http-client.js +4 -3
- package/lib/mail.js +5 -4
- package/lib/network-dns.js +138 -43
- package/lib/pagination.js +136 -76
- package/lib/parsers/index.js +16 -2
- package/lib/parsers/safe-ini.js +273 -0
- package/lib/queue-local.js +12 -1
- package/lib/vault/index.js +3 -3
- package/package.json +1 -1
- package/sbom.cyclonedx.json +6 -6
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* INI parser — same security defaults as the framework's other parsers.
|
|
4
|
+
*
|
|
5
|
+
* INI is the Windows config-file format (also used by systemd unit
|
|
6
|
+
* files, .gitconfig, php.ini, tox.ini, and a long tail of operator
|
|
7
|
+
* tooling). The format has no formal spec — we implement the
|
|
8
|
+
* widely-compatible subset:
|
|
9
|
+
*
|
|
10
|
+
* - Sections: [section-name] -> object key
|
|
11
|
+
* - Subsections: [parent.child] / [parent "child"] -> nested object
|
|
12
|
+
* - Key-value: key = value / key: value
|
|
13
|
+
* - Comments: ; or # at the start of a line, or after a value
|
|
14
|
+
* - Quoted values: "double" / 'single' (escapes: \\ \" \' \n \t)
|
|
15
|
+
* - Booleans: true/false/yes/no/on/off (case-insensitive)
|
|
16
|
+
* - Numbers: decimal integers + floats; hex (0xABCD)
|
|
17
|
+
*
|
|
18
|
+
* Security defaults:
|
|
19
|
+
* - maxBytes: 1 MiB (operator override via opts.maxBytes)
|
|
20
|
+
* - maxSections: 500 (depth + breadth limit)
|
|
21
|
+
* - maxKeysPerSection: 1000
|
|
22
|
+
* - maxValueBytes: 64 KiB
|
|
23
|
+
* - prototype-pollution: keys named __proto__, constructor, prototype
|
|
24
|
+
* are rejected (would otherwise let an attacker poison Object.prototype
|
|
25
|
+
* when a downstream consumer uses bracket access)
|
|
26
|
+
* - Duplicate-key policy: opts.onDuplicate = "throw" (default) | "first" | "last".
|
|
27
|
+
* Silent overwrite (the bare-INI default) is OFF — operators almost
|
|
28
|
+
* never want a config error to silently shadow earlier values.
|
|
29
|
+
*
|
|
30
|
+
* Public API:
|
|
31
|
+
* parsers.ini.parse(input, opts?) -> object
|
|
32
|
+
* parsers.ini.IniSafeError (with .code matching ini/...)
|
|
33
|
+
*
|
|
34
|
+
* Validation tier: A (config-time throw) — every malformed input
|
|
35
|
+
* surfaces at parse time, never silently coerces to a usable shape.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
var { defineClass } = require("../framework-error");
|
|
39
|
+
|
|
40
|
+
var IniSafeError = defineClass("IniSafeError", { alwaysPermanent: true });
|
|
41
|
+
|
|
42
|
+
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
43
|
+
var DEFAULT_MAX_SECTIONS = 500;
|
|
44
|
+
var DEFAULT_MAX_KEYS_SECTION = 1000;
|
|
45
|
+
var DEFAULT_MAX_VALUE_BYTES = 64 * 1024;
|
|
46
|
+
|
|
47
|
+
var FORBIDDEN_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
48
|
+
|
|
49
|
+
var TRUE_VALUES = new Set(["true", "yes", "on"]);
|
|
50
|
+
var FALSE_VALUES = new Set(["false", "no", "off"]);
|
|
51
|
+
|
|
52
|
+
function _err(code, message) { return new IniSafeError(code, message); }
|
|
53
|
+
|
|
54
|
+
function _stripComment(line) {
|
|
55
|
+
var inSingle = false, inDouble = false, escape = false;
|
|
56
|
+
for (var i = 0; i < line.length; i++) {
|
|
57
|
+
var c = line.charAt(i);
|
|
58
|
+
if (escape) { escape = false; continue; }
|
|
59
|
+
if (c === "\\" && (inSingle || inDouble)) { escape = true; continue; }
|
|
60
|
+
if (c === "\"" && !inSingle) { inDouble = !inDouble; continue; }
|
|
61
|
+
if (c === "'" && !inDouble) { inSingle = !inSingle; continue; }
|
|
62
|
+
if (!inSingle && !inDouble && (c === ";" || c === "#")) {
|
|
63
|
+
if (i === 0 || /\s/.test(line.charAt(i - 1))) {
|
|
64
|
+
return line.slice(0, i);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return line;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _unquote(raw) {
|
|
72
|
+
var s = raw.trim();
|
|
73
|
+
if (s.length === 0) return s;
|
|
74
|
+
var first = s.charAt(0), last = s.charAt(s.length - 1);
|
|
75
|
+
if ((first === "\"" && last === "\"") || (first === "'" && last === "'")) {
|
|
76
|
+
if (s.length < 2) {
|
|
77
|
+
throw _err("ini/bad-quote", "unbalanced quote in value: " + JSON.stringify(s));
|
|
78
|
+
}
|
|
79
|
+
var inner = s.slice(1, -1);
|
|
80
|
+
var out = "";
|
|
81
|
+
var i = 0;
|
|
82
|
+
while (i < inner.length) {
|
|
83
|
+
var c = inner.charAt(i);
|
|
84
|
+
if (c === "\\" && i + 1 < inner.length) {
|
|
85
|
+
var next = inner.charAt(i + 1);
|
|
86
|
+
if (next === "\\") out += "\\";
|
|
87
|
+
else if (next === "n") out += "\n";
|
|
88
|
+
else if (next === "t") out += "\t";
|
|
89
|
+
else if (next === "r") out += "\r";
|
|
90
|
+
else if (next === "\"") out += "\"";
|
|
91
|
+
else if (next === "'") out += "'";
|
|
92
|
+
else throw _err("ini/bad-escape", "unknown escape sequence \\" + next);
|
|
93
|
+
i += 2;
|
|
94
|
+
} else {
|
|
95
|
+
out += c;
|
|
96
|
+
i += 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
return s;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _coerceValue(raw) {
|
|
105
|
+
if (raw.length === 0) return raw;
|
|
106
|
+
var first = raw.charAt(0);
|
|
107
|
+
if (first === "\"" || first === "'") return _unquote(raw);
|
|
108
|
+
var lower = raw.toLowerCase();
|
|
109
|
+
if (TRUE_VALUES.has(lower)) return true;
|
|
110
|
+
if (FALSE_VALUES.has(lower)) return false;
|
|
111
|
+
if (/^0x[0-9a-f]+$/i.test(raw)) {
|
|
112
|
+
var hex = parseInt(raw, 16);
|
|
113
|
+
if (!Number.isSafeInteger(hex)) {
|
|
114
|
+
throw _err("ini/value-out-of-range", "hex integer exceeds safe-integer range: " + raw);
|
|
115
|
+
}
|
|
116
|
+
return hex;
|
|
117
|
+
}
|
|
118
|
+
if (/^-?\d+$/.test(raw)) {
|
|
119
|
+
var n = Number(raw);
|
|
120
|
+
if (!Number.isSafeInteger(n)) {
|
|
121
|
+
throw _err("ini/value-out-of-range", "integer exceeds safe-integer range: " + raw);
|
|
122
|
+
}
|
|
123
|
+
return n;
|
|
124
|
+
}
|
|
125
|
+
if (/^-?\d+\.\d+([eE][+-]?\d+)?$/.test(raw) || /^-?\d+[eE][+-]?\d+$/.test(raw)) {
|
|
126
|
+
return Number(raw);
|
|
127
|
+
}
|
|
128
|
+
return _unquote(raw);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function _validateKey(name) {
|
|
132
|
+
if (FORBIDDEN_KEYS.has(name)) {
|
|
133
|
+
throw _err("ini/forbidden-key", "key '" + name + "' is reserved (prototype pollution defense)");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function _ensureSection(root, sectionPath) {
|
|
138
|
+
if (sectionPath.length === 0) return root;
|
|
139
|
+
var node = root;
|
|
140
|
+
for (var i = 0; i < sectionPath.length; i++) {
|
|
141
|
+
var seg = sectionPath[i];
|
|
142
|
+
_validateKey(seg);
|
|
143
|
+
if (Object.prototype.hasOwnProperty.call(node, seg)) {
|
|
144
|
+
var existing = node[seg];
|
|
145
|
+
if (typeof existing !== "object" || existing === null || Array.isArray(existing)) {
|
|
146
|
+
throw _err("ini/section-conflict",
|
|
147
|
+
"section path [" + sectionPath.join(".") + "] collides with existing scalar at '" + seg + "'");
|
|
148
|
+
}
|
|
149
|
+
node = existing;
|
|
150
|
+
} else {
|
|
151
|
+
var child = {};
|
|
152
|
+
node[seg] = child;
|
|
153
|
+
node = child;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return node;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function _parseSectionHeader(line) {
|
|
160
|
+
var inner = line.slice(1, line.lastIndexOf("]")).trim();
|
|
161
|
+
if (inner.length === 0) {
|
|
162
|
+
throw _err("ini/empty-section", "section header [] has no name");
|
|
163
|
+
}
|
|
164
|
+
var quotedMatch = /^([A-Za-z0-9._-]+)\s+"([^"\\]*(?:\\.[^"\\]*)*)"$/.exec(inner);
|
|
165
|
+
if (quotedMatch) {
|
|
166
|
+
return [quotedMatch[1], quotedMatch[2]];
|
|
167
|
+
}
|
|
168
|
+
var parts = inner.split(".");
|
|
169
|
+
for (var i = 0; i < parts.length; i++) {
|
|
170
|
+
if (parts[i].length === 0) {
|
|
171
|
+
throw _err("ini/bad-section", "section name has empty segment: " + JSON.stringify(inner));
|
|
172
|
+
}
|
|
173
|
+
if (!/^[A-Za-z0-9_-]+$/.test(parts[i])) {
|
|
174
|
+
throw _err("ini/bad-section",
|
|
175
|
+
"section segment must match [A-Za-z0-9_-]+ (got " + JSON.stringify(parts[i]) + ")");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return parts;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function parse(input, opts) {
|
|
182
|
+
opts = opts || {};
|
|
183
|
+
var maxBytes = opts.maxBytes || DEFAULT_MAX_BYTES;
|
|
184
|
+
var maxSections = opts.maxSections || DEFAULT_MAX_SECTIONS;
|
|
185
|
+
var maxKeysPerSect = opts.maxKeysPerSection || DEFAULT_MAX_KEYS_SECTION;
|
|
186
|
+
var maxValueBytes = opts.maxValueBytes || DEFAULT_MAX_VALUE_BYTES;
|
|
187
|
+
var onDuplicate = opts.onDuplicate || "throw";
|
|
188
|
+
|
|
189
|
+
if (typeof input !== "string") {
|
|
190
|
+
throw _err("ini/bad-input", "ini.parse: input must be a string, got " + typeof input);
|
|
191
|
+
}
|
|
192
|
+
if (Buffer.byteLength(input, "utf8") > maxBytes) {
|
|
193
|
+
throw _err("ini/too-large",
|
|
194
|
+
"ini.parse: input exceeds " + maxBytes + " bytes");
|
|
195
|
+
}
|
|
196
|
+
if (onDuplicate !== "throw" && onDuplicate !== "first" && onDuplicate !== "last") {
|
|
197
|
+
throw _err("ini/bad-opt",
|
|
198
|
+
"ini.parse: onDuplicate must be 'throw' | 'first' | 'last', got " + JSON.stringify(onDuplicate));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
var root = {};
|
|
202
|
+
var currentSectionPath = [];
|
|
203
|
+
var currentSection = root;
|
|
204
|
+
var sectionCount = 0;
|
|
205
|
+
var keysInCurrentSection = 0;
|
|
206
|
+
|
|
207
|
+
var lines = input.split(/\r?\n/);
|
|
208
|
+
for (var li = 0; li < lines.length; li++) {
|
|
209
|
+
var raw = lines[li];
|
|
210
|
+
var stripped = _stripComment(raw).trim();
|
|
211
|
+
if (stripped.length === 0) continue;
|
|
212
|
+
|
|
213
|
+
if (stripped.charAt(0) === "[") {
|
|
214
|
+
if (stripped.charAt(stripped.length - 1) !== "]") {
|
|
215
|
+
throw _err("ini/bad-section", "section header at line " + (li + 1) + " missing closing ']'");
|
|
216
|
+
}
|
|
217
|
+
sectionCount += 1;
|
|
218
|
+
if (sectionCount > maxSections) {
|
|
219
|
+
throw _err("ini/too-many-sections",
|
|
220
|
+
"ini.parse: section count exceeds " + maxSections);
|
|
221
|
+
}
|
|
222
|
+
currentSectionPath = _parseSectionHeader(stripped);
|
|
223
|
+
currentSection = _ensureSection(root, currentSectionPath);
|
|
224
|
+
keysInCurrentSection = 0;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var eqIdx = stripped.indexOf("=");
|
|
229
|
+
var coIdx = stripped.indexOf(":");
|
|
230
|
+
var sepIdx;
|
|
231
|
+
if (eqIdx === -1) sepIdx = coIdx;
|
|
232
|
+
else if (coIdx === -1) sepIdx = eqIdx;
|
|
233
|
+
else sepIdx = Math.min(eqIdx, coIdx);
|
|
234
|
+
if (sepIdx === -1) {
|
|
235
|
+
throw _err("ini/bad-line",
|
|
236
|
+
"line " + (li + 1) + " is neither blank nor key=value: " + JSON.stringify(stripped));
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var key = stripped.slice(0, sepIdx).trim();
|
|
240
|
+
var valueRaw = stripped.slice(sepIdx + 1).trim();
|
|
241
|
+
if (key.length === 0) {
|
|
242
|
+
throw _err("ini/empty-key", "line " + (li + 1) + " has empty key");
|
|
243
|
+
}
|
|
244
|
+
_validateKey(key);
|
|
245
|
+
if (Buffer.byteLength(valueRaw, "utf8") > maxValueBytes) {
|
|
246
|
+
throw _err("ini/value-too-large",
|
|
247
|
+
"line " + (li + 1) + " value exceeds " + maxValueBytes + " bytes");
|
|
248
|
+
}
|
|
249
|
+
keysInCurrentSection += 1;
|
|
250
|
+
if (keysInCurrentSection > maxKeysPerSect) {
|
|
251
|
+
throw _err("ini/too-many-keys",
|
|
252
|
+
"section [" + currentSectionPath.join(".") + "] exceeds " + maxKeysPerSect + " keys");
|
|
253
|
+
}
|
|
254
|
+
var value = _coerceValue(valueRaw);
|
|
255
|
+
|
|
256
|
+
if (Object.prototype.hasOwnProperty.call(currentSection, key)) {
|
|
257
|
+
if (onDuplicate === "throw") {
|
|
258
|
+
throw _err("ini/duplicate-key",
|
|
259
|
+
"section [" + currentSectionPath.join(".") + "] redefines key '" + key + "' " +
|
|
260
|
+
"(opt onDuplicate:'first' or 'last' to allow)");
|
|
261
|
+
}
|
|
262
|
+
if (onDuplicate === "first") continue;
|
|
263
|
+
}
|
|
264
|
+
currentSection[key] = value;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return root;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
module.exports = {
|
|
271
|
+
parse: parse,
|
|
272
|
+
IniSafeError: IniSafeError,
|
|
273
|
+
};
|
package/lib/queue-local.js
CHANGED
|
@@ -109,7 +109,18 @@ function create(_config) {
|
|
|
109
109
|
cluster.requireLeader();
|
|
110
110
|
opts = opts || {};
|
|
111
111
|
var nowMs = Date.now();
|
|
112
|
-
|
|
112
|
+
// Caller-supplied opts.availableAt wins (cron-repeat pre-computes
|
|
113
|
+
// the exact next-fire ms). delaySeconds is the operator-shorthand
|
|
114
|
+
// alternative — used when opts.availableAt isn't provided. Falling
|
|
115
|
+
// through delaySeconds without honouring an explicit availableAt
|
|
116
|
+
// loses sub-second precision (delaySeconds is integer-floored)
|
|
117
|
+
// and drifts on the internal clock vs the caller's intended ms.
|
|
118
|
+
var availableAt;
|
|
119
|
+
if (typeof opts.availableAt === "number" && isFinite(opts.availableAt)) {
|
|
120
|
+
availableAt = opts.availableAt;
|
|
121
|
+
} else {
|
|
122
|
+
availableAt = nowMs + (opts.delaySeconds ? C.TIME.seconds(opts.delaySeconds) : 0);
|
|
123
|
+
}
|
|
113
124
|
|
|
114
125
|
var priority = (typeof opts.priority === "number" && isFinite(opts.priority))
|
|
115
126
|
? Math.floor(opts.priority) : 0;
|
package/lib/vault/index.js
CHANGED
|
@@ -47,9 +47,9 @@ var VAULT_PREFIX = C.VAULT_PREFIX;
|
|
|
47
47
|
// Module-local cache populated by init().
|
|
48
48
|
var keys = null;
|
|
49
49
|
var initialized = false;
|
|
50
|
-
// Passphrase retained post-init (best-effort) for
|
|
51
|
-
//
|
|
52
|
-
//
|
|
50
|
+
// Passphrase retained post-init (best-effort) for vault rotation +
|
|
51
|
+
// backup re-wrap. Already in JS heap during unwrap; retaining doesn't
|
|
52
|
+
// change the threat model meaningfully.
|
|
53
53
|
var currentPassphrase = null;
|
|
54
54
|
// Resolved paths (set by init based on dataDir option)
|
|
55
55
|
var paths = null;
|
package/package.json
CHANGED
package/sbom.cyclonedx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.5",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:2dcbd08d-cbaf-408b-8b68-8982ea425a0f",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-05-
|
|
8
|
+
"timestamp": "2026-05-02T07:32:02.459Z",
|
|
9
9
|
"lifecycles": [
|
|
10
10
|
{
|
|
11
11
|
"phase": "build"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"component": {
|
|
22
|
-
"bom-ref": "@blamejs/core@0.6.
|
|
22
|
+
"bom-ref": "@blamejs/core@0.6.22",
|
|
23
23
|
"type": "library",
|
|
24
24
|
"name": "blamejs",
|
|
25
|
-
"version": "0.6.
|
|
25
|
+
"version": "0.6.22",
|
|
26
26
|
"scope": "required",
|
|
27
27
|
"author": "blamejs contributors",
|
|
28
28
|
"description": "The Node framework that owns its stack.",
|
|
29
|
-
"purl": "pkg:npm/%40blamejs/core@0.6.
|
|
29
|
+
"purl": "pkg:npm/%40blamejs/core@0.6.22",
|
|
30
30
|
"properties": [],
|
|
31
31
|
"externalReferences": [
|
|
32
32
|
{
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"components": [],
|
|
55
55
|
"dependencies": [
|
|
56
56
|
{
|
|
57
|
-
"ref": "@blamejs/core@0.6.
|
|
57
|
+
"ref": "@blamejs/core@0.6.22",
|
|
58
58
|
"dependsOn": []
|
|
59
59
|
}
|
|
60
60
|
]
|