Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option for disabling file downloads #5055

Merged
merged 18 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
args.password = process.env.PASSWORD
}

if (process.env.CS_DISABLE_FILE_DOWNLOADS) {
jsjoeio marked this conversation as resolved.
Show resolved Hide resolved
args["disable-file-downloads"] = true
}

const usingEnvHashedPassword = !!process.env.HASHED_PASSWORD
if (process.env.HASHED_PASSWORD) {
args["hashed-password"] = process.env.HASHED_PASSWORD
Expand All @@ -556,6 +560,7 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
delete process.env.PASSWORD
delete process.env.HASHED_PASSWORD
delete process.env.GITHUB_TOKEN
delete process.env.CS_DISABLE_FILE_DOWNLOADS
jsjoeio marked this conversation as resolved.
Show resolved Hide resolved

// Filter duplicate proxy domains and remove any leading `*.`.
const proxyDomains = new Set((args["proxy-domain"] || []).map((d) => d.replace(/^\*\./, "")))
Expand Down
12 changes: 12 additions & 0 deletions test/unit/node/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,18 @@ describe("parser", () => {
expect(process.env.GITHUB_TOKEN).toBe(undefined)
})

it("should use env var CS_DISABLE_FILE_DOWNLOADS", async () => {
process.env.CS_DISABLE_FILE_DOWNLOADS = "0"
const args = parse([])
expect(args).toEqual({})

const defaultArgs = await setDefaults(args)
expect(defaultArgs).toEqual({
...defaults,
"disable-file-downloads": true,
})
})

it("should error if password passed in", () => {
expect(() => parse(["--password", "supersecret123"])).toThrowError(
"--password can only be set in the config file or passed in via $PASSWORD",
Expand Down