omnius 1.0.699 → 1.0.701

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.
@@ -244748,6 +244748,145 @@ init_process_lifecycle();
244748
244748
  // packages/execution/dist/tools/desktop-control.js
244749
244749
  init_system_deps();
244750
244750
 
244751
+ // packages/execution/dist/tools/archive-extract.js
244752
+ init_process_async();
244753
+ var EXTRACT = String.raw`
244754
+ import json, os, re, stat, sys, tarfile, zipfile
244755
+ source, stage = sys.argv[1:3]
244756
+ limits = json.loads(sys.argv[3])
244757
+ seen, kinds, preview = set(), {}, []
244758
+ entries = files = total = 0
244759
+ root = os.open(stage, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
244760
+
244761
+ def path_parts(name, kind):
244762
+ if not isinstance(name, str) or not name or '\x00' in name or '\\' in name or name.startswith('/') or re.match(r'^[a-zA-Z]:', name):
244763
+ raise ValueError('unsafe absolute or invalid archive path')
244764
+ raw = name.split('/')
244765
+ if '..' in raw:
244766
+ raise ValueError('archive path traversal rejected')
244767
+ parts = [part for part in raw if part not in ('', '.')]
244768
+ key = '/'.join(parts)
244769
+ if not parts and kind != 'directory':
244770
+ raise ValueError('invalid empty file path')
244771
+ if key in seen:
244772
+ raise ValueError('duplicate archive path rejected')
244773
+ seen.add(key)
244774
+ for index in range(1, len(parts)):
244775
+ parent = '/'.join(parts[:index])
244776
+ if kinds.get(parent) == 'file':
244777
+ raise ValueError('archive file/directory collision rejected')
244778
+ kinds[parent] = 'directory'
244779
+ if key in kinds and (kind != 'directory' or kinds[key] != 'directory'):
244780
+ raise ValueError('archive path collision rejected')
244781
+ if key:
244782
+ kinds[key] = kind
244783
+ return parts
244784
+
244785
+ def parent_fd(parts):
244786
+ fd = os.dup(root)
244787
+ try:
244788
+ for part in parts:
244789
+ try:
244790
+ os.mkdir(part, 0o700, dir_fd=fd)
244791
+ except FileExistsError:
244792
+ pass
244793
+ child = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=fd)
244794
+ os.close(fd)
244795
+ fd = child
244796
+ return fd
244797
+ except BaseException:
244798
+ os.close(fd)
244799
+ raise
244800
+
244801
+ def member(name, kind, declared, opener):
244802
+ global entries, files, total
244803
+ entries += 1
244804
+ if limits.get('maxEntries') is not None and entries > limits['maxEntries']:
244805
+ raise ValueError('explicit maxEntries limit exceeded')
244806
+ parts = path_parts(name, kind)
244807
+ if kind == 'directory':
244808
+ fd = parent_fd(parts)
244809
+ os.close(fd)
244810
+ else:
244811
+ if declared < 0:
244812
+ raise ValueError('invalid archive file size')
244813
+ if limits.get('maxOutputBytes') is not None and total + declared > limits['maxOutputBytes']:
244814
+ raise ValueError('explicit maxOutputBytes limit exceeded')
244815
+ fd = parent_fd(parts[:-1])
244816
+ try:
244817
+ output = os.open(parts[-1], os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600, dir_fd=fd)
244818
+ finally:
244819
+ os.close(fd)
244820
+ written = 0
244821
+ with os.fdopen(output, 'wb') as target, opener() as input_file:
244822
+ while True:
244823
+ chunk = input_file.read(1024 * 1024)
244824
+ if not chunk:
244825
+ break
244826
+ if limits.get('maxOutputBytes') is not None and total + len(chunk) > limits['maxOutputBytes']:
244827
+ raise ValueError('explicit maxOutputBytes limit exceeded')
244828
+ target.write(chunk)
244829
+ written += len(chunk)
244830
+ total += len(chunk)
244831
+ if written != declared:
244832
+ raise ValueError('archive member length mismatch')
244833
+ files += 1
244834
+ if len(preview) < 40:
244835
+ preview.append({'path': '/'.join(parts)[:512], 'kind': kind, 'bytes': declared if kind == 'file' else 0})
244836
+
244837
+ try:
244838
+ if zipfile.is_zipfile(source):
244839
+ archive_format = 'zip'
244840
+ with zipfile.ZipFile(source) as archive:
244841
+ for info in archive.infolist():
244842
+ mode = stat.S_IFMT(info.external_attr >> 16)
244843
+ if mode not in (0, stat.S_IFREG, stat.S_IFDIR):
244844
+ raise ValueError('archive links, devices and special entries are not allowed')
244845
+ kind = 'directory' if info.is_dir() or mode == stat.S_IFDIR else 'file'
244846
+ member(info.orig_filename, kind, info.file_size, lambda info=info: archive.open(info, 'r'))
244847
+ else:
244848
+ archive_format = 'tar'
244849
+ with tarfile.open(source, 'r|*') as archive:
244850
+ for info in archive:
244851
+ if not (info.isdir() or info.isreg()):
244852
+ raise ValueError('archive links, devices and special entries are not allowed')
244853
+ member(info.name, 'directory' if info.isdir() else 'file', info.size, lambda info=info: archive.extractfile(info))
244854
+ print(json.dumps({'format': archive_format, 'entries': entries, 'files': files,
244855
+ 'directories': sum(kind == 'directory' for kind in kinds.values()), 'bytes': total,
244856
+ 'preview': preview, 'previewOmitted': max(0, entries - len(preview))}))
244857
+ except BaseException as error:
244858
+ # Exception messages from standard readers can contain untrusted filenames;
244859
+ # report a bounded JSON string, never executable or control-sequence output.
244860
+ print(json.dumps({'error': str(error)[:600]}), file=sys.stderr)
244861
+ sys.exit(1)
244862
+ finally:
244863
+ os.close(root)
244864
+ `;
244865
+ var PUBLISH = String.raw`
244866
+ import ctypes, errno, json, os, stat, sys
244867
+ parent, stage, target, dev, ino = sys.argv[1:]
244868
+ try:
244869
+ fd = os.open(parent, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
244870
+ entry = os.stat(stage, dir_fd=fd, follow_symlinks=False)
244871
+ if not stat.S_ISDIR(entry.st_mode) or entry.st_dev != int(dev) or entry.st_ino != int(ino):
244872
+ raise ValueError('staging ownership changed before publication')
244873
+ libc = ctypes.CDLL(None, use_errno=True)
244874
+ rename = getattr(libc, 'renameat2', None)
244875
+ if rename is None:
244876
+ raise ValueError('atomic no-replace directory publication is unavailable on this platform')
244877
+ rename.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint]
244878
+ rename.restype = ctypes.c_int
244879
+ if rename(fd, os.fsencode(stage), fd, os.fsencode(target), 1) != 0:
244880
+ code = ctypes.get_errno()
244881
+ if code == errno.EEXIST:
244882
+ raise ValueError('destination already exists; nothing was overwritten')
244883
+ raise OSError(code, os.strerror(code))
244884
+ os.close(fd)
244885
+ except BaseException as error:
244886
+ print(json.dumps({'error': str(error)[:600]}), file=sys.stderr)
244887
+ sys.exit(1)
244888
+ `;
244889
+
244751
244890
  // packages/execution/dist/tools/change-log.js
244752
244891
  import { randomBytes } from "node:crypto";
244753
244892
  var _sessionId = `session-${Date.now()}-${randomBytes(3).toString("hex")}`;