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: Removing stack trace info in production env #11657

Merged
merged 22 commits into from
Aug 21, 2023
Merged
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
12 changes: 6 additions & 6 deletions packages/backend/src/server/web/ClientServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ export class ClientServerService {
if (request.url === bullBoardPath || request.url.startsWith(bullBoardPath + '/')) {
const token = request.cookies.token;
if (token == null) {
reply.code(401);
throw new Error('login required');
reply.code(401).send('Login required');
return;
}
const user = await this.usersRepository.findOneBy({ token });
if (user == null) {
reply.code(403);
throw new Error('no such user');
reply.code(403).send('No such user');
return;
}
const isAdministrator = await this.roleService.isAdministrator(user);
if (!isAdministrator) {
reply.code(403);
throw new Error('access denied');
reply.code(403).send('Access denied');
return;
}
}
});
Expand Down
12 changes: 11 additions & 1 deletion packages/backend/test/e2e/fetch-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe('Webリソース', () => {
let aliceGalleryPost: any;
let aliceChannel: any;

let bob: misskey.entities.MeSignup;

type Request = {
path: string,
accept?: string,
Expand Down Expand Up @@ -90,6 +92,8 @@ describe('Webリソース', () => {
fileIds: [aliceUploadedFile.body.id],
});
aliceChannel = await channel(alice, {});

bob = await signup({ username: 'alice' });
}, 1000 * 60 * 2);

afterAll(async () => {
Expand Down Expand Up @@ -163,9 +167,15 @@ describe('Webリソース', () => {
});

describe.each([{ path: '/queue' }])('$path', ({ path }) => {
test('はログインしないとGETできない。', async () => await notOk({
path,
status: 401,
}));

test('はadminでなければGETできない。', async () => await notOk({
path,
status: 500, // FIXME? 403ではない。
cookie: cookie(bob),
status: 403,
}));

test('はadminならGETできる。', async () => await ok({
Expand Down