mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(sandbox): bound lifecycle queue and harden install/backup paths
Bound the OpenCode supervisor lifecycle queue to one running plus one pending operation so repeated restarts cannot stack unbounded HTTP requests, while exempting stop() so shutdown is never dropped. Reject enforcement backups that carry no recoverable removed sections, matching the existing fail-closed handling of unparseable backups. Install OpenCode through a private mktemp staging directory instead of the predictable /tmp/opencode path. Use named path/os imports in the files added by this branch.
This commit is contained in:
1 parent
0481160f5e
commit
0215de9d92
9 files changed
+108
-28
No files matched your search
@@ -190,11 +190,15 @@ const runOpenCodeSection = (snippet: string, env: Record<string, string> = {}) =
|
||||
|
||||
const stubInstallTools = () => {
|
||||
writeStub('curl', `echo "curl $*" >> "$OCM_STUB_LOG"
|
||||
rm -rf /tmp/opencode /tmp/opencode.tar.gz
|
||||
out=""
|
||||
while [ "$#" -gt 0 ]; do
|
||||
if [ "$1" = "-o" ]; then out="$2"; fi
|
||||
shift
|
||||
done
|
||||
mkdir -p "$HOME/.opencode/bin"
|
||||
printf '#!/bin/bash\\necho 1.18.16\\n' > "$HOME/.opencode/bin/opencode"
|
||||
chmod +x "$HOME/.opencode/bin/opencode"
|
||||
printf 'fake binary\\n' > /tmp/opencode`)
|
||||
printf 'fake binary\\n' > "$(dirname "$out")/opencode"`)
|
||||
writeStub('tar', `echo "tar $*" >> "$OCM_STUB_LOG"`)
|
||||
}
|
||||
|
||||
@@ -208,6 +212,7 @@ describe('install_opencode', () => {
|
||||
const urls = curlLog().join(' ')
|
||||
expect(urls).toMatch(/\/releases\/download\/v1\.18\.16\//)
|
||||
expect(urls).not.toContain('/releases/latest/download/')
|
||||
expect(urls).not.toContain('/tmp/opencode.tar.gz')
|
||||
})
|
||||
|
||||
it('refuses to guess the pinned build when OPENCODE_BUNDLED_VERSION is unset', () => {
|
||||
|
||||
Reference in new issue
Block a user