mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: key check report
This commit is contained in:
1 parent
cf4ef57f68
commit
132ef0312c
14 files changed
+33
-20
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.11.2",
|
||||
"version": "2.11.3",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -229,6 +229,7 @@ export default async function readCases(folder: string, cfg: Record<string, any>
|
||||
result.subtasks = c.subtasks;
|
||||
result.count = c.count;
|
||||
}
|
||||
if ((!args.key) || args.key !== result.key) isValidConfig(result);
|
||||
if (args.key && args.key !== result.key) throw new FormatError('Incorrect secret key');
|
||||
if (!args.key) isValidConfig(result);
|
||||
return result;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.37.2",
|
||||
"version": "2.37.3",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -402,21 +402,25 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
@post('filename', Types.Name, true)
|
||||
@post('type', Types.Range(['testdata', 'additional_file']), true)
|
||||
async postUploadFile(domainId: string, filename: string, type = 'testdata') {
|
||||
if ((this.pdoc.data?.length || 0) + (this.pdoc.additional_file?.length || 0) >= system.get('limit.problem_files_max')) {
|
||||
if (!this.request.files.file) throw new ValidationError('file');
|
||||
if (!filename) filename = this.request.files.file.name || String.random(16);
|
||||
if (filename.includes('/') || filename.includes('..')) throw new ValidationError('filename', null, 'Bad filename');
|
||||
if (!this.user.hasPriv(PRIV.PRIV_EDIT_SYSTEM)) {
|
||||
if ((this.pdoc.data?.length || 0) + (this.pdoc.additional_file?.length || 0)
|
||||
>= system.get('limit.problem_files_max')) {
|
||||
throw new ForbiddenError('File limit exceeded.');
|
||||
}
|
||||
if (!this.request.files.file) throw new ValidationError('file');
|
||||
const size = Math.sum((this.pdoc.data || []).map((i) => i.size), (this.pdoc.additional_file || []).map((i) => i.size));
|
||||
if (size >= system.get('limit.problem_files_max_size')) {
|
||||
throw new ForbiddenError('File size limit exceeded.');
|
||||
}
|
||||
if (!filename) filename = this.request.files.file.name || String.random(16);
|
||||
if (filename.includes('/') || filename.includes('..')) throw new ValidationError('filename', null, 'Bad filename');
|
||||
}
|
||||
if (!this.user.own(this.pdoc, PERM.PERM_EDIT_PROBLEM_SELF)) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
|
||||
if (filename.endsWith('.zip')) {
|
||||
const zip = new AdmZip(this.request.files.file.path);
|
||||
const entries = zip.getEntries();
|
||||
for (const entry of entries) {
|
||||
// TODO check file size
|
||||
if (!entry.name) continue;
|
||||
if (type === 'testdata') {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
|
||||
@@ -160,12 +160,14 @@ export interface ProblemConfigFile {
|
||||
judge_extra_files?: string[];
|
||||
detail?: boolean;
|
||||
outputs?: [string, number][];
|
||||
redirect?: string;
|
||||
cases?: TestCaseConfig[];
|
||||
subtasks?: SubtaskConfig[];
|
||||
langs?: string[];
|
||||
}
|
||||
|
||||
export interface ProblemConfig {
|
||||
redirect?: [string, string];
|
||||
count: number;
|
||||
memoryMax: number;
|
||||
memoryMin: number;
|
||||
|
||||
@@ -36,6 +36,7 @@ export async function parseConfig(config: string | ProblemConfigFile = {}) {
|
||||
result.timeMax = result.timeMin = 1000;
|
||||
}
|
||||
if (cfg.langs) result.langs = cfg.langs;
|
||||
if (cfg.redirect) result.redirect = cfg.redirect.split('/', 2) as any;
|
||||
if (cfg.filename && result.type === 'default') {
|
||||
result.type = 'fileio';
|
||||
result.subType = cfg.filename;
|
||||
|
||||
@@ -88,9 +88,9 @@ export interface Types {
|
||||
}
|
||||
|
||||
export const Types: Types = {
|
||||
Content: [(v) => v.toString(), isContent],
|
||||
Name: [(v) => v.toString(), isName],
|
||||
Title: [(v) => v.toString(), isTitle],
|
||||
Content: [(v) => v.toString().trim(), isContent],
|
||||
Name: [(v) => v.toString().trim(), isName],
|
||||
Title: [(v) => v.toString().trim(), isTitle],
|
||||
String: [(v) => v.toString(), null],
|
||||
Int: [(v) => parseInt(v, 10), (v) => isSafeInteger(parseInt(v, 10))],
|
||||
UnsignedInt: [(v) => parseInt(v, 10), (v) => parseInt(v, 10) >= 0],
|
||||
|
||||
@@ -37,6 +37,7 @@ const problemConfigSchema = {
|
||||
type: 'object',
|
||||
def: problemConfigSchemaDef,
|
||||
properties: {
|
||||
redirect: { type: 'string', pattern: '[0-9a-z_-]+\\/[0-9]+' },
|
||||
key: { type: 'string', pattern: '[0-9a-f]{32}' },
|
||||
type: { enum: ['default', 'interactive', 'submit_answer', 'objective', 'remote_judge'] },
|
||||
subType: { type: 'string' },
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"compilerOptions": {
|
||||
"jsx": "react",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES6",
|
||||
"target": "ES2020",
|
||||
"baseUrl": ".",
|
||||
"moduleResolution": "node",
|
||||
"paths": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.22.2",
|
||||
"version": "4.22.3",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -39,16 +39,20 @@ const page = new NamedPage('home_messages', () => {
|
||||
type: 'DIALOGUES_MESSAGE_PUSH',
|
||||
payload: msg,
|
||||
});
|
||||
new VjNotification({
|
||||
const notification = new VjNotification({
|
||||
title: msg.udoc.uname,
|
||||
avatar: msg.udoc.avatarUrl,
|
||||
message: msg.mdoc.content,
|
||||
duration: 15000,
|
||||
action: () => store.dispatch({
|
||||
action: () => {
|
||||
store.dispatch({
|
||||
type: 'DIALOGUES_SWITCH_TO',
|
||||
payload: msg.udoc._id,
|
||||
}),
|
||||
}).show();
|
||||
});
|
||||
notification.hide();
|
||||
},
|
||||
});
|
||||
notification.show();
|
||||
};
|
||||
|
||||
const userSelector = UserSelectAutoComplete.getOrConstruct($('.dialog__body--user-select [name="user"]'));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/vjudge",
|
||||
"version": "1.3.7",
|
||||
"version": "1.3.8",
|
||||
"description": "Submit problems to remote oj",
|
||||
"main": "package.json",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -19,7 +19,7 @@ declare module 'hydrooj/src/interface' {
|
||||
}
|
||||
}
|
||||
export interface IBasicProvider {
|
||||
ensureLogin(): Promise<boolean>;
|
||||
ensureLogin(): Promise<boolean | string>;
|
||||
getProblem(id: string): Promise<{
|
||||
title: string;
|
||||
data: Record<string, any>;
|
||||
|
||||
@@ -71,11 +71,11 @@ class Service {
|
||||
|
||||
async login() {
|
||||
const login = await this.api.ensureLogin();
|
||||
if (login) {
|
||||
if (login === true) {
|
||||
logger.info(`${this.account.type}/${this.account.handle}: logged in`);
|
||||
return true;
|
||||
}
|
||||
logger.warn(`${this.account.type}/${this.account.handle}: login fail`);
|
||||
logger.warn(`${this.account.type}/${this.account.handle}: login fail`, login || '');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user