<commit_before>/*
 * Copyright (c) 2015, Yahoo Inc. All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

'use strict';

module.exports = CSP;

var LRU     = require('lru-cache');
var crypto  = require('crypto');
var TOKEN_RE = /(self|unsafe-inline|unsafe-eval)(?!.)|(sha(256|384|512)-|nonce-)/;

if (!Object.assign) {
    Object.assign = require('object-assign');
}

var SUPPORTED_DIRECTIVES = [
    'base-uri',
    'child-src',
    'connect-src',
    'default-src',
    'font-src',
    'form-action',
    'frame-ancestors',
    'img-src',
    'media-src',
    'object-src',
    'plugin-types',
    'report-uri',
    'reflected-xss',
    'script-src',
    'style-src'
];

var freeze = Object.freeze;

function CSP (config) {
    config = Object.assign({}, config, {
        cacheSize: 50
    });

    this.scripts  = {};
    this.styles   = {};
    this.cache    = new LRU(config.cacheSize);<commit_msg>Update csp.js<commit_after>/*
 * Copyright (c) 2015, Yahoo Inc. All rights reserved.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

'use strict';

module.exports = CSP;

var LRU     = require('lru-cache');
var crypto  = require('crypto');
var TOKEN_RE = /(self|unsafe-inline|unsafe-eval)(?!.)|(sha(256|384|512)-|nonce-)/;

if (!Object.assign) {
    Object.assign = require('object-assign');
}

var SUPPORTED_DIRECTIVES = [
    'base-uri',
    'block-all-mixed-content',
    'child-src',
    'connect-src',
    'default-src',
    'font-src',
    'form-action',
    'frame-ancestors',
    'frame-src',
    'img-src',
    'media-src',
    'object-src',
    'plugin-types',
    'report-uri',
    'reflected-xss',
    'require-sri-for',
    'script-src',
    'style-src',
    'upgrade-insecure-requests',
    'worker-src'
];

var freeze = Object.freeze;

function CSP (config) {
    config = Object.assign({}, config, {
        cacheSize: 50
    });

    this.scripts  = {};
    this.styles   = {};
    this.cache    = new LRU(config.cacheSize);
{'fraction_non_alphanumeric': 0.1782608695652174, 'fraction_numerical': 0.014492753623188406, 'mean_word_length': 2.856610800744879, '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': '441597', 'n_tokens_mistral': 772, 'n_tokens_neox': 731, 'n_words': 151}