Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/opencode/src/flag/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export namespace Flag {
export const OPENCODE_FAKE_VCS = process.env["OPENCODE_FAKE_VCS"]
export declare const OPENCODE_CLIENT: string
export const OPENCODE_SERVER_PASSWORD = process.env["OPENCODE_SERVER_PASSWORD"]
delete process.env["OPENCODE_SERVER_PASSWORD"]
export const OPENCODE_SERVER_USERNAME = process.env["OPENCODE_SERVER_USERNAME"]
export const OPENCODE_ENABLE_QUESTION_TOOL = truthy("OPENCODE_ENABLE_QUESTION_TOOL")

Expand Down
22 changes: 22 additions & 0 deletions packages/opencode/test/bun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ describe("BunProc registry configuration", () => {
}
})
})

describe("Flag server password", () => {
test("removes OPENCODE_SERVER_PASSWORD from env on load", async () => {
const key = "OPENCODE_SERVER_PASSWORD"
const original = process.env[key]
process.env[key] = "secret"

try {
const flagPath = path.join(__dirname, "../src/flag/flag.ts")
const tempPath = path.join(path.dirname(flagPath), `flag-${Date.now()}-${Math.random().toString(16).slice(2)}.ts`)
const content = await fs.readFile(flagPath, "utf-8")
await fs.writeFile(tempPath, content)

const { Flag } = await import(tempPath)
expect(Flag.OPENCODE_SERVER_PASSWORD).toBe("secret")
expect(process.env[key]).toBeUndefined()
} finally {
if (original === undefined) delete process.env[key]
else process.env[key] = original
}
})
})
Loading