From 9496f9c3796850180afc756fdcb4659bc06db6dd Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 5 Nov 2024 09:02:20 +0800 Subject: [PATCH] fix --- packages/hydrojudge/src/interface.ts | 2 +- packages/hydrooj/src/handler/manage.ts | 4 ++-- packages/hydrooj/src/model/system.ts | 2 +- packages/hydrooj/src/service/server.ts | 4 ++-- packages/hydrooj/src/utils.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/hydrojudge/src/interface.ts b/packages/hydrojudge/src/interface.ts index 6f0427a46..85c5126d5 100644 --- a/packages/hydrojudge/src/interface.ts +++ b/packages/hydrojudge/src/interface.ts @@ -32,5 +32,5 @@ export interface Session { cacheOpen: (source: string, files: any[], next?: NextFunction) => Promise; fetchFile: (target: string) => Promise; postFile: (target: string, filename: string, file: string) => Promise; - config: { detail: boolean, host?: string }; + config: { detail: boolean, host?: string, trusted?: boolean }; } diff --git a/packages/hydrooj/src/handler/manage.ts b/packages/hydrooj/src/handler/manage.ts index d149c61a3..79ffe84bb 100644 --- a/packages/hydrooj/src/handler/manage.ts +++ b/packages/hydrooj/src/handler/manage.ts @@ -221,8 +221,8 @@ class SystemUserImportHandler extends SystemHandler { const users = _users.split('\n'); const udocs: { email: string, username: string, password: string, displayName?: string, [key: string]: any; }[] = []; const messages = []; - const mapping = {}; - const groups: Record = {}; + const mapping = Object.create(null); + const groups: Record = Object.create(null); for (const i in users) { const u = users[i]; if (!u.trim()) continue; diff --git a/packages/hydrooj/src/model/system.ts b/packages/hydrooj/src/model/system.ts index 89b7098a3..110266151 100644 --- a/packages/hydrooj/src/model/system.ts +++ b/packages/hydrooj/src/model/system.ts @@ -5,7 +5,7 @@ import { NumberKeys } from '../typeutils'; import { SYSTEM_SETTINGS } from './setting'; const coll = db.collection('system'); -const cache: Record = {}; +const cache: Record = Object.create(null); export function get(key: K): SystemKeys[K]; export function get(key: string): any; diff --git a/packages/hydrooj/src/service/server.ts b/packages/hydrooj/src/service/server.ts index 44f5d1b89..59aebcf5d 100644 --- a/packages/hydrooj/src/service/server.ts +++ b/packages/hydrooj/src/service/server.ts @@ -197,8 +197,8 @@ export async function apply(ctx: Context) { url(name: string, ...kwargsList: Record[]) { if (name === '#') return '#'; let res = '#'; - const args: any = {}; - const query: any = {}; + const args: any = Object.create(null); + const query: any = Object.create(null); for (const kwargs of kwargsList) { for (const key in kwargs) { if (kwargs[key] instanceof ObjectId) args[key] = kwargs[key].toHexString(); diff --git a/packages/hydrooj/src/utils.ts b/packages/hydrooj/src/utils.ts index eec55c4f4..2f03138b6 100644 --- a/packages/hydrooj/src/utils.ts +++ b/packages/hydrooj/src/utils.ts @@ -1,5 +1,5 @@ export function buildProjection(fields: readonly T[]): Record { - const o: Record = {} as any; + const o: Record = Object.create(null); for (const k of fields) o[k] = true; return o; }