diff --git a/remote_judger/src/interface.ts b/remote_judger/src/interface.ts index 3b8f1b6..02a4f42 100644 --- a/remote_judger/src/interface.ts +++ b/remote_judger/src/interface.ts @@ -19,6 +19,7 @@ export interface IBasicProvider { next: NextFunction, end: NextFunction ): Promise; + ensureIsOwnSubmission(id: string): Promise; waitForSubmission( id: string, next: NextFunction, diff --git a/remote_judger/src/providers/atcoder.ts b/remote_judger/src/providers/atcoder.ts index 0e64967..53317d7 100644 --- a/remote_judger/src/providers/atcoder.ts +++ b/remote_judger/src/providers/atcoder.ts @@ -244,6 +244,10 @@ export default class AtcoderProvider implements IBasicProvider { .getAttribute('data-id'); } + async ensureIsOwnSubmission(id: string) { + throw new Error('Method not implemented.'); + } + async waitForSubmission(id: string, next, end, problem_id: string) { let count = 0; let fail = 0; diff --git a/remote_judger/src/providers/codeforces.ts b/remote_judger/src/providers/codeforces.ts index fd0d549..eb17728 100644 --- a/remote_judger/src/providers/codeforces.ts +++ b/remote_judger/src/providers/codeforces.ts @@ -344,6 +344,10 @@ export default class CodeforcesProvider implements IBasicProvider { .getAttribute('data-submission-id'); } + async ensureIsOwnSubmission(id: string) { + throw new Error('Method not implemented.'); + } + async waitForSubmission(id: string, next, end) { let count = 0; let fail = 0; diff --git a/remote_judger/src/providers/luogu.ts b/remote_judger/src/providers/luogu.ts index e20e8c1..f7e5e93 100644 --- a/remote_judger/src/providers/luogu.ts +++ b/remote_judger/src/providers/luogu.ts @@ -250,7 +250,26 @@ export default class LuoguProvider implements IBasicProvider { return result.body.rid; } - async waitForSubmission(id: string, next, end) { + async ensureIsOwnSubmission(id: string) { + const { body } = await this.safeGet(`/record/${id}?_contentOnly=1`); + + const current_uid = body.currentUser?.uid; + const submission_uid = body.currentData.record?.user.uid; + + return current_uid && submission_uid && current_uid === submission_uid; + } + + async waitForSubmission(id: string, next, end, problem_id: string) { + if (!(await this.ensureLogin())) { + await end({ + error: true, + status: 'Judgment Failed', + message: 'Login failed', + }); + + return null; + } + let fail = 0; let count = 0; @@ -262,6 +281,24 @@ export default class LuoguProvider implements IBasicProvider { const { body } = await this.safeGet(`/record/${id}?_contentOnly=1`); const data = body.currentData.record; + if (!data) { + return await end({ + error: true, + id: `R${id}`, + status: 'Judgment Failed', + message: 'Failed to fetch submission details.', + }); + } + + if (data.problem.pid != problem_id) { + return await end({ + id, + error: true, + status: 'Judgment Failed', + message: 'Submission does not match current problem.', + }); + } + if ( data.detail.compileResult && data.detail.compileResult.success === false diff --git a/remote_judger/src/providers/uoj.ts b/remote_judger/src/providers/uoj.ts index 63ce1f3..ee54086 100644 --- a/remote_judger/src/providers/uoj.ts +++ b/remote_judger/src/providers/uoj.ts @@ -206,6 +206,10 @@ export default class UOJProvider implements IBasicProvider { .innerHTML.split('#')[1]; } + async ensureIsOwnSubmission(id: string) { + throw new Error('Method not implemented.'); + } + async waitForSubmission(id: string, next, end) { let count = 0; let fail = 0; diff --git a/web/app/models/UOJRemoteProblem.php b/web/app/models/UOJRemoteProblem.php index c5addc2..fc9f278 100644 --- a/web/app/models/UOJRemoteProblem.php +++ b/web/app/models/UOJRemoteProblem.php @@ -49,7 +49,7 @@ class UOJRemoteProblem { 'short_name' => '洛谷', 'url' => 'https://www.luogu.com.cn', 'languages' => ['C', 'C++98', 'C++11', 'C++', 'C++17', 'C++20', 'Python3', 'Java8', 'Pascal'], - 'submit_type' => ['my'], + 'submit_type' => ['my', 'archive'], ], ];