@agent-sh/agent-workspace-linux 0.2.0 → 0.2.1
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 +1 -1
- package/scripts/postinstall.js +17 -6
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -131,15 +131,24 @@ function parseSha256Sidecar(contents, expectedAssetName) {
|
|
|
131
131
|
|
|
132
132
|
const candidates = [];
|
|
133
133
|
for (const line of lines) {
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
// Safe linear parse instead of potentially quadratic regex on untrusted sidecar content.
|
|
135
|
+
// Sidecar format: "<64-hex> [ *]<filename>"
|
|
136
|
+
const trimmed = line.trim();
|
|
137
|
+
if (!/^[a-fA-F0-9]{64}(\s+\*?(\S.*)?)?$/.test(trimmed)) {
|
|
136
138
|
throw new Error(`invalid checksum sidecar line: ${line}`);
|
|
137
139
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
const spaceIdx = trimmed.indexOf(' ');
|
|
141
|
+
let checksum, fileNamePart;
|
|
142
|
+
if (spaceIdx === -1) {
|
|
143
|
+
checksum = trimmed;
|
|
144
|
+
fileNamePart = null;
|
|
145
|
+
} else {
|
|
146
|
+
checksum = trimmed.slice(0, spaceIdx);
|
|
147
|
+
fileNamePart = trimmed.slice(spaceIdx + 1).replace(/^\*?\s*/, '');
|
|
148
|
+
}
|
|
140
149
|
candidates.push({
|
|
141
150
|
checksum: checksum.toLowerCase(),
|
|
142
|
-
fileName:
|
|
151
|
+
fileName: fileNamePart && fileNamePart.length ? fileNamePart.trim() : null,
|
|
143
152
|
});
|
|
144
153
|
}
|
|
145
154
|
|
|
@@ -222,8 +231,10 @@ async function main() {
|
|
|
222
231
|
} catch (err) {
|
|
223
232
|
removeFileQuietly(tmpPath);
|
|
224
233
|
removeFileQuietly(tmpChecksumPath);
|
|
234
|
+
// Do not interpolate raw err.message (from untrusted sidecar/network) into logs.
|
|
235
|
+
// This was flagged as log-injection (js/log-injection).
|
|
225
236
|
console.error(
|
|
226
|
-
|
|
237
|
+
"\nagent-workspace-linux: checksum verification failed. The sidecar may be malformed or the binary tampered."
|
|
227
238
|
);
|
|
228
239
|
process.exit(1);
|
|
229
240
|
}
|