mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 01:38:19 +08:00
core: fix argument validation for script
This commit is contained in:
1 parent
61597151a8
commit
c43663a1d1
5 files changed
+5
-13
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.23.12",
|
||||
"version": "2.23.13",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -108,7 +108,7 @@ class SystemScriptHandler extends SystemHandler {
|
||||
if (!global.Hydro.script[id]) throw new ValidationError('id');
|
||||
const args = JSON.parse(raw);
|
||||
validate(global.Hydro.script[id].validate, args);
|
||||
const rid = await record.add(domainId, -1, this.user._id, '-', id, false, 'raw');
|
||||
const rid = await record.add(domainId, -1, this.user._id, '-', id, false, raw);
|
||||
const report = (data) => judge.next({ domainId, rid, ...data });
|
||||
report({ message: `Running script: ${id} `, status: STATUS.STATUS_JUDGING });
|
||||
const start = new Date().getTime();
|
||||
|
||||
@@ -182,7 +182,6 @@ SystemSetting(
|
||||
Setting('setting_session', 'session.unsaved_expire_seconds', 3600 * 3,
|
||||
'number', 'session.unsaved_expire_seconds', 'Unsaved session expire seconds'),
|
||||
Setting('setting_storage', 'db.ver', 0, 'number', 'db.ver', 'Database version', FLAG_DISABLED | FLAG_HIDDEN),
|
||||
Setting('setting_storage', 'user', 1, 'number', 'user', 'User Counter', FLAG_DISABLED | FLAG_HIDDEN),
|
||||
Setting('setting_storage', 'installid', String.random(64), 'text', 'installid', 'Installation ID', FLAG_HIDDEN | FLAG_DISABLED),
|
||||
);
|
||||
|
||||
|
||||
@@ -76,11 +76,9 @@ export async function run({
|
||||
}
|
||||
|
||||
export const validate = {
|
||||
$or: [
|
||||
{ address: 'string' },
|
||||
{ discuss: ObjectID },
|
||||
{ user: 'number' },
|
||||
],
|
||||
address: 'string?',
|
||||
discuss: 'string?',
|
||||
user: 'number?',
|
||||
dryrun: 'boolean?',
|
||||
};
|
||||
|
||||
|
||||
@@ -489,11 +489,6 @@ export async function run({
|
||||
report({ message: 'No valid installation found' });
|
||||
return false;
|
||||
}
|
||||
await dst.collection('system').updateOne(
|
||||
{ _id: 'user' },
|
||||
{ $set: { value: userCounter.value } },
|
||||
{ upsert: true },
|
||||
);
|
||||
await report({ progress: 1, message: 'Collection:system done.' });
|
||||
if (!await dst.collection('system').findOne({ _id: 'migrateVijosFs' })) {
|
||||
const f = ['fs.files', 'fs.chunks'] as any;
|
||||
|
||||
Reference in new issue
Block a user