judge: 测试数据组数过多时拒绝评测

This commit is contained in:
undefined committed 2020-10-30 23:28:00 +08:00
1 parent 1231fb2ce7
commit 13e874d139
6 files changed
+21 -30

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.1.14",
"version": "2.1.15",
"main": "package.json",
"author": "masnn",
"repository": "https://github.com/hydro-dev/Hydro.git",
+3 -1
View File
@@ -293,5 +293,7 @@ export default async function readCases(folder: string, cfg: Record<string, any>
} else if (fs.existsSync(iniConfig)) {
config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg };
}
return await readYamlCases(folder, config, args);
const result = await readYamlCases(folder, config, args);
if (result.count > 100) throw new FormatError('测试数据组数过多,拒绝评测');
return result;
}
+7 -7
View File
@@ -50,7 +50,7 @@ class JudgeTask {
nextWaiting = [];
constructor(session, request, ws: WebSocket) {
constructor(session: VJ4, request, ws: WebSocket) {
this.stat = {};
this.stat.receive = new Date();
this.session = session;
@@ -230,7 +230,7 @@ export default class VJ4 {
return 'unknown';
}
async problemData(domainId: string, pid: string, savePath, retry = 3, next?) {
async problemData(domainId: string, pid: string, savePath: string, retry = 3, next?) {
log.info(`Getting problem data: ${this.config.host}/${domainId}/${pid}`);
await this.ensureLogin();
if (next) next({ judge_text: '正在同步测试数据,请稍后' });
@@ -249,7 +249,7 @@ export default class VJ4 {
fs.ensureDirSync(path.dirname(savePath));
const zip = new AdmZip(tmpFilePath);
const entries = zip.getEntries();
if (entries.length > 1000) throw new FormatError('Too many files');
if (entries.length > 256) throw new FormatError('Too many files');
await new Promise((resolve, reject) => {
zip.extractAllToAsync(savePath, true, (e) => {
if (e) reject(e);
@@ -279,7 +279,7 @@ export default class VJ4 {
fs.ensureDirSync(path.dirname(savePath));
const zip = new AdmZip(tmpFilePath);
const entries = zip.getEntries();
if (entries.length > 1000) throw new FormatError('Too many files');
if (entries.length > 256) throw new FormatError('Too many files');
await new Promise((resolve, reject) => {
zip.extractAllToAsync(savePath, true, (e) => {
if (e) reject(e);
@@ -319,7 +319,7 @@ export default class VJ4 {
log.info(`[${this.config.host}] 已连接`);
}
async setCookie(cookie) {
async setCookie(cookie: string) {
this.config.cookie = cookie;
this.axios = axios.create({
baseURL: this.config.server_url,
@@ -357,7 +357,7 @@ export default class VJ4 {
}
}
async processData(folder) { // eslint-disable-line class-methods-use-this
async processData(folder: string) { // eslint-disable-line class-methods-use-this
let files = await fs.readdir(folder);
let ini = false;
if (files.length <= 2) {
@@ -403,7 +403,7 @@ export default class VJ4 {
return filePath;
}
async retry(queue) {
async retry(queue: Queue<any>) {
this.consume(queue).catch(() => {
setTimeout(() => {
this.retry(queue);
+1 -1
View File
@@ -75,7 +75,7 @@ async function postInit() {
fs.ensureDirSync(path.dirname(savePath));
const zip = new AdmZip(tmpFilePath);
const entries = zip.getEntries();
if (entries.length > 1000) throw new FormatError('Too many files');
if (entries.length > 256) throw new FormatError('Too many files');
await new Promise((resolve, reject) => {
zip.extractAllToAsync(savePath, true, (e) => {
if (e) reject(e);