From 98a9f3d621ab44ba2f51d941ace69a6d7bfad248 Mon Sep 17 00:00:00 2001 From: dhurley Date: Wed, 15 Mar 2023 15:57:04 +0000 Subject: [PATCH] Add check if there are any warrnings in the NGINX config validation --- sdk/proto/events/event.proto | 2 +- src/core/nginx.go | 4 ++++ .../github.com/nginx/agent/sdk/v2/proto/events/event.proto | 2 +- .../github.com/nginx/agent/sdk/v2/proto/events/event.proto | 2 +- .../vendor/github.com/nginx/agent/v2/src/core/nginx.go | 4 ++++ vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sdk/proto/events/event.proto b/sdk/proto/events/event.proto index ba925506e8..61324fc700 100644 --- a/sdk/proto/events/event.proto +++ b/sdk/proto/events/event.proto @@ -69,7 +69,7 @@ message SecurityViolationEvent { // DEPRECATED reserved 39; reserved "NginxID"; - + string PolicyName = 1 [(gogoproto.jsontag) = "policy_name"]; string SupportID = 2 [(gogoproto.jsontag) = "support_id"]; diff --git a/src/core/nginx.go b/src/core/nginx.go index ffc6ee23d0..d27322b39f 100644 --- a/src/core/nginx.go +++ b/src/core/nginx.go @@ -269,6 +269,10 @@ func (n *NginxBinaryType) ValidateConfig(processId, bin, configLocation string, return fmt.Errorf("error running nginx -t -c %v:\n%s", configLocation, response) } + if strings.Contains(response.String(), "nginx: [warn]") { + return fmt.Errorf("error running nginx -t -c %v:\n%s", configLocation, response) + } + log.Infof("Config validated:\n%s", response) return nil diff --git a/test/integration/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto b/test/integration/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto index ba925506e8..61324fc700 100644 --- a/test/integration/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto +++ b/test/integration/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto @@ -69,7 +69,7 @@ message SecurityViolationEvent { // DEPRECATED reserved 39; reserved "NginxID"; - + string PolicyName = 1 [(gogoproto.jsontag) = "policy_name"]; string SupportID = 2 [(gogoproto.jsontag) = "support_id"]; diff --git a/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto b/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto index ba925506e8..61324fc700 100644 --- a/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto +++ b/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto @@ -69,7 +69,7 @@ message SecurityViolationEvent { // DEPRECATED reserved 39; reserved "NginxID"; - + string PolicyName = 1 [(gogoproto.jsontag) = "policy_name"]; string SupportID = 2 [(gogoproto.jsontag) = "support_id"]; diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go index ffc6ee23d0..d27322b39f 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go @@ -269,6 +269,10 @@ func (n *NginxBinaryType) ValidateConfig(processId, bin, configLocation string, return fmt.Errorf("error running nginx -t -c %v:\n%s", configLocation, response) } + if strings.Contains(response.String(), "nginx: [warn]") { + return fmt.Errorf("error running nginx -t -c %v:\n%s", configLocation, response) + } + log.Infof("Config validated:\n%s", response) return nil diff --git a/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto b/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto index ba925506e8..61324fc700 100644 --- a/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto +++ b/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.proto @@ -69,7 +69,7 @@ message SecurityViolationEvent { // DEPRECATED reserved 39; reserved "NginxID"; - + string PolicyName = 1 [(gogoproto.jsontag) = "policy_name"]; string SupportID = 2 [(gogoproto.jsontag) = "support_id"];