prism-csp.js 777 B

12345678910111213141516171819202122232425
  1. /**
  2. * Original by Scott Helme.
  3. *
  4. * Reference: https://scotthelme.co.uk/csp-cheat-sheet/
  5. *
  6. * Supports the following:
  7. * - CSP Level 1
  8. * - CSP Level 2
  9. * - CSP Level 3
  10. */
  11. Prism.languages.csp = {
  12. 'directive': {
  13. pattern: /\b(?:base-uri|block-all-mixed-content|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src|disown-opener|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox|upgrade-insecure-requests)\b/i,
  14. alias: 'keyword'
  15. },
  16. 'safe': {
  17. pattern: /'(?:self|none|strict-dynamic|(?:nonce-|sha(?:256|384|512)-)[a-zA-Z\d+=/]+)'/,
  18. alias: 'selector'
  19. },
  20. 'unsafe': {
  21. pattern: /(?:'unsafe-inline'|'unsafe-eval'|'unsafe-hashed-attributes'|\*)/,
  22. alias: 'function'
  23. }
  24. };