csp.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Language: CSP
  3. Description: Content Security Policy definition highlighting
  4. Author: Taras <oxdef@oxdef.info>
  5. Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
  6. Category: web
  7. vim: ts=2 sw=2 st=2
  8. */
  9. /** @type LanguageFn */
  10. function csp(hljs) {
  11. const KEYWORDS = [
  12. "base-uri",
  13. "child-src",
  14. "connect-src",
  15. "default-src",
  16. "font-src",
  17. "form-action",
  18. "frame-ancestors",
  19. "frame-src",
  20. "img-src",
  21. "manifest-src",
  22. "media-src",
  23. "object-src",
  24. "plugin-types",
  25. "report-uri",
  26. "sandbox",
  27. "script-src",
  28. "style-src",
  29. "trusted-types",
  30. "unsafe-hashes",
  31. "worker-src"
  32. ];
  33. return {
  34. name: 'CSP',
  35. case_insensitive: false,
  36. keywords: {
  37. $pattern: '[a-zA-Z][a-zA-Z0-9_-]*',
  38. keyword: KEYWORDS
  39. },
  40. contains: [
  41. {
  42. className: 'string',
  43. begin: "'",
  44. end: "'"
  45. },
  46. {
  47. className: 'attribute',
  48. begin: '^Content',
  49. end: ':',
  50. excludeEnd: true
  51. }
  52. ]
  53. };
  54. }
  55. export { csp as default };