Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(async () => {
// reset the winston loggers
winston.loggers.loggers.clear();
await clean();
});
msg = 'Error from logger (winston) while trying to use a file to store logs. If the directory "' + dir + '" does not exist, please create it:'
}
// make the error intentionally more visible to get the attention of the user
console.error('------------------------')
console.error(msg, err)
console.error('------------------------')
}
})
} else {
if (!winston.loggers.get('jsreport').transports.debug) {
winston.loggers.get('jsreport').add(DebugTransport)
}
}
this.logger = winston.loggers.get('jsreport')
this.logger.rewriters.push(function (level, msg, meta) {
// detecting if meta is jsreport request object
if (meta != null && meta.context) {
meta.context.logs = meta.context.logs || []
meta.context.logs.push({
level: level,
message: msg,
timestamp: meta.timestamp || new Date().getTime()
})
// excluding non relevant properties for the log
return Object.assign({}, omit(meta, ['template', 'options', 'data', 'context', 'timestamp']))
}
return meta
/*
* Uses workflow map retrieved from redis:
* - ins[i][j] = data id mapped to j-th output port of i-th task
* - outs[i][j] = data id mapped to j-th input port of i-th task
* - sources[i][1] = task id which produces data element with id=i (if none, sources[i]=[])
* - sources[i][2] = port id in this task the data element is mapped to
* - sinks[i][j] = task id which consumes data element with id=i (if none, sinks[i]=[])
* - sinks[i][j+1] = port id in this task the data element is mapped to
*/
var fs = require('fs'),
xml2js = require('xml2js'),
fsm = require('./automata.js'),
async = require('async'),
eventServerFactory = require('../eventlog'),
logger = require('winston').loggers.get('hyperflow');
var ProcDataflowFSM = require('./ProcDataflowFSM.js');
var ProcChoiceFSM = require('./ProcChoiceFSM.js');
var ProcForeachFSM = require('./ProcForeachFSM.js');
var ProcJoinFSM = require('./ProcJoinFSM.js');
var ProcSplitterFSM = require('./ProcSplitterFSM.js');
// TODO: automatically import and register all task FSMs in the current directory
fsm.registerFSM(ProcDataflowFSM);
fsm.registerFSM(ProcChoiceFSM);
fsm.registerFSM(ProcForeachFSM);
fsm.registerFSM(ProcJoinFSM);
fsm.registerFSM(ProcSplitterFSM);
/* Logging functionality for daemon. Exports a logger. */
import * as Winston from "winston";
import * as Path from "path";
import * as Fs from "fs";
Winston.loggers.add("daemon", Winston.createLogger());
Winston.loggers.add("client", Winston.createLogger());
export function addConsoleLog(name, level) {
let logger = Winston.loggers.get(name);
let trans = new Winston.transports.Console({
name: "console",
json: false,
colorize: true,
format: Winston.format.simple(),
level: level || "info"
});
logger.add(trans);
}
fineTuneUrls: function(okUrls, errorUrls, maxPagesToTest, absResultDir, callback) {
var log = winston.loggers.get('sitespeed.io');
var downloadErrors = {};
Object.keys(errorUrls).forEach(function(errorUrl) {
log.log('error', 'Failed to download ' + errorUrl);
downloadErrors[errorUrl] = inspect(errorUrls[errorUrl]);
});
// limit
if (maxPagesToTest) {
if (okUrls.length > maxPagesToTest) {
okUrls.length = maxPagesToTest;
}
}
if (okUrls.length === 0) {
log.log('info', 'Didn\'t get any URLs');
callback(new Error('No URLs to analyze'), okUrls, downloadErrors);
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
'use strict';
const VehicleLifecycle = require('./../vehicle-lifecycle.js');
const winston = require('winston');
const LOG = winston.loggers.get('application');
exports.command = 'deployRuleapp';
exports.desc = 'Deploy ruleapp';
exports.builder = {};
exports.handler = function (argv) {
return VehicleLifecycle.deployRuleappCmd(argv)
.then(() => {
LOG.info('Command completed successfully.');
process.exit(0);
})
.catch((error) => {
LOG.error(error+ '\nCommand failed.');
process.exit(1);
});
'use strict';
const conf = require('simple-configure');
const logger = require('winston').loggers.get('authorization');
const securedBySoCraTesAdminURLRegex = new RegExp(conf.get('securedBySoCraTesAdminURLPattern'));
module.exports = function redirectIfNotSoCraTesAdmin(req, res, next) {
const originalUrl = req.originalUrl;
const user = req.user;
if (securedBySoCraTesAdminURLRegex && securedBySoCraTesAdminURLRegex.test(originalUrl)) {
if (!res.locals.accessrights.isSoCraTesAdmin()) {
logger.info('Someone tried to access SoCraTes-Admin protected page ' + originalUrl + ' ' + (user ? ' - User was: ' + user.authenticationId : ''));
return res.redirect('/mustBeSoCraTesAdmin?page=' + encodeURIComponent(conf.get('publicUrlPrefix') + originalUrl));
}
}
next();
};
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const LandRegistry = require('./../../landRegistry.js');
const winston = require('winston');
const LOG = winston.loggers.get('application');
exports.command = 'list';
exports.desc = 'Lists all the land titles held in the Land Regsitry';
exports.builder = {};
exports.handler = async function (argv) {
try {
await LandRegistry.listCmd(argv);
LOG.info('Command completed successfully.');
process.exit(0);
} catch(error) {
LOG.error(error+ '\nCommand failed.');
process.exit(1);
}
};