]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/accesslog.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / accesslog.js
1 /*! `accesslog` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Apache Access Log
7 Author: Oleg Efimov <efimovov@gmail.com>
8 Description: Apache/Nginx Access Logs
9 Website: https://httpd.apache.org/docs/2.4/logs.html#accesslog
10 Category: web, logs
11 Audit: 2020
12 */
13
14 /** @type LanguageFn */
15 function accesslog(hljs) {
16 const regex = hljs.regex;
17 // https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
18 const HTTP_VERBS = [
19 "GET",
20 "POST",
21 "HEAD",
22 "PUT",
23 "DELETE",
24 "CONNECT",
25 "OPTIONS",
26 "PATCH",
27 "TRACE"
28 ];
29 return {
30 name: 'Apache Access Log',
31 contains: [
32 // IP
33 {
34 className: 'number',
35 begin: /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?\b/,
36 relevance: 5
37 },
38 // Other numbers
39 {
40 className: 'number',
41 begin: /\b\d+\b/,
42 relevance: 0
43 },
44 // Requests
45 {
46 className: 'string',
47 begin: regex.concat(/"/, regex.either(...HTTP_VERBS)),
48 end: /"/,
49 keywords: HTTP_VERBS,
50 illegal: /\n/,
51 relevance: 5,
52 contains: [
53 {
54 begin: /HTTP\/[12]\.\d'/,
55 relevance: 5
56 }
57 ]
58 },
59 // Dates
60 {
61 className: 'string',
62 // dates must have a certain length, this prevents matching
63 // simple array accesses a[123] and [] and other common patterns
64 // found in other languages
65 begin: /\[\d[^\]\n]{8,}\]/,
66 illegal: /\n/,
67 relevance: 1
68 },
69 {
70 className: 'string',
71 begin: /\[/,
72 end: /\]/,
73 illegal: /\n/,
74 relevance: 0
75 },
76 // User agent / relevance boost
77 {
78 className: 'string',
79 begin: /"Mozilla\/\d\.\d \(/,
80 end: /"/,
81 illegal: /\n/,
82 relevance: 3
83 },
84 // Strings
85 {
86 className: 'string',
87 begin: /"/,
88 end: /"/,
89 illegal: /\n/,
90 relevance: 0
91 }
92 ]
93 };
94 }
95
96 return accesslog;
97
98 })();
99 ;
100 export default hljsGrammar;