<commit_before>const {random, randomItem, pad, range, uppercaseify, include,} = require('../../api');

module.exports = (inc, contents) => {
    const pic = contents.picture;
    delete contents.picture;

    include(inc, contents, 'phone', '(' + random(4, 1) + random(3, 2) + ') ' + random(4, 1) + random(3, 2) + '-' + random(3, 4));
    include(inc, contents, 'cell', '(' + random(4, 1) + random(3, 2) + ') ' + random(4, 1) + random(3, 2) + '-' + random(3, 4));
    include(inc, contents, 'id', {
        name: 'SSN',
        value: random(3, 3) + '-' + random(3, 2) + '-' + random(3, 4)
    });
    include(inc, contents, 'picture', pic);
};<commit_msg>fix(us-ssn-generation): enforced checks for valid SSNs during random generation<commit_after>const {random, randomItem, pad, range, uppercaseify, include,} = require('../../api');

module.exports = (inc, contents) => {
    const pic = contents.picture;
    delete contents.picture;

    include(inc, contents, 'phone', '(' + random(4, 1) + random(3, 2) + ') ' + random(4, 1) + random(3, 2) + '-' + random(3, 4));
    include(inc, contents, 'cell', '(' + random(4, 1) + random(3, 2) + ') ' + random(4, 1) + random(3, 2) + '-' + random(3, 4));
    include(inc, contents, 'id', () => {
        const checkSSN = (ssn) => {
            const regex = new RegExp("^(?!219-09-9999|078-05-1120)(?!666|000|9\\d{2})\\d{3}-(?!00)\\d{2}-(?!0{4})\\d{4}$");
            return regex.test(ssn);
        };
        const genSSN = () => {
            let ssn = random(3, 3) + '-' + random(3, 2) + '-' + random(3, 4);
            while(!checkSSN(ssn)){
                ssn = random(3, 3) + '-' + random(3, 2) + '-' + random(3, 4);
            }
            return ssn;
        };
        contents.id = {
            name: 'SSN',
            value: genSSN()
        }
    });
    include(inc, contents, 'picture', pic);
};
{'fraction_non_alphanumeric': 0.23304628632938643, 'fraction_numerical': 0.04897739504843918, 'mean_word_length': 2.5342205323193916, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '4918700', 'n_tokens_mistral': 715, 'n_tokens_neox': 661, 'n_words': 149}