@fungi.computer/oyster 0.46.2 → 0.46.4
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/dist/build/job-log.js
CHANGED
|
@@ -130,6 +130,7 @@ export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
|
130
130
|
const { redactor } = await loadRedactorOrWithhold(loadRedactor);
|
|
131
131
|
let pending = "";
|
|
132
132
|
let scannedLength = 0;
|
|
133
|
+
let masking;
|
|
133
134
|
const scan = (final) => {
|
|
134
135
|
if (redactor === undefined) {
|
|
135
136
|
pending = "";
|
|
@@ -138,7 +139,21 @@ export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
|
138
139
|
ring.append(textToBytes(redactionWithheld));
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
+
// A private key without its end line, or a curl command with lines still
|
|
143
|
+
// to come, is never released raw: it is held from its opener, and masked
|
|
144
|
+
// whole if the output ends first, or through its end if the held text
|
|
145
|
+
// reaches the ceiling first.
|
|
146
|
+
const open = redactor.openFrom(pending);
|
|
147
|
+
const ceiling = pending.length > maxPendingText;
|
|
148
|
+
// Still held from the start: nothing can leave, so skip the full scan.
|
|
149
|
+
if (!final && !ceiling && open?.opener.start === 0) {
|
|
150
|
+
scannedLength = pending.length;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const whole = open !== undefined &&
|
|
154
|
+
(final || (ceiling && open.opener.start < pending.length - scanWindow));
|
|
155
|
+
// A block masked whole needs a full scan only of the text before it.
|
|
156
|
+
const matches = redactor.find(whole ? pending.slice(0, open.opener.start) : pending);
|
|
142
157
|
if (matches === undefined) {
|
|
143
158
|
// Over Veil's size ceiling: withhold this text, never pass it raw.
|
|
144
159
|
ring.append(textToBytes(redactionWithheld));
|
|
@@ -146,15 +161,28 @@ export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
|
146
161
|
scannedLength = 0;
|
|
147
162
|
return;
|
|
148
163
|
}
|
|
164
|
+
const masks = secretsOf(matches);
|
|
165
|
+
if (whole) {
|
|
166
|
+
ring.append(textToBytes(maskSpans(pending, [
|
|
167
|
+
...masks,
|
|
168
|
+
{ start: open.opener.start, end: pending.length },
|
|
169
|
+
])));
|
|
170
|
+
// The rest of the block, through its end, is masked as it arrives.
|
|
171
|
+
if (!final)
|
|
172
|
+
masking = open.follow();
|
|
173
|
+
pending = "";
|
|
174
|
+
scannedLength = 0;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
149
177
|
if (final) {
|
|
150
|
-
ring.append(textToBytes(maskSpans(pending,
|
|
178
|
+
ring.append(textToBytes(maskSpans(pending, masks)));
|
|
151
179
|
pending = "";
|
|
152
180
|
scannedLength = 0;
|
|
153
181
|
return;
|
|
154
182
|
}
|
|
155
|
-
if (
|
|
183
|
+
if (ceiling) {
|
|
156
184
|
// Ceiling: emit all but the last window, masked on both sides of the cut.
|
|
157
|
-
const text = maskSpans(pending,
|
|
185
|
+
const text = maskSpans(pending, masks);
|
|
158
186
|
ring.append(textToBytes(text.slice(0, text.length - scanWindow)));
|
|
159
187
|
pending = text.slice(text.length - scanWindow);
|
|
160
188
|
scannedLength = pending.length;
|
|
@@ -163,12 +191,12 @@ export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
|
163
191
|
// A match reaching into the last window could still grow with later
|
|
164
192
|
// output, so it stays pending raw, with its whole match as rescan context.
|
|
165
193
|
// Walking by descending start also holds any match that overlaps one held.
|
|
166
|
-
let cut = pending.length - scanWindow;
|
|
194
|
+
let cut = Math.min(pending.length - scanWindow, open?.opener.start ?? Infinity);
|
|
167
195
|
for (const { match } of [...matches].sort((left, right) => right.match.start - left.match.start))
|
|
168
196
|
if (match.start < cut && match.end > cut)
|
|
169
197
|
cut = match.start;
|
|
170
198
|
if (cut > 0) {
|
|
171
|
-
ring.append(textToBytes(maskSpans(pending.slice(0, cut),
|
|
199
|
+
ring.append(textToBytes(maskSpans(pending.slice(0, cut), masks.filter(({ end }) => end <= cut))));
|
|
172
200
|
pending = pending.slice(cut);
|
|
173
201
|
}
|
|
174
202
|
scannedLength = pending.length;
|
|
@@ -179,8 +207,18 @@ export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
|
179
207
|
return ring.allocatedBytes;
|
|
180
208
|
},
|
|
181
209
|
append(bytes) {
|
|
182
|
-
|
|
183
|
-
if (
|
|
210
|
+
let text = bytesToText(bytes);
|
|
211
|
+
if (masking !== undefined) {
|
|
212
|
+
const end = masking.read(text);
|
|
213
|
+
if (end === undefined)
|
|
214
|
+
return;
|
|
215
|
+
masking = undefined;
|
|
216
|
+
text = text.slice(end);
|
|
217
|
+
}
|
|
218
|
+
pending += text;
|
|
219
|
+
// Held text doubles before its next rescan, so holding stays linear.
|
|
220
|
+
if (pending.length >=
|
|
221
|
+
Math.min(maxPendingText + 1, Math.max(2 * scanWindow, scannedLength + Math.max(scanWindow, scannedLength))))
|
|
184
222
|
scan(false);
|
|
185
223
|
},
|
|
186
224
|
finish() {
|