Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/node
var _ = require('underscore'),
config = require('./config'),
fs = require('fs'),
async = require('async'),
db = require('./lib/db'),
github = require('./lib/github'),
apn = require('apn'),
StatsD = require('node-statsd'),
raven = require('raven');
// Configure Raven for error reporting
var ravenClient;
if (config.raven) {
ravenClient = new raven.Client(config.raven);
ravenClient.patchGlobal();
}
// A method to report errors
function reportError(err) {
if (ravenClient)
ravenClient.captureError(err);
console.error(err);
}
// The statsD client for reporting statistics
var stats = new StatsD({
host: 'graphite.dillonbuchanan',
prefix: 'codehub_push.',
cacheDns: true,
});
module.exports = () => {
if (process.type === 'browser') {
// eslint-disable-next-line no-console
console.log('Setup Browser/Main Process Error Tracking')
// main process
// eslint-disable-next-line global-require
const raven = require('raven')
const client = new raven.Client('https://2961feaae16a4ae18e4a63a5fa54b67a:71e01192e348489f912684133bdc86d2@sentry.io/111960')
client.patchGlobal()
process.on('uncaughtException', (err) => {
// eslint-disable-next-line global-require
const dialog = require('electron').dialog
dialog.showMessageBox({
type: 'error',
message: 'An error occurred our side. Please reach out to the Serverless team to resolve the issue.',
detail: err.stack,
buttons: ['OK'],
})
})
} else if (process.type === 'renderer') {
// eslint-disable-next-line no-console
console.log('Setup Renderer Process Error Tracking')
var express = require('express')
, config = require('./config')
, http = require('http')
, db = require('./lib/db')
, github = require('./lib/github')
, raven = require('raven')
, apn = require('apn')
, spawn = require('child_process').spawn
, StatsD = require('node-statsd')
, async = require('async');
// Configure Raven for error reporting
var ravenClient;
if (config.raven) {
ravenClient = new raven.Client(config.raven);
ravenClient.patchGlobal();
}
// A method to report errors
function reportError(err) {
if (ravenClient)
ravenClient.captureError(err);
stats.increment('500_error');
console.error(err);
}
// The statsD client for reporting statistics
var stats = new StatsD({
host: 'graphite.dillonbuchanan',
prefix: 'codehub_push.',
cacheDns: true,
const express = require('express');
const compression = require('compression');
const path = require('path');
const logger = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const routes = require('./routes/index');
const data = require('./routes/data');
const update = require('./routes/update');
const partners = require('./routes/partners');
const timeStampMiddleware = require('./middleware/timestamp');
const app = express();
const ftwebservice = require('express-ftwebservice');
const hbs = require('express-hbs');
const raven = require('raven');
const client = new raven.Client(SENTRY_DSN);
client.patchGlobal();
ftwebservice(app, {
manifestPath: path.join(__dirname, '../package.json'),
about: require('./runbook.json'),
healthCheck: require('./healthcheck'),
goodToGoTest: () => Promise.resolve(true) // TODO
});
// view engine setup
app.engine('hbs', hbs.express4({
partialsDir: path.join(__dirname, '/views/partials')
}));
app.set('views', path.join(__dirname, 'views')); //TODO: remove this
app.set('view engine', 'hbs');
git.branch((branch) => {
let ravenConfig = {
release: commit + "-" + branch,
transport: new Raven.transports.HTTPSTransport({rejectUnauthorized: false}),
tags: {
shardId: process.env.id,
},
autoBreadcrumbs: true,
};
if (sentryEnv) {
ravenConfig.environment = sentryEnv
}
this.raven = new Raven.Client(this.fileAuth.data.sentryURL, ravenConfig);
this.raven.install(() => {
console.log("This is thy sheath; there rust, and let me die.");
process.exit(1);
});
this.raven.on("logged", (e) => {
console.log("Error reported to sentry!: ".green + e);
});
this.raven.on("error", (e) => {
console.error("Could not report event to sentry:", e.reason);
});
resolve(true);
})
});
git.branch((branch) => {
this.git = {commit, branch};
let ravenConfig = {
release: commit + "-" + branch,
transport: new ravenClient.transports.HTTPSTransport({rejectUnauthorized: false}),
tags: {
shardId: process.env.id,
},
autoBreadcrumbs: false,
};
if (sentryEnv) {
ravenConfig.environment = sentryEnv
}
this.raven = new ravenClient.Client(this.fileAuth.data.sentryURL, ravenConfig);
this.raven.install(function (err, sendErr, eventId) {
if (!sendErr) {
console.log('Successfully sent fatal error with eventId ' + eventId + ' to Sentry:');
console.error(err.stack);
} else {
console.error("Error sending fatal error to sentry: ", sendErr);
console.error("fatal error was ", err.stack);
}
console.log("This is thy sheath; there rust, and let me die.");
setTimeout(() => {
process.exit(1)
}, 250);
});
this.raven.on("logged", function (e) {
var express = require('express');
var router = express.Router();
var exec = require('child_process').exec;
var config = require('../confighandler');
var raven = require('raven');
var sentry = new raven.Client(config.dsn);
router.post('/', function(req, res, next) {
exec('git pull', function(err, stdout, stderr) {
if(err) {
console.log(err.stack || err);
sentry.captureError(err);
next(err);
}
res.json({
stdout: stdout,
stderr: stderr
});
});
});
module.exports = router;
const raven = require('raven');
const request = require('request');
const https = require('https');
const { parseError } = require('raven/lib/parsers');
const { getModules, getCulprit } = require('raven/lib/utils');
const { https: ravenHTTPSTransport } = require('raven/lib/transports');
const config = require('../support/config');
const log = require('../support/log');
raven.config();
raven.disableConsoleAlerts();
const globalSentryDSNClient = new raven.Client();
const cache = {};
ravenHTTPSTransport.agent = https.globalAgent;
function getRavenClient(DSN) {
if (!cache[DSN]) {
cache[DSN] = new raven.Client(DSN);
}
return cache[DSN];
}
function applyContext(frame, lines) {
const linesOfContext = 7;
const realLine = frame.lineno - 2;
frame.pre_context = lines.slice(Math.max(0, realLine - (linesOfContext + 1)), realLine);
protected setupServices (): void {
if (this.config.has('service.sentry') === true) {
let key = null
if (this.config.has('service.sentry.secret') === true) {
key = this.config.get('service.sentry.secret')
} else if (this.config.has('service.sentry.public') === true) {
key = this.config.get('service.sentry.public')
}
if (key != null) {
this.sentry = new Raven(key)
this.sentry.release = this.config.get('houston.version')
this.sentry.environment = this.config.get('environment')
} else {
this.error('No sentry service key configured')
}
}
}
constructor(sentryUrl) {
if (!sentryUrl) {
logger.error('No sentry url defined.');
return;
}
this.raven = new Raven.Client();
this.raven.config(sentryUrl);
}