@raytrace-cli/sdk 0.2.5 → 0.2.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/client.mjs +6 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raytrace-cli/sdk",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "TypeScript/JavaScript SDK for RayTrace cloud sandboxes: create, run commands, stop, start and destroy over the /v1 API",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/client.mjs CHANGED
@@ -58,12 +58,12 @@ export function buildTarGz(files) {
58
58
  }
59
59
  for (const [rawPath, content] of entries) {
60
60
  const rel = String(rawPath).replace(/^\/+/, '');
61
- if (!rel || rel.includes('..') || rel.length > 99) {
61
+ if (!rel || rel.includes('..') || Buffer.byteLength(rel, 'utf8') > 99) {
62
62
  throw new Error(`Invalid archive file path: ${rawPath}`);
63
63
  }
64
64
  const data = Buffer.isBuffer(content) ? content : Buffer.from(content);
65
65
  const header = Buffer.alloc(512, 0);
66
- header.write(rel, 0, Math.min(rel.length, 100), 'utf8');
66
+ header.write(rel, 0, 100, 'utf8');
67
67
  writeOctal(header, 100, 8, 0o644);
68
68
  writeOctal(header, 108, 8, 1000);
69
69
  writeOctal(header, 116, 8, 1000);
@@ -183,7 +183,7 @@ export async function archiveFromRepo(repo, { ref = undefined } = {}) {
183
183
  }
184
184
 
185
185
  export function archiveFromDirectory(dirPath) {
186
- const files = {};
186
+ const files = Object.create(null);
187
187
  function walk(absDir, relPrefix) {
188
188
  for (const entry of readdirSync(absDir, { withFileTypes: true })) {
189
189
  if (DEFAULT_EXCLUDED.has(entry.name)) continue;
@@ -194,9 +194,10 @@ export function archiveFromDirectory(dirPath) {
194
194
  walk(abs, rel);
195
195
  } else if (entry.isFile() && !isSecretFile(entry.name)) {
196
196
  const st = statSync(abs);
197
- if (st.size <= 25 * 1024 * 1024) {
198
- files[rel] = readFileSync(abs);
197
+ if (st.size > 25 * 1024 * 1024) {
198
+ throw new Error(`Project file ${rel} exceeds the 25 MiB size limit`);
199
199
  }
200
+ files[rel] = readFileSync(abs);
200
201
  }
201
202
  }
202
203
  }