Example #1
0
  this.parseMessageRow = function (row) {
    var self = this;
    var rr = _.pick(row, "message_id", "who_from", "is_from_me", "chat_id", "text", "attachment_id", "date", "guid", "lookupValue", "mime_type");
    var fi = _.pick(row, "attachment_id", "filename", "chat_id", "mime_type", "uti");
    self.attachmentInfo[fi.attachment_id] = _.pick(fi, "filename", "chat_id", "mime_type", "uti");

    return rr;
  }
Example #2
0
 dtree.param_category_array = _.map(dtree.param_category_array, function(currentObj){
     return _.pick(currentObj,
     "category_id",
     "name",
     "description"
     );
 });
Example #3
0
 dtree.payoff_array = _.map(dtree.payoff_array, function(currentObj){
     return _.pick(currentObj,
         "payoff_id",
         "payoff_name",
         "payoff_weight"
     );
 });
Example #4
0
var User_Apply = function (args){

    if(!args){
        return ;
    }

    _.defaults(this ,  _.pick(args , 'userId' ,'applyId' ,'createTime', 'role' ));
}
Example #5
0
var Approve = function (args){

    if(!args){
        return ;
    }

    _.defaults(this ,  _.pick(args , 'id' ,'reply' , 'applyId' ));
}
Example #6
0
	this.getAttachmentPath = function (attachment_id, cb) {
    var self = this;
    var fl = self.attachmentInfo[attachment_id];

    fl.path = expandHomeDir(fl.filename);
    cb(_.pick(fl, "path", "filename", "uti", "mime_type"));

	}
Example #7
0
 dtree.table_array = _.map(dtree.table_array, function(currentObj){
     return _.pick(currentObj,
     "table_id",
     "name",
     "description",
     "value",
     "comment"
     );
 });
Example #8
0
 async.eachSeries(mergedTranslations, function(mergedTranslation, done) {
     destinationCol.update({
         _id: mergedTranslation._id
     }, {$set: _.pick(mergedTranslation, argv.p)}, function(err, numberOfUpdatedDocuments) {
         if(numberOfUpdatedDocuments) {
             successfullyUpdatedTranslations.push(mergedTranslation);
         }
         done(err, numberOfUpdatedDocuments);
     });
 }, function(err, result) {
Example #9
0
 dtree.param_array = _.map(dtree.param_array, function(currentObj){
     return _.pick(currentObj,
         "param_id",
         "name",
         "description",
         "formula",
         "category",
         "display",
         "comment"
     );
 });
Example #10
0
 dtree.distribution_array = _.map(dtree.distribution_array, function(currentObj){
     return _.pick(currentObj,
     "distr_id",
     "name",
     "description",
     "type",
     "value",
     "display",
     "comment"
     );
 });
Example #11
0
var singleRequest = function(){
    log.info("making new request");
    var request;
    
    var useStyleString = config.style;
    //find the next filename in the dir list that is a csl file
    while(true){
        if(stylesListCounter >= stylesList.length -1){
            continueRequests = false;
            return;
        }
        useStyleString = stylesList[stylesListCounter];
        stylesListCounter++;
        if(useStyleString && useStyleString.slice(-4) == '.csl'){
            useStyleString = useStyleString.replace('.csl', '');
            log.info("counter: " + stylesListCounter + ' / ' + stylesList.length + ' - ' + useStyleString);
            break;
        }
    }
    
    var qstringObject = _.extend({},
            defaultQueryObject,
            _.pick(config, 'style', 'responseformat', 'bibliography', 'citations', 'outputformat', 'linkwrap', 'locale'),
            {'style': useStyleString});
    var qstring = querystring.stringify(qstringObject);
    
    request = http.request({
        'hostname': targetHost,
        'port': 8085,
        'method': 'POST',
        'path': '/?' + qstring
    });
    request.startDate = Date.now();
    request.styleUsed = useStyleString;
    request.on('response', function (response) {
        log.info('STATUS: ' + response.statusCode);
        response.setEncoding('utf8');
        response.body = '';
        response.on('data', function (chunk) {
            this.body += chunk;
        });
        response.on('end', function(){
            curConnections--;
            this.endDate = Date.now();
            var timeElapsed = this.endDate - request.startDate;
            requestTimes.push(timeElapsed);
            var styleUsed = request.styleUsed;
            if(this.statusCode != 200){
                errorStyles.push(styleUsed);
            }
            else{
                passedStyles.push(styleUsed);
            }
            log.info("timeElapsed: " + timeElapsed);
            connectionResults.push({
                'status':this.statusCode,
                'body':this.body,
                'requestTime': timeElapsed
            });
            if(config.showoutput){
                log.info(this.body);
            }
            log.info("curConnections: " + curConnections);
            log.info("continueRequests: " + continueRequests);
            if(!continueRequests && curConnections < 3){
                outputStats();
            }
        });
    });
    request.write(reqBody, 'utf8');
    request.end();
};
Example #12
0
 var profileArray =underscore._.map(docs, function(obj){return underscore._.pick(obj, 'title', 'description', 'backgroundImage')});
Example #13
0
  .option('')
  .option('--jspath <path>', 'Folder to scan for javascript files')
  .option('--nodepath <path>', 'Folder to scan for node files')
  .option('--path <path>', 'Folder to scan for both')
  .option('--jsrepo <path|url>', 'Local or internal version of repo')
  .option('--noderepo <path|url>', 'Local or internal version of repo')
  .option('--proxy <url>', 'Proxy url (http://some.sever:8080)')
  .option('--outputformat <format>', 'Valid formats: text, json')
  .option('--outputpath <path>', 'File to which output should be written')
  .option('--ignore <paths>', 'Comma delimited list of paths to ignore')
  .option('--ignorefile <path>', 'Custom .retireignore file, defaults to .retireignore')
  .option('--exitwith <code>', 'Custom exit code (default: 13) when vulnerabilities are found')
  .parse(process.argv);

var config = _.extend({ path: '.' }, _.pick(program, [
  'package', 'node', 'js', 'jspath', 'verbose', 'nodepath', 'path', 'jsrepo', 'noderepo',
  'dropexternal', 'nocache', 'proxy', 'ignore', 'ignorefile', 'outputformat', 'outputpath', 'exitwith'
]));

if (!config.nocache) {
  config.cachedir = path.resolve(os.tmpdir(), '.retire-cache/');
}
config.ignore = config.ignore ? _.map(config.ignore.split(','), function(e) { return path.resolve(e); }) : [];

if (!config.ignorefile && fs.existsSync(defaultIgnoreFile)) {
  config.ignorefile = defaultIgnoreFile;
}

if(config.ignorefile) {
  if (!fs.existsSync(config.ignorefile)) {
    console.warn('Error: Could not read ignore file: ' + config.ignorefile);
    process.exit(1);
Example #14
0
        
    },
    fun2: function(){
        
    }
};
console.log(_.functions(fun));//[ 'fun1', 'fun2' ]

// extend 复制对象的所有属性到目标对象上,覆盖已有属性
console.log(_.extend({name:'moe'}, {age:8})); //{ name: 'moe', age: 8 }

// default: 复制对象的所有属性到目标对象上,跳过已有属性
console.log(_.defaults({a:'a', b:'b'}, {a:'aa', c:'c'}));//{ a: 'a', b: 'b', c: 'c' }

// pick, omit返回一个对象的副本, 保留指定的属性或去掉指定的属性
console.log(_.pick({name:'tom', age:4}, 'name'));//{ name: 'tom' }
console.log(_.omit({name:'tom', age:4}, 'name'));//{ age: 4 }
// has 判断对象是否包含指定的属性名
console.log(_.has({a:1, b:2, c:3}, 'b')); //true
// isEqual: 判断两个对象是值相等
var moe = {name:'moe', b:[1,2,3]};
var clone = {name:'moe', b:[1,2,3]};
console.log(moe==clone);//false
console.log(_.isEqual(moe, clone));//true
//判断对象类型以下都为空
console.log(_.isEmpty({})); //如果object里没包含任何东西,将返回true
console.log(_.isArray([1,2,3]));
console.log(_.isObject({}));
console.log((function(){ return _.isArguments(arguments); })(1, 2, 3));
console.log(_.isFunction(console.log));
console.log(_.isString("moe"));
Example #15
0
let singleRequest = function(){
    log.info("making new request");
    let request;
    
    if(config.memoryUsage){
        request = http.request({
            'hostname': targetHost,
            'port': 8085,
            'method': 'POST',
            'path': '/?memoryUsage=1'
        });
        request.on('response', function (response) {
            log.info("STATUS: " + response.statusCode);
            response.setEncoding('utf8');
            response.on('data', function (chunk) {
                log.info(chunk);
            });
        });
        request.write(reqBody, 'utf8');
        request.end();
        return;
    }
//    log.info(config);
    let useStyleString = config.style;
    if(config.style == 'rand'){
        useStyleString = randStyle();
    }
    
    //config.style = useStyleString;
    let qstringObject = _.extend({},
            defaultQueryObject,
            _.pick(config, 'responseformat', 'bibliography', 'citations', 'outputformat', 'linkwrap', 'locale'),
            {'style': useStyleString});
    let qstring = querystring.stringify(qstringObject);
    log.info(qstring);
    request = http.request({
        'hostname': targetHost,
        'port': 8085,
        'method': 'POST',
        'path': '/?' + qstring
    });
    request.startDate = Date.now();
    request.styleUsed = useStyleString;
    request.on('response', function (response) {
        log.info('STATUS: ' + response.statusCode);
        response.setEncoding('utf8');
        response.body = '';
        response.on('data', function (chunk) {
            this.body += chunk;
        });
        response.on('end', function(){
            let resp = this;
            curConnections--;
            resp.endDate = Date.now();
            let timeElapsed = resp.endDate - request.startDate;
            requestTimes.push(timeElapsed);
            let styleUsed = request.styleUsed;
            if(resp.statusCode != 200){
                errorStyles.push(styleUsed);
            }
            else{
                passedStyles.push(styleUsed);
            }
            log.info("timeElapsed: " + timeElapsed);
            connectionResults.push({
                'status':resp.statusCode,
                'body':resp.body,
                'requestTime': timeElapsed
            });
            if(config.showoutput){
                let obj = JSON.parse(resp.body);
                log.info("response body");
                console.log(obj);
            }
            log.info("curConnections: " + curConnections);
            log.info("continueRequests: " + continueRequests);
            if((!continueRequests) && (curConnections == 0)){
                outputStats();
            }
        });
    });
    request.write(reqBody, 'utf8');
    request.end();
};
Example #16
0
var pickDTree = function (dtree) {
    //node_array部分
    //node_array有单纯的key,也有object需区分
    //将node_array中的5个Array进行提取
    var node_path_array;
    var redefined_param_array;
    var tracker_array;
    var payoff_array;
    var markov_info;
    for(var i = 0; i < dtree.node_array.length; i++){
        //node_path_array目前无筛选,没有key进行定位
        node_path_array = dtree.node_array[i].node_path_array;

        //redefined_param_array筛选
        redefined_param_array = dtree.node_array[i].redefined_param_array;

        dtree.redefined_param_array = _.map(dtree.redefined_param_array, function(currentObj){
            return _.pick(currentObj,
                "param_id",
                "formula"
            );
        });

        //下列三个array目前无筛选,没有key进行定位
        tracker_array = dtree.node_array[i].tracker_array;
        payoff_array = dtree.node_array[i].payoff_array;
        markov_info = dtree.node_array[i].markov_info;

        dtree.node_array[i] = _.pick(dtree.node_array[i],
            "node_id",
            "parent_id",
            "name",
            "tip",
            "type",
            "show_child",
            "show_tip",
            "prob"
        );

        dtree.node_array[i].node_path_array = node_path_array;
        dtree.node_array[i].redefined_param_array = redefined_param_array;
        dtree.node_array[i].tracker_array = tracker_array;
        dtree.node_array[i].payoff_array = payoff_array;
        dtree.node_array[i].markov_info = markov_info;
    }

    //其他部分
    dtree.config = _.pick(dtree.config,
        "name",
        "description",
        "last_saved",
        "security_level",
        "layout_style",
        "layer_width",
        "show_title",
        "show_info",
        "show_param",
        "show_tracker",
        "show_payoff",
        "show_tips",
        "align_endArea"
    );

    dtree.param_array = _.map(dtree.param_array, function(currentObj){
        return _.pick(currentObj,
            "param_id",
            "name",
            "description",
            "formula",
            "category",
            "display",
            "comment"
        );
    });

    dtree.param_category_array = _.map(dtree.param_category_array, function(currentObj){
        return _.pick(currentObj,
        "category_id",
        "name",
        "description"
        );
    });

    dtree.table_array = _.map(dtree.table_array, function(currentObj){
        return _.pick(currentObj,
        "table_id",
        "name",
        "description",
        "value",
        "comment"
        );
    });

    dtree.distribution_array = _.map(dtree.distribution_array, function(currentObj){
        return _.pick(currentObj,
        "distr_id",
        "name",
        "description",
        "type",
        "value",
        "display",
        "comment"
        );
    });

    dtree.payoff_array = _.map(dtree.payoff_array, function(currentObj){
        return _.pick(currentObj,
            "payoff_id",
            "payoff_name",
            "payoff_weight"
        );
    });

    return dtree;
};
Example #17
0
 dtree.redefined_param_array = _.map(dtree.redefined_param_array, function(currentObj){
     return _.pick(currentObj,
         "param_id",
         "formula"
     );
 });