1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-04 05:08:06 +02:00

PS-1230 PS-1152 Fix/improve null origin message (#3280)

* Improve message if Origin header value is empty

* PS-1230 Remove serve feature flag
This commit is contained in:
Matt Gibson 2022-08-11 08:00:27 -06:00 committed by GitHub
parent 4a1c3eb1ec
commit 6e68761337
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 40 deletions

View File

@ -1,5 +1,3 @@
{ {
"flags": { "flags": {}
"serve": true
}
} }

View File

@ -1,5 +1,3 @@
{ {
"flags": { "flags": {}
"serve": true
}
} }

View File

@ -6,6 +6,7 @@ import * as koaBodyParser from "koa-bodyparser";
import * as koaJson from "koa-json"; import * as koaJson from "koa-json";
import { KeySuffixOptions } from "@bitwarden/common/enums/keySuffixOptions"; import { KeySuffixOptions } from "@bitwarden/common/enums/keySuffixOptions";
import { Utils } from "@bitwarden/common/misc/utils";
import { Response } from "@bitwarden/node/cli/models/response"; import { Response } from "@bitwarden/node/cli/models/response";
import { FileResponse } from "@bitwarden/node/cli/models/response/fileResponse"; import { FileResponse } from "@bitwarden/node/cli/models/response/fileResponse";
@ -167,7 +168,13 @@ export class ServeCommand {
.use(async (ctx, next) => { .use(async (ctx, next) => {
if (protectOrigin && ctx.headers.origin != undefined) { if (protectOrigin && ctx.headers.origin != undefined) {
ctx.status = 403; ctx.status = 403;
this.main.logService.warning(`Blocking request from ${ctx.headers.origin}`); this.main.logService.warning(
`Blocking request from "${
Utils.isNullOrEmpty(ctx.headers.origin)
? "(Origin header value missing)"
: ctx.headers.origin
}"`
);
return; return;
} }
await next(); await next();

View File

@ -1,5 +1,5 @@
export type Flags = { // Remove this linter hint if any flags exist
serve?: boolean; // eslint-disable-next-line @typescript-eslint/ban-types
}; export type Flags = {};
export type FlagName = keyof Flags; export type FlagName = keyof Flags;

View File

@ -470,7 +470,6 @@ export class Program extends BaseProgram {
this.processResponse(response); this.processResponse(response);
}); });
if (CliUtils.flagEnabled("serve")) {
program program
.command("serve") .command("serve")
.description("Start a RESTful API webserver.") .description("Start a RESTful API webserver.")
@ -500,7 +499,6 @@ export class Program extends BaseProgram {
await command.run(cmd); await command.run(cmd);
}); });
} }
}
protected processResponse(response: Response, exitImmediately = false) { protected processResponse(response: Response, exitImmediately = false) {
super.processResponse(response, exitImmediately, () => { super.processResponse(response, exitImmediately, () => {