<commit_before>var CONFIG                = require ('./config'),
    utils                 = require("./lib/utils.js"),
    fs                    = require('fs'),
    redis                 = require("redis"),
    client                = redis.createClient(),
    xml2js                = require('xml2js'),
    parser                = new xml2js.Parser(),
    child_process         = require('child_process'),
    nodemailer            = require('nodemailer'),
    Slack                 = require('node-slack');
    slack                 = new Slack('https://hooks.slack.com/services/' + CONFIG.SLACK_TOKEN);
    verbose               = true,
    alertLog              = "",
    callBackCounterToExit = 0,
    transporter           = nodemailer.createTransport({
    	service: CONFIG.EMAIL_PROVIDER,
    	auth: {
    		user: CONFIG.EMAIL_USER,
    		pass: CONFIG.EMAIL_PASSWORD
    	}
    });

client.on("error", function (err) {
	console.log("Error " + err);
});

function sendSlack (message, channel, index, array) {
	slack.send({
		text: message,
		channel: channel,
		username: 'CVE Watch'
	}, function (error) {
		if (error != null && error.message != null) {
			console.log ("Slack: " + error.message);
		}

		// if last item in list
		if (index == array.length - 1) {
			// terminate the program
			console.log ("Done");
			process.exit(1);
		}
	});
}

function sendAlerts (alertLog) {
	if (alertLog != "") {
		emaillist.forEach (function (emailAddress, index, array) {
			var slackMessage = utils.replaceAll ("<br />", String.fromCharCode(13) + String.fromCharCode(10), alertLog),
			    mailOptions = { 							// setup e-mail data with unicode symbols
				from: 'CVE Watch ✔ <<EMAIL>>',	// sender address
				to: emailAddress,							// list of receivers
				subject: 'New vulnerabilities found',		// Subject line
				text: alertLog, 							// plaintext body
				html: alertLog 								// html body
			};

			// send mail with defined transport object
			transporter.sendMail(mailOptions, function(error, info){
				if (error){
					console.log(error);
				} else {
					if (verbose) console.log('Message sent: ' + info.response);
				}
			});<commit_msg>fix some broken stuff and clean up<commit_after>var CONFIG                = require ('./config'),
    utils                 = require("./lib/utils.js"),
    fs                    = require('fs'),
    redis                 = require("redis"),
    client                = redis.createClient(),
    xml2js                = require('xml2js'),
    parser                = new xml2js.Parser(),
    child_process         = require('child_process'),
    nodemailer            = require('nodemailer'),
    Slack                 = require('node-slack');
    slack                 = new Slack('https://hooks.slack.com/services/' + CONFIG.SLACK_TOKEN);
    verbose               = true,
    alertLog              = "",
    callBackCounterToExit = 0;

client.on("error", function (err) {
	console.log("Error " + err);
});

function sendSlack (message, channel, index, array) {
	slack.send({
		text: message,
		channel: channel,
		username: 'CVE Watch'
	}, function (error) {
		if (error != null && error.message != null) {
			console.log ("Slack: " + error.message);
		}

		// if last item in list
		if (index == array.length - 1) {
			// terminate the program
			console.log ("Done");
			process.exit(1);
		}
	});
}

function sendAlerts (alertLog) {
	if (alertLog != "") {
		var slackMessage = utils.replaceAll ("<br />", String.fromCharCode(13) + String.fromCharCode(10), alertLog),
		    transporter  = nodemailer.createTransport({
		    	service: CONFIG.EMAIL_PROVIDER,
		    	auth: {
		    		user: CONFIG.EMAIL_USER,
		    		pass: CONFIG.EMAIL_PASSWORD
		    	}
		    });

		emaillist.forEach (function (emailAddress, index, array) {
			var mailOptions = { 							// setup e-mail data with unicode symbols
				from: 'CVE Watch ✔ <<EMAIL>>',	// sender address
				to: emailAddress,							// list of receivers
				subject: 'New vulnerabilities found',		// Subject line
				text: alertLog, 							// plaintext body
				html: alertLog 								// html body
			};

			// send mail with defined transport object
			transporter.sendMail(mailOptions, function(error, info){
				if (error){
					console.log(error);
				} else {
					if (verbose) console.log('Message sent: ' + info.response);
				}
			});
{'fraction_non_alphanumeric': 0.13701149425287357, 'fraction_numerical': 0.004597701149425287, 'mean_word_length': 2.1100786275911365, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '3891938', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1305, 'n_words': 313}