<commit_before>var detectWithExtension = require("../build/detectWithExtension");
var commbuilder = require("./commbuilder");
var userdata = require("../server/userdata");
var comspath = require("./inCom").comms_root;
var fs = require('fs');
var required_cache = Object.create(null);

var createFunction = async function (data, __require, pathname) {
    var content = String(data);
    var { params, imported, required, data } = commbuilder.parse(content, pathname, pathname);
    var func = Function.apply(null, params.concat(data));
    if (!(imported instanceof Array)) imported = [];
    imported = imported.map(a => {
        if (typeof a === 'number') return __require(required[a]);
        return __require(a);
    });
    const imported_1 = await Promise.all(imported);
    return func.apply(func, imported_1);
};

var taskmap = {};
var gettask = async function (taskid) {
    var task = await userdata.option("task", taskid, 0);
    if (!task) throw new Error(`指定的任务 ${taskid} 不存在！`);
    if (!task) return null;
    var task = createFunction(task.code, async function (pathname) {
        if (global[pathname] !== undefined) return global[pathname];
        switch (pathname) {
            case "undefined": return undefined;
            case "require": return require;
            case "os":
            case "vm":
            case "net":
            case "zlib":
            case "http":
            case "https":
            case "crypto":
                return require(pathname);
            case "runtask":
                return _runtask;
            case "_private":
                return _private;
        }
    }, 'private/main');
    return task;
};<commit_msg>禁止访问未启用的任务<commit_after>var detectWithExtension = require("../build/detectWithExtension");
var commbuilder = require("./commbuilder");
var userdata = require("../server/userdata");
var comspath = require("./inCom").comms_root;
var fs = require('fs');
var required_cache = Object.create(null);

var createFunction = async function (data, __require, pathname) {
    var content = String(data);
    var { params, imported, required, data } = commbuilder.parse(content, pathname, pathname);
    var func = Function.apply(null, params.concat(data));
    if (!(imported instanceof Array)) imported = [];
    imported = imported.map(a => {
        if (typeof a === 'number') return __require(required[a]);
        return __require(a);
    });
    const imported_1 = await Promise.all(imported);
    return func.apply(func, imported_1);
};

var taskmap = {};
var gettask = async function (taskid) {
    var task = await userdata.option("task", taskid, 0);
    if (!task) throw new Error(`指定的任务 ${taskid} 不存在！`);
    if (task.status !== 1) throw new Error(`任务 ${taskid} 未启用！`);
    var task = createFunction(task.code, async function (pathname) {
        if (global[pathname] !== undefined) return global[pathname];
        switch (pathname) {
            case "undefined": return undefined;
            case "require": return require;
            case "os":
            case "vm":
            case "net":
            case "zlib":
            case "http":
            case "https":
            case "crypto":
                return require(pathname);
            case "runtask":
                return _runtask;
            case "_private":
                return _private;
        }
    }, 'private/main');
    return task;
};
{'fraction_non_alphanumeric': 0.13903586125808348, 'fraction_numerical': 0.00205761316872428, 'mean_word_length': 2.608695652173913, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5250523', 'n_tokens_mistral': 970, 'n_tokens_neox': 974, 'n_words': 272}