<commit_before>var dir = require('node-dir');

dir.readFiles(__dirname, {
        exclude: ['LICENSE', '.gitignore', '.DS_Store'],
        excludeDir: ['node_modules', '.git']
    }, function(err, content, next) {
        if (err) throw err;
        console.log('content:', content);
        next();
    },
    function(err, files) {
        if (err) throw err;
        console.log('finished reading files:', files);
    });<commit_msg>Add functionality to check for keys in commmit<commit_after>var dir = require('node-dir');

dir.readFiles(__dirname, {
        exclude: ['LICENSE', '.gitignore', '.DS_Store'],
        excludeDir: ['node_modules', '.git']
    }, function(err, content, next) {
        if (err) throw err;
        var digitalOceanToken = findDigitalOceanToken(String(content));
        var awsToken = findAwsToken(String(content));
        if(awsToken != null || digitalOceanToken != null){
        	console.log("Key in commit. Remove and commit again");
        	process.exit(1);
        }
        next();
    },
    function(err, files) {
        if (err) throw err;
        //console.log('finished reading files:', files);
    });


function findDigitalOceanToken(content){
	return content.match(/\"[a-zA-Z0-9]{63,65}\"/);
}

function findAwsToken(content){
	return content.match(/\"AKIA[a-zA-Z0-9]{16,17}\"/);
}
{'fraction_non_alphanumeric': 0.1704204204204204, 'fraction_numerical': 0.00975975975975976, 'mean_word_length': 2.909090909090909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2169053', 'n_tokens_mistral': 420, 'n_tokens_neox': 410, 'n_words': 93}