author lwe google license import { CheckerFunction } from './checks/checker' ; import * as parserChecks from './checks/parser_checks' ; import * as securityChecks from './checks/security_checks' ; import * as strictcspChecks from './checks/strictcsp_checks' ; import * as csp from './csp' ; import { Csp , Version } from './csp' ; import { Finding } from './finding' ; unrestricted export class CspEvaluator { version : Version ; csp : Csp ; /**
     * List of findings reported by checks.
     *
     */ findings : Finding [ ] = [ ] ; param parsedCsp param cspVersion constructor ( parsedCsp , cspVersion ? ) { /**
         * CSP version.
         */ this . version = cspVersion || csp . Version . CSP3 ; /**
         * Parsed CSP.
         */ this . csp = parsedCsp ; } param parsedCspChecks param effectiveCspChecks return export evaluate ( parsedCspChecks ? , effectiveCspChecks ? ) { this . findings = [ ] ; const checks = effectiveCspChecks || DEFAULT_CHECKS ; const effectiveCsp = this . csp . getEffectiveCsp ( this . version , this . findings ) ; if ( parsedCspChecks ) { for ( const check of parsedCspChecks ) { this . findings = this . findings . concat ( check ( this . csp ) ) ; } } for ( const check of checks ) { this . findings = this . findings . concat ( check ( effectiveCsp ) ) ; } return this . findings ; } } /**
 * Set of default checks to run.
 */ export const DEFAULT_CHECKS = [ securityChecks . checkScriptUnsafeInline , securityChecks . checkScriptUnsafeEval , securityChecks . checkPlainUrlSchemes , securityChecks . checkWildcards , securityChecks . checkMissingDirectives , securityChecks . checkScriptAllowlistBypass , securityChecks . checkFlashObjectAllowlistBypass , securityChecks . checkIpSource , securityChecks . checkNonceLength , securityChecks . checkSrcHttp , securityChecks . checkDeprecatedDirective , parserChecks . checkUnknownDirective , parserChecks . checkMissingSemicolon , parserChecks . checkInvalidKeyword ] ; /**
 * Strict CSP and backward compatibility checks.
 */ export const STRICTCSP_CHECKS = [ strictcspChecks . checkStrictDynamic , strictcspChecks . checkStrictDynamicNotStandalone , strictcspChecks . checkUnsafeInlineFallback , strictcspChecks . checkAllowlistFallback , strictcspChecks . checkRequiresTrustedTypesForScripts ] ;