From 36ef12843e2ea2863cfea87a29b0c2a8f3f10e05 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Fri, 6 Feb 2026 15:22:12 +0000 Subject: [PATCH] fix: add WebDAV methods (PROPFIND, PROPPATCH, MKCOL, etc.) to ValidHTTPMethods The structured access logs were showing an empty method field for PROPFIND requests because the parser only recognized standard HTTP methods. Changes: - Add WebDAV methods (RFC 4918) to ValidHTTPMethods in parser/types.go: PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK - Update the validMethods check in indexer/parallel_indexer_optimized.go - Add test cases for WebDAV methods in parser_test.go Fixes: PROPFIND method not showing in structured access logs Co-authored-by: Jacky --- .../indexer/parallel_indexer_optimized.go | 4 +++ internal/nginx_log/parser/parser_test.go | 31 +++++++++++++++++++ internal/nginx_log/parser/types.go | 11 ++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/internal/nginx_log/indexer/parallel_indexer_optimized.go b/internal/nginx_log/indexer/parallel_indexer_optimized.go index 0cb96057..e994e80d 100644 --- a/internal/nginx_log/indexer/parallel_indexer_optimized.go +++ b/internal/nginx_log/indexer/parallel_indexer_optimized.go @@ -289,8 +289,12 @@ func isValidLogEntry(doc *LogDocument) bool { // Check HTTP method if present if doc.Method != "" { validMethods := map[string]bool{ + // Standard HTTP methods "GET": true, "POST": true, "PUT": true, "DELETE": true, "HEAD": true, "OPTIONS": true, "PATCH": true, "CONNECT": true, "TRACE": true, + // WebDAV methods (RFC 4918) + "PROPFIND": true, "PROPPATCH": true, "MKCOL": true, + "COPY": true, "MOVE": true, "LOCK": true, "UNLOCK": true, } if !validMethods[doc.Method] { return false diff --git a/internal/nginx_log/parser/parser_test.go b/internal/nginx_log/parser/parser_test.go index 4d6a99b8..82cac0af 100644 --- a/internal/nginx_log/parser/parser_test.go +++ b/internal/nginx_log/parser/parser_test.go @@ -80,6 +80,37 @@ func TestParser_ParseLine(t *testing.T) { entry.BytesSent == 0 }, }, + { + name: "WebDAV PROPFIND method", + line: `192.168.1.100 - - [25/Dec/2023:10:00:00 +0000] "PROPFIND /webdav/ HTTP/1.1" 207 1234 "-" "davfs2/1.5.4"`, + validate: func(entry *AccessLogEntry) bool { + return entry.IP == "192.168.1.100" && + entry.Method == "PROPFIND" && + entry.Path == "/webdav/" && + entry.Status == 207 && + entry.BytesSent == 1234 + }, + }, + { + name: "WebDAV MKCOL method", + line: `10.0.0.5 - - [25/Dec/2023:10:00:00 +0000] "MKCOL /webdav/newdir/ HTTP/1.1" 201 0 "-" "WebDAVClient/1.0"`, + validate: func(entry *AccessLogEntry) bool { + return entry.IP == "10.0.0.5" && + entry.Method == "MKCOL" && + entry.Path == "/webdav/newdir/" && + entry.Status == 201 + }, + }, + { + name: "WebDAV LOCK method", + line: `172.16.0.1 - - [25/Dec/2023:10:00:00 +0000] "LOCK /webdav/file.txt HTTP/1.1" 200 512 "-" "Microsoft-WebDAV"`, + validate: func(entry *AccessLogEntry) bool { + return entry.IP == "172.16.0.1" && + entry.Method == "LOCK" && + entry.Path == "/webdav/file.txt" && + entry.Status == 200 + }, + }, } config := DefaultParserConfig() diff --git a/internal/nginx_log/parser/types.go b/internal/nginx_log/parser/types.go index c92e0a4e..dada71e7 100644 --- a/internal/nginx_log/parser/types.go +++ b/internal/nginx_log/parser/types.go @@ -100,8 +100,9 @@ func DefaultParserConfig() *Config { } } -// ValidHTTPMethods Valid HTTP methods +// ValidHTTPMethods Valid HTTP methods including WebDAV methods var ValidHTTPMethods = map[string]bool{ + // Standard HTTP methods "GET": true, "POST": true, "PUT": true, @@ -111,6 +112,14 @@ var ValidHTTPMethods = map[string]bool{ "PATCH": true, "TRACE": true, "CONNECT": true, + // WebDAV methods (RFC 4918) + "PROPFIND": true, + "PROPPATCH": true, + "MKCOL": true, + "COPY": true, + "MOVE": true, + "LOCK": true, + "UNLOCK": true, } // Parser errors (moved to errors.go as Cosy Errors)