basant307/AI_Governance_Project
048
1/*2Language: Apache config3Author: Ruslan Keba <rukeba@gmail.com>4Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>5Website: https://httpd.apache.org6Description: language definition for Apache configuration files (httpd.conf & .htaccess)7Category: config, web8Audit: 20209*/10 11/** @type LanguageFn */12function apache(hljs) {13 const NUMBER_REF = {14 className: 'number',15 begin: /[$%]\d+/16 };17 const NUMBER = {18 className: 'number',19 begin: /\b\d+/20 };21 const IP_ADDRESS = {22 className: "number",23 begin: /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?/24 };25 const PORT_NUMBER = {26 className: "number",27 begin: /:\d{1,5}/28 };29 return {30 name: 'Apache config',31 aliases: [ 'apacheconf' ],32 case_insensitive: true,33 contains: [34 hljs.HASH_COMMENT_MODE,35 {36 className: 'section',37 begin: /<\/?/,38 end: />/,39 contains: [40 IP_ADDRESS,41 PORT_NUMBER,42 // low relevance prevents us from claming XML/HTML where this rule would43 // match strings inside of XML tags44 hljs.inherit(hljs.QUOTE_STRING_MODE, { relevance: 0 })45 ]46 },47 {48 className: 'attribute',49 begin: /\w+/,50 relevance: 0,51 // keywords aren’t needed for highlighting per se, they only boost relevance52 // for a very generally defined mode (starts with a word, ends with line-end53 keywords: { _: [54 "order",55 "deny",56 "allow",57 "setenv",58 "rewriterule",59 "rewriteengine",60 "rewritecond",61 "documentroot",62 "sethandler",63 "errordocument",64 "loadmodule",65 "options",66 "header",67 "listen",68 "serverroot",69 "servername"70 ] },71 starts: {72 end: /$/,73 relevance: 0,74 keywords: { literal: 'on off all deny allow' },75 contains: [76 {77 scope: "punctuation",78 match: /\\\n/79 },80 {81 className: 'meta',82 begin: /\s\[/,83 end: /\]$/84 },85 {86 className: 'variable',87 begin: /[\$%]\{/,88 end: /\}/,89 contains: [90 'self',91 NUMBER_REF92 ]93 },94 IP_ADDRESS,95 NUMBER,96 hljs.QUOTE_STRING_MODE97 ]98 }99 }100 ],101 illegal: /\S/102 };103}104 105export { apache as default };106 