@agent-sh/agent-workspace-linux 0.1.6 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-sh/agent-workspace-linux",
3
- "version": "0.1.6",
3
+ "version": "0.2.1",
4
4
  "description": "Isolated Linux desktop workspaces for AI agents — MCP server binary wrapper.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -131,15 +131,24 @@ function parseSha256Sidecar(contents, expectedAssetName) {
131
131
 
132
132
  const candidates = [];
133
133
  for (const line of lines) {
134
- const match = line.match(/^([a-fA-F0-9]{64})(?:\s+(?:\*)?(.+))?$/);
135
- if (!match) {
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
- const [, checksum, fileName] = match;
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: fileName ? fileName.trim() : null,
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
- `\nagent-workspace-linux: checksum verification failed — ${err.message}`
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
  }