From d0c64514c7b4f5f83ecf637589f88fa5c5e5e646 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 19 Sep 2024 15:26:41 +0200 Subject: [PATCH 1/4] add headerValue to logs about bad header --- .../iot/cygnus/handlers/NGSIRestHandler.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java index fc88794d7..90b5de67e 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java @@ -213,11 +213,11 @@ public List getEvents(javax.servlet.http.HttpServletRequest request) thro LOGGER.warn("[NGSIRestHandler] Bad HTTP notification ('" + CommonConstants.HEADER_FIWARE_SERVICE + "' header length greater than " - + NGSIConstants.SERVICE_HEADER_MAX_LEN + ")"); + + NGSIConstants.SERVICE_HEADER_MAX_LEN + ") for " + headerValue); throw new HTTPBadRequestException( "'" + CommonConstants.HEADER_FIWARE_SERVICE + "' header length greater than " - + NGSIConstants.SERVICE_HEADER_MAX_LEN + ")"); + + NGSIConstants.SERVICE_HEADER_MAX_LEN + ") for " + headerValue); } else { service = headerValue; } // if else @@ -231,17 +231,17 @@ public List getEvents(javax.servlet.http.HttpServletRequest request) thro LOGGER.warn("[NGSIRestHandler] Bad HTTP notification ('" + CommonConstants.HEADER_FIWARE_SERVICE_PATH + "' header value length greater than " - + NGSIConstants.SERVICE_PATH_HEADER_MAX_LEN + ")"); + + NGSIConstants.SERVICE_PATH_HEADER_MAX_LEN + ") for " + headerValue); throw new HTTPBadRequestException( "'fiware-servicePath' header length greater than " - + NGSIConstants.SERVICE_PATH_HEADER_MAX_LEN + ")"); + + NGSIConstants.SERVICE_PATH_HEADER_MAX_LEN + ") for " + headerValue)); } else if (wrongServicePathHeaderInitialCharacter(splitValue)) { LOGGER.warn("[NGSIRestHandler] Bad HTTP notification ('" + CommonConstants.HEADER_FIWARE_SERVICE_PATH - + "' header value must start with '/'"); + + "' header value " + headerValue + " must start with '/'"); throw new HTTPBadRequestException( "'" + CommonConstants.HEADER_FIWARE_SERVICE_PATH - + "' header value must start with '/'"); + + "' header value " + headerValue + " must start with '/'"); } // if else } // for @@ -252,7 +252,7 @@ public List getEvents(javax.servlet.http.HttpServletRequest request) thro ngsiVersion = headerValue; break; default: - LOGGER.debug("[NGSIRestHandler] Unnecessary header"); + LOGGER.debug("[NGSIRestHandler] Unnecessary header: " + headerName + " value " + headerValue); } // switch } // while From 296babaa02ad08c80fb741bd3cbd759b399eb59f Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 19 Sep 2024 15:39:15 +0200 Subject: [PATCH 2/4] fix typo --- .../com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java index 90b5de67e..8a90e23a9 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java @@ -234,11 +234,11 @@ public List getEvents(javax.servlet.http.HttpServletRequest request) thro + NGSIConstants.SERVICE_PATH_HEADER_MAX_LEN + ") for " + headerValue); throw new HTTPBadRequestException( "'fiware-servicePath' header length greater than " - + NGSIConstants.SERVICE_PATH_HEADER_MAX_LEN + ") for " + headerValue)); + + NGSIConstants.SERVICE_PATH_HEADER_MAX_LEN + ") for " + headerValue); } else if (wrongServicePathHeaderInitialCharacter(splitValue)) { LOGGER.warn("[NGSIRestHandler] Bad HTTP notification ('" + CommonConstants.HEADER_FIWARE_SERVICE_PATH - + "' header value " + headerValue + " must start with '/'"); + + "' header value " + headerValue + " must start with '/'");task/add_header_value_logs_about_bad_header throw new HTTPBadRequestException( "'" + CommonConstants.HEADER_FIWARE_SERVICE_PATH + "' header value " + headerValue + " must start with '/'"); From 81b936bc143b0968508fecf6ab53a7c0dfbd58c9 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 19 Sep 2024 15:42:16 +0200 Subject: [PATCH 3/4] fix typo --- .../com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java index 8a90e23a9..48080f000 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/handlers/NGSIRestHandler.java @@ -238,7 +238,7 @@ public List getEvents(javax.servlet.http.HttpServletRequest request) thro } else if (wrongServicePathHeaderInitialCharacter(splitValue)) { LOGGER.warn("[NGSIRestHandler] Bad HTTP notification ('" + CommonConstants.HEADER_FIWARE_SERVICE_PATH - + "' header value " + headerValue + " must start with '/'");task/add_header_value_logs_about_bad_header + + "' header value " + headerValue + " must start with '/'"); throw new HTTPBadRequestException( "'" + CommonConstants.HEADER_FIWARE_SERVICE_PATH + "' header value " + headerValue + " must start with '/'"); From 9c549cb65449a4e6fa56c40bac796e448a0f5109 Mon Sep 17 00:00:00 2001 From: Alvaro Vega Date: Thu, 19 Sep 2024 15:51:59 +0200 Subject: [PATCH 4/4] update CNR --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 66f9cf6aa..3e1ea202a 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -1,3 +1,4 @@ +- [cygnus-ngsi][restHandler] Add header value to logs about bad header (#2410) - [cygnus-ngsi] Upgrade Debian version from 12.5 to 12.6 in Dockerfile - [cygnus-common][cygnus-ngsi] New setting mongo_uri (#2387) - [cygnus-common][cygnus-ngsi] Deprecate (mongo_hosts, mongo_username, mongo_password, mongo_auth_source, mongo_replica_set) (use mongo_uri instead)