Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
LYkcul committed Oct 9, 2023
2 parents c7df8bd + 47b8c06 commit 8d6d039
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 39 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"test": "node test/entry.js",
"benchmark": "cross-env BENCHMARK=true node test/entry.js",
"lint": "eslint packages plugins modules --ext .ts,.tsx,.jsx --fix",
"lint:ci": "eslint packages plugins modules --ext .ts,.tsx,.jsx",
"lint:ci": "eslint packages plugins modules --ext .ts,.tsx,.jsx --max-warnings=0",
"lint:ui": "yarn workspace @hydrooj/ui-default lint --ext .js,.ts,.jsx,.tsx . --fix",
"lint:ui:ci": "yarn workspace @hydrooj/ui-default lint --ext .js,.ts,.jsx,.tsx .",
"lint:ui:ci": "yarn workspace @hydrooj/ui-default lint --ext .js,.ts,.jsx,.tsx . --max-warnings=0",
"debug": "node --trace-warnings --async-stack-traces --trace-deprecation packages/hydrooj/bin/hydrooj --debug --template",
"start": "packages/hydrooj/bin/hydrooj",
"postinstall": "node build/prepare.js",
Expand All @@ -32,11 +32,11 @@
"license": "AGPL-3.0-only",
"devDependencies": {
"@simplewebauthn/typescript-types": "^8.0.0",
"@types/autocannon": "^7.12.0",
"@types/autocannon": "^7.12.1",
"@types/cross-spawn": "^6.0.3",
"@types/node": "^20.6.1",
"@types/semver": "^7.5.2",
"@types/supertest": "^2.0.12",
"@types/semver": "^7.5.3",
"@types/supertest": "^2.0.13",
"autocannon": "^7.12.0",
"cac": "^6.7.14",
"chokidar": "^3.5.3",
Expand All @@ -62,7 +62,7 @@
"ora": "^6.3.1",
"postcss-loader": "7.3.2",
"semver": "^7.5.4",
"simple-git": "^3.19.1",
"simple-git": "^3.20.0",
"style-loader": "^3.3.3",
"stylus": "^0.60.0",
"stylus-loader": "7.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "MIT",
"main": "react.yaml",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-plugin-import": "2.28.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/geoip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0-or-later",
"dependencies": {
"maxmind": "^4.3.11"
"maxmind": "^4.3.13"
},
"preferUnplugged": true,
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrojudge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"preferUnplugged": true,
"license": "AGPL-3.0-or-later",
"devDependencies": {
"@types/shell-quote": "^1.7.1",
"@types/ws": "^8.5.5"
"@types/shell-quote": "^1.7.2",
"@types/ws": "^8.5.6"
}
}
4 changes: 2 additions & 2 deletions packages/hydrojudge/src/judge/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function judgeCase(c: NormalizedCase) {
},
);
const {
code, time, memory, fileIds,
code, signalled, time, memory, fileIds,
} = res;
let { status } = res;
let message: any = '';
Expand All @@ -50,7 +50,7 @@ function judgeCase(c: NormalizedCase) {
}));
}
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code) {
if (code < 32) message = signals[code];
if (code < 32 && signalled) message = signals[code];
else message = { message: 'Your program returned {0}.', params: [code] };
}
await Promise.allSettled(Object.values(res.fileIds).map((id) => del(id)));
Expand Down
6 changes: 4 additions & 2 deletions packages/hydrojudge/src/judge/hack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export async function judge(ctx: Context) {
cacheStdoutAndStderr: true,
},
);
const { code, time, memory } = res;
const {
code, signalled, time, memory,
} = res;
let { status } = res;
let message: any = '';
if (status === STATUS.STATUS_ACCEPTED) {
Expand All @@ -73,7 +75,7 @@ export async function judge(ctx: Context) {
}));
}
} else if (status === STATUS.STATUS_RUNTIME_ERROR && code) {
if (code < 32) message = signals[code];
if (code < 32 && signalled) message = signals[code];
else message = { message: 'Your program returned {0}.', params: [code] };
}
await Promise.allSettled(Object.values(res.fileIds).map((id) => del(id)));
Expand Down
6 changes: 4 additions & 2 deletions packages/hydrojudge/src/judge/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ function judgeCase(c: NormalizedCase) {
return async (ctx: Context, ctxSubtask: ContextSubTask) => {
ctx.executeInteractor.copyIn.in = c.input ? { src: c.input } : { content: '' };
ctx.executeInteractor.copyIn.out = c.output ? { src: c.output } : { content: '' };
const [{ code, time, memory }, resInteractor] = await runPiped(
const [{
code, signalled, time, memory,
}, resInteractor] = await runPiped(
{
execute: ctx.executeUser.execute,
copyIn: ctx.executeUser.copyIn,
Expand All @@ -39,7 +41,7 @@ function judgeCase(c: NormalizedCase) {
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
} else if ((code && code !== 13/* Broken Pipe */) || (code === 13 && !resInteractor.code)) {
status = STATUS.STATUS_RUNTIME_ERROR;
if (code < 32) message = signals[code];
if (code < 32 && signalled) message = signals[code];
else message = { message: 'Your program returned {0}.', params: [code] };
} else {
const result = parse(resInteractor.stderr, c.score);
Expand Down
6 changes: 4 additions & 2 deletions packages/hydrojudge/src/judge/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export const judge = async (ctx: Context) => {
},
1,
);
const { code, time, memory } = res;
const {
code, signalled, time, memory,
} = res;
let { status } = res;
const message: string[] = [];
if (time > parseTimeMS(ctx.config.time || '1s')) {
Expand All @@ -66,7 +68,7 @@ export const judge = async (ctx: Context) => {
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
} else if (code) {
status = STATUS.STATUS_RUNTIME_ERROR;
if (code < 32) message.push(`ExitCode: ${code} (${signals[code]})`);
if (code < 32 && signalled) message.push(`ExitCode: ${code} (${signals[code]})`);
else message.push(`ExitCode: ${code}`);
}
message.push(res.stdout, res.stderr);
Expand Down
2 changes: 2 additions & 0 deletions packages/hydrojudge/src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface Parameter {
interface SandboxAdaptedResult {
status: number;
code: number;
signalled: boolean;
/** in miliseconds */
time: number;
/** in kilobytes */
Expand Down Expand Up @@ -114,6 +115,7 @@ async function adaptResult(result: SandboxResult, params: Parameter): Promise<Sa
// FIXME: Signalled?
const ret: SandboxAdaptedResult = {
status: statusMap.get(result.status) || STATUS.STATUS_ACCEPTED,
signalled: result.status === SandboxStatus.Signalled,
time: result.time / 1000000 / rate,
memory: result.memory / 1024,
files: result.files,
Expand Down
16 changes: 8 additions & 8 deletions packages/hydrooj/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
},
"preferUnplugged": true,
"dependencies": {
"@aws-sdk/client-s3": "3.414.0",
"@aws-sdk/lib-storage": "3.414.0",
"@aws-sdk/client-s3": "3.418.0",
"@aws-sdk/lib-storage": "3.418.0",
"@aws-sdk/middleware-endpoint": "3.374.0",
"@aws-sdk/s3-presigned-post": "3.414.0",
"@aws-sdk/s3-request-presigner": "3.414.0",
"@aws-sdk/s3-presigned-post": "3.418.0",
"@aws-sdk/s3-request-presigner": "3.418.0",
"@graphql-tools/schema": "^10.0.0",
"@hydrooj/utils": "workspace:*",
"@simplewebauthn/server": "^8.1.1",
Expand Down Expand Up @@ -66,12 +66,12 @@
"@types/koa-static-cache": "^5.1.2",
"@types/lodash": "^4.14.198",
"@types/mime-types": "^2.1.1",
"@types/nodemailer": "^6.4.10",
"@types/notp": "^2.0.2",
"@types/nodemailer": "^6.4.11",
"@types/notp": "^2.0.3",
"@types/saslprep": "^1.0.1",
"@types/semver": "^7.5.2",
"@types/semver": "^7.5.3",
"@types/serialize-javascript": "^5.0.2",
"@types/superagent": "^4.1.18",
"@types/superagent": "^4.1.19",
"@types/tar": "^6.1.6",
"moment": "^2.29.4"
}
Expand Down
9 changes: 7 additions & 2 deletions packages/hydrooj/src/handler/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export class UserRegisterHandler extends Handler {
const mailDomain = mail.split('@')[1];
if (await BlackListModel.get(`mail::${mailDomain}`)) throw new BlacklistedError(mailDomain);
await Promise.all([
this.limitRate(`send_mail_${mail}`, 60, 3, false),
this.limitRate('send_mail', 3600, 30, false),
oplog.log(this, 'user.register', {}),
]);
Expand All @@ -265,7 +266,11 @@ export class UserRegisterHandler extends Handler {
} else this.response.redirect = this.url('user_register_with_code', { code: t[0] });
} else if (phoneNumber) {
if (!global.Hydro.lib.sendSms) throw new SystemError('Cannot send sms');
await this.limitRate('send_sms', 60, 3);
await Promise.all([
this.limitRate(`send_sms_${phoneNumber}`, 60, 1, false),
this.limitRate('send_sms', 3600, 15, false),
oplog.log(this, 'user.register', {}),
]);
const id = String.random(6, '0123456789');
await token.add(
token.TYPE_REGISTRATION,
Expand Down Expand Up @@ -334,7 +339,7 @@ class UserLostPassHandler extends Handler {
if (!udoc) throw new UserNotFoundError(mail);
await Promise.all([
this.limitRate('send_mail', 3600, 30, false),
this.limitRate(`user_lostpass_${mail}`, 60, 5, false),
this.limitRate(`user_lostpass_${mail}`, 60, 3, false),
oplog.log(this, 'user.lostpass', {}),
]);
const [tid] = await token.add(
Expand Down
14 changes: 7 additions & 7 deletions packages/ui-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"cli": false
},
"devDependencies": {
"@blueprintjs/core": "^5.3.0",
"@blueprintjs/core": "^5.3.2",
"@fontsource/dm-mono": "^5.0.12",
"@fontsource/fira-code": "^5.0.8",
"@fontsource/inconsolata": "^5.0.8",
Expand All @@ -31,18 +31,18 @@
"@types/json-schema": "^7.0.13",
"@types/katex": "^0.16.3",
"@types/markdown-it": "^13.0.1",
"@types/pickadate": "^3.5.32",
"@types/pickadate": "^3.5.33",
"@types/qrcode": "^1.5.2",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"@types/redux-logger": "^3.0.9",
"@types/serviceworker": "^0.0.73",
"@types/sharedworker": "^0.0.102",
"@types/webpack-env": "^1.18.1",
"@types/serviceworker": "^0.0.74",
"@types/sharedworker": "^0.0.103",
"@types/webpack-env": "^1.18.2",
"@vscode/codicons": "^0.0.33",
"ajv": "^8.12.0",
"allotment": "^1.19.3",
"autoprefixer": "^10.4.15",
"autoprefixer": "^10.4.16",
"browser-update": "^3.3.44",
"chalk": "^5.3.0",
"classnames": "^2.3.2",
Expand Down Expand Up @@ -103,7 +103,7 @@
"through2": "^4.0.2",
"timeago-react": "^3.0.6",
"timeago.js": "^4.0.2",
"vditor": "^3.9.5",
"vditor": "^3.9.6",
"vinyl-buffer": "^1.0.1",
"web-streams-polyfill": "^3.2.1"
},
Expand Down
1 change: 1 addition & 0 deletions packages/ui-default/pages/record_main.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const page = new NamedPage('record_main', async () => {
dd.apply($oldTr[0], dd.diff($oldTr[0], $newTr[0]));
$oldTr.trigger('vjContentNew');
} else {
if (+new URLSearchParams(window.location.search).get('page') > 1) return;
$('.record_main__table tbody').prepend($newTr);
$('.record_main__table tbody tr:last').remove();
$newTr.trigger('vjContentNew');
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ interface MatchRule {

const SubtaskMatcher: MatchRule[] = [
{
regex: /^(([A-Za-z0-9]*?)(?:(\d*)[-_])?(\d+))\.in$/,
regex: /^(([A-Za-z0-9]*?)(?:(\d*)[-_])?(\d+))\.(in|txt)$/,
output: [
(a) => `${a[1]}.out`,
(a) => `${a[1]}.ans`,
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"reggol": "^1.5.1",
"search-query-parser": "^1.6.0",
"source-map-support": "^0.5.21",
"systeminformation": "^5.21.7"
"systeminformation": "^5.21.9"
},
"devDependencies": {
"@types/fs-extra": "^11.0.2",
"@types/source-map-support": "^0.5.7"
"@types/source-map-support": "^0.5.8"
}
}

0 comments on commit 8d6d039

Please sign in to comment.