@fungi.computer/oyster 0.46.1 → 0.46.2
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.d.ts +4 -2
- package/dist/build/job-log.js +34 -19
- package/dist/embed-metafiles.js +1 -1
- package/dist/embed-scripts.js +1 -1
- package/dist/page-script.js +3 -3
- package/package.json +7 -7
package/dist/build/job-log.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
+
import { type PatternRedactor } from "@fungi.computer/veil/redaction";
|
|
2
3
|
/** Maximum retained combined stdout/stderr bytes, split equally into head and tail. */
|
|
3
4
|
export declare const buildJobLogMaxBytes: number;
|
|
4
5
|
/** Base64url preserves raw command bytes, including split UTF-8 and terminal control bytes. */
|
|
@@ -17,9 +18,10 @@ export declare const redactionWithheld = "[output withheld: redaction unavailabl
|
|
|
17
18
|
/**
|
|
18
19
|
* One bounded sink for a build's combined output. Veil's pattern redactor
|
|
19
20
|
* (S3's gitleaks rules) runs before a byte is retained, so the stored log and
|
|
20
|
-
* every `?log` read of it are already scrubbed.
|
|
21
|
+
* every `?log` read of it are already scrubbed. `loadRedactor` is Veil's
|
|
22
|
+
* loader unless a caller wraps it (a test that counts scanned characters).
|
|
21
23
|
*/
|
|
22
|
-
export declare function createBuildJobLog(): Promise<{
|
|
24
|
+
export declare function createBuildJobLog(loadRedactor?: () => Promise<PatternRedactor>): Promise<{
|
|
23
25
|
/** Retained buffer capacity, distinct from the transient encoded result. */
|
|
24
26
|
readonly allocatedBytes: number;
|
|
25
27
|
append(bytes: Uint8Array): void;
|
package/dist/build/job-log.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
import { base64url } from "jose";
|
|
3
3
|
import { boundedDiagnostic } from "@fungi.computer/bird-dog/effect";
|
|
4
|
-
import { loadPatternRedactor, } from "@fungi.computer/veil/redaction";
|
|
4
|
+
import { loadPatternRedactor, maskSpans, } from "@fungi.computer/veil/redaction";
|
|
5
5
|
/** Maximum retained combined stdout/stderr bytes, split equally into head and tail. */
|
|
6
6
|
export const buildJobLogMaxBytes = 2 * 1024 * 1024;
|
|
7
7
|
/** Base64url preserves raw command bytes, including split UTF-8 and terminal control bytes. */
|
|
@@ -102,15 +102,16 @@ function textToBytes(text) {
|
|
|
102
102
|
*/
|
|
103
103
|
const scanWindow = 16 * 1024;
|
|
104
104
|
const maxPendingText = 1024 * 1024;
|
|
105
|
+
const secretsOf = (matches) => matches.map(({ secret }) => secret);
|
|
105
106
|
/** What a host writes where it cannot redact: the ADR's form, never raw output. */
|
|
106
107
|
export const redactionWithheld = "[output withheld: redaction unavailable]";
|
|
107
108
|
/**
|
|
108
109
|
* The redactor, or undefined when its rules cannot load: callers then write
|
|
109
110
|
* {@link redactionWithheld} and never the unredacted text.
|
|
110
111
|
*/
|
|
111
|
-
async function loadRedactorOrWithhold() {
|
|
112
|
+
async function loadRedactorOrWithhold(load) {
|
|
112
113
|
try {
|
|
113
|
-
return { redactor: await
|
|
114
|
+
return { redactor: await load() };
|
|
114
115
|
}
|
|
115
116
|
catch (cause) {
|
|
116
117
|
console.error("redaction rules failed to load", cause instanceof Error ? cause.name : "unknown");
|
|
@@ -120,12 +121,13 @@ async function loadRedactorOrWithhold() {
|
|
|
120
121
|
/**
|
|
121
122
|
* One bounded sink for a build's combined output. Veil's pattern redactor
|
|
122
123
|
* (S3's gitleaks rules) runs before a byte is retained, so the stored log and
|
|
123
|
-
* every `?log` read of it are already scrubbed.
|
|
124
|
+
* every `?log` read of it are already scrubbed. `loadRedactor` is Veil's
|
|
125
|
+
* loader unless a caller wraps it (a test that counts scanned characters).
|
|
124
126
|
*/
|
|
125
|
-
export async function createBuildJobLog() {
|
|
127
|
+
export async function createBuildJobLog(loadRedactor = loadPatternRedactor) {
|
|
126
128
|
const ring = createBoundedLog();
|
|
127
129
|
// A rule table that cannot load stores the withheld notice, never the output.
|
|
128
|
-
const { redactor } = await loadRedactorOrWithhold();
|
|
130
|
+
const { redactor } = await loadRedactorOrWithhold(loadRedactor);
|
|
129
131
|
let pending = "";
|
|
130
132
|
let scannedLength = 0;
|
|
131
133
|
const scan = (final) => {
|
|
@@ -136,25 +138,38 @@ export async function createBuildJobLog() {
|
|
|
136
138
|
ring.append(textToBytes(redactionWithheld));
|
|
137
139
|
return;
|
|
138
140
|
}
|
|
139
|
-
const
|
|
141
|
+
const matches = redactor.find(pending);
|
|
142
|
+
if (matches === undefined) {
|
|
143
|
+
// Over Veil's size ceiling: withhold this text, never pass it raw.
|
|
144
|
+
ring.append(textToBytes(redactionWithheld));
|
|
145
|
+
pending = "";
|
|
146
|
+
scannedLength = 0;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
140
149
|
if (final) {
|
|
141
|
-
ring.append(textToBytes(
|
|
150
|
+
ring.append(textToBytes(maskSpans(pending, secretsOf(matches))));
|
|
142
151
|
pending = "";
|
|
143
152
|
scannedLength = 0;
|
|
144
153
|
return;
|
|
145
154
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
while (unchanged < text.length &&
|
|
150
|
-
unchanged < pending.length &&
|
|
151
|
-
text[text.length - 1 - unchanged] ===
|
|
152
|
-
pending[pending.length - 1 - unchanged])
|
|
153
|
-
unchanged++;
|
|
154
|
-
if (text.length > scanWindow &&
|
|
155
|
-
(unchanged >= scanWindow || text.length > maxPendingText)) {
|
|
155
|
+
if (pending.length > maxPendingText) {
|
|
156
|
+
// Ceiling: emit all but the last window, masked on both sides of the cut.
|
|
157
|
+
const text = maskSpans(pending, secretsOf(matches));
|
|
156
158
|
ring.append(textToBytes(text.slice(0, text.length - scanWindow)));
|
|
157
159
|
pending = text.slice(text.length - scanWindow);
|
|
160
|
+
scannedLength = pending.length;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// A match reaching into the last window could still grow with later
|
|
164
|
+
// output, so it stays pending raw, with its whole match as rescan context.
|
|
165
|
+
// Walking by descending start also holds any match that overlaps one held.
|
|
166
|
+
let cut = pending.length - scanWindow;
|
|
167
|
+
for (const { match } of [...matches].sort((left, right) => right.match.start - left.match.start))
|
|
168
|
+
if (match.start < cut && match.end > cut)
|
|
169
|
+
cut = match.start;
|
|
170
|
+
if (cut > 0) {
|
|
171
|
+
ring.append(textToBytes(maskSpans(pending.slice(0, cut), secretsOf(matches).filter(({ end }) => end <= cut))));
|
|
172
|
+
pending = pending.slice(cut);
|
|
158
173
|
}
|
|
159
174
|
scannedLength = pending.length;
|
|
160
175
|
};
|
|
@@ -179,7 +194,7 @@ const buildJobLogReference = (jobId) => `/api/builds/${encodeURIComponent(jobId)
|
|
|
179
194
|
/** Preserve BirdDog's redacted 200-character status/mail budget and name the full log. */
|
|
180
195
|
export async function buildJobDiagnostic(jobId, detail) {
|
|
181
196
|
const reference = `Log: ${buildJobLogReference(jobId)}`;
|
|
182
|
-
const { redactor } = await loadRedactorOrWithhold();
|
|
197
|
+
const { redactor } = await loadRedactorOrWithhold(loadPatternRedactor);
|
|
183
198
|
const diagnostic = boundedDiagnostic(redactor === undefined ? redactionWithheld : redactor.redact(detail).text) ?? "Build finished";
|
|
184
199
|
return `${reference}\n${diagnostic.slice(0, 200 - reference.length - 1)}`;
|
|
185
200
|
}
|