diff --git a/sdk/proto/events/event.pb.go b/sdk/proto/events/event.pb.go index 903408281..0d8ac2fec 100644 --- a/sdk/proto/events/event.pb.go +++ b/sdk/proto/events/event.pb.go @@ -123,7 +123,6 @@ func (m *Metadata) GetCategory() string { type Event struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=Metadata,proto3" json:"metadata"` // Types that are valid to be assigned to Data: - // // *Event_ActivityEvent // *Event_SecurityViolationEvent Data isEvent_Data `protobuf_oneof:"data"` diff --git a/src/core/topics.go b/src/core/topics.go index 9c251993c..41dc95b57 100644 --- a/src/core/topics.go +++ b/src/core/topics.go @@ -43,6 +43,6 @@ const ( Events = "events" FileWatcherEnabled = "file.watcher.enabled" ConfigRollbackResponse = "config.rollback.response" - NginxAppProtectDetailsGenerated = "nap.details.generated" + DataplaneSoftwareDetailsUpdated = "dataplane.software.details.updated" EnableExtension = "enable.extension" ) diff --git a/src/plugins/dataplane_status.go b/src/plugins/dataplane_status.go index 92a5f4b41..577408dbb 100644 --- a/src/plugins/dataplane_status.go +++ b/src/plugins/dataplane_status.go @@ -85,12 +85,19 @@ func (dps *DataPlaneStatus) Info() *core.Info { func (dps *DataPlaneStatus) Process(msg *core.Message) { switch { case msg.Exact(core.AgentConfigChanged): + log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) // If the agent config on disk changed update DataPlaneStatus with relevant config info dps.syncAgentConfigChange() - case msg.Exact(core.NginxAppProtectDetailsGenerated): - // If a NAP report was generated sync it - dps.syncNAPDetails(msg) + case msg.Exact(core.DataplaneSoftwareDetailsUpdated): + log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) + switch data := msg.Data().(type) { + case *proto.DataplaneSoftwareDetails_AppProtectWafDetails: + log.Debugf("DataplaneStatus is syncing with NAP details - %+v", data.AppProtectWafDetails) + dps.napDetailsMutex.Lock() + dps.napDetails = data + dps.napDetailsMutex.Unlock() + } case msg.Exact(core.NginxConfigValidationPending): log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) @@ -100,6 +107,7 @@ func (dps *DataPlaneStatus) Process(msg *core.Message) { default: log.Errorf("Expected the type %T but got %T", &proto.AgentActivityStatus{}, data) } + case msg.Exact(core.NginxConfigApplyFailed) || msg.Exact(core.NginxConfigApplySucceeded): log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) switch data := msg.Data().(type) { @@ -116,7 +124,7 @@ func (dps *DataPlaneStatus) Process(msg *core.Message) { func (dps *DataPlaneStatus) Subscriptions() []string { return []string{ core.AgentConfigChanged, - core.NginxAppProtectDetailsGenerated, + core.DataplaneSoftwareDetailsUpdated, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -330,15 +338,3 @@ func (dps *DataPlaneStatus) syncAgentConfigChange() { dps.tags = &conf.Tags dps.configDirs = conf.ConfigDirs } - -func (dps *DataPlaneStatus) syncNAPDetails(msg *core.Message) { - switch commandData := msg.Data().(type) { - case *proto.DataplaneSoftwareDetails_AppProtectWafDetails: - log.Debugf("DataPlaneStatus is syncing with NAP details - %+v", commandData.AppProtectWafDetails) - dps.napDetailsMutex.Lock() - dps.napDetails = commandData - dps.napDetailsMutex.Unlock() - default: - log.Errorf("Expected the type %T but got %T", &proto.DataplaneSoftwareDetails_AppProtectWafDetails{}, commandData) - } -} diff --git a/src/plugins/dataplane_status_test.go b/src/plugins/dataplane_status_test.go index b5377ff10..898c4d19e 100644 --- a/src/plugins/dataplane_status_test.go +++ b/src/plugins/dataplane_status_test.go @@ -315,7 +315,7 @@ func TestDPSSyncNAPDetails(t *testing.T) { assert.Equal(t, tc.initialNAPDetails, dataPlaneStatus.napDetails) // Send updated NAP details message - dataPlaneStatus.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, tc.updatedNAPDetails)) + dataPlaneStatus.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, tc.updatedNAPDetails)) // Check if NAP details were updated assert.Equal(t, tc.updatedNAPDetails, dataPlaneStatus.napDetails) @@ -326,7 +326,7 @@ func TestDPSSyncNAPDetails(t *testing.T) { func TestDataPlaneSubscriptions(t *testing.T) { expectedSubscriptions := []string{ core.AgentConfigChanged, - core.NginxAppProtectDetailsGenerated, + core.DataplaneSoftwareDetailsUpdated, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, diff --git a/src/plugins/nginx_app_protect.go b/src/plugins/nginx_app_protect.go index dd078a49c..83b455f1b 100644 --- a/src/plugins/nginx_app_protect.go +++ b/src/plugins/nginx_app_protect.go @@ -108,7 +108,7 @@ func (n *NginxAppProtect) addSoftwareDetailsToRegistration(msg *core.Message) { func (n *NginxAppProtect) monitor() { initialDetails := n.generateNAPDetailsProtoCommand() log.Infof("Initial Nginx App Protect details: %+v", initialDetails) - n.messagePipeline.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, initialDetails)) + n.messagePipeline.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, initialDetails)) napUpdateChannel := n.nap.Monitor(n.reportInterval) @@ -119,7 +119,7 @@ func (n *NginxAppProtect) monitor() { // Communicate the update in NAP status via message pipeline log.Infof("Change in NAP detected... Previous: %+v... Updated: %+v", updateMsg.PreviousReport, updateMsg.UpdatedReport) napReportMsg := n.generateNAPDetailsProtoCommand() - n.messagePipeline.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, napReportMsg)) + n.messagePipeline.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, napReportMsg)) case <-time.After(n.reportInterval): log.Infof("No NAP changes detected after %v seconds... NAP Values: %+v", n.reportInterval.Seconds(), n.nap.GenerateNAPReport()) diff --git a/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go b/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go index 903408281..0d8ac2fec 100644 --- a/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go +++ b/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go @@ -123,7 +123,6 @@ func (m *Metadata) GetCategory() string { type Event struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=Metadata,proto3" json:"metadata"` // Types that are valid to be assigned to Data: - // // *Event_ActivityEvent // *Event_SecurityViolationEvent Data isEvent_Data `protobuf_oneof:"data"` diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/topics.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/topics.go index 9c251993c..41dc95b57 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/topics.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/topics.go @@ -43,6 +43,6 @@ const ( Events = "events" FileWatcherEnabled = "file.watcher.enabled" ConfigRollbackResponse = "config.rollback.response" - NginxAppProtectDetailsGenerated = "nap.details.generated" + DataplaneSoftwareDetailsUpdated = "dataplane.software.details.updated" EnableExtension = "enable.extension" ) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/dataplane_status.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/dataplane_status.go index 92a5f4b41..577408dbb 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/dataplane_status.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/dataplane_status.go @@ -85,12 +85,19 @@ func (dps *DataPlaneStatus) Info() *core.Info { func (dps *DataPlaneStatus) Process(msg *core.Message) { switch { case msg.Exact(core.AgentConfigChanged): + log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) // If the agent config on disk changed update DataPlaneStatus with relevant config info dps.syncAgentConfigChange() - case msg.Exact(core.NginxAppProtectDetailsGenerated): - // If a NAP report was generated sync it - dps.syncNAPDetails(msg) + case msg.Exact(core.DataplaneSoftwareDetailsUpdated): + log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) + switch data := msg.Data().(type) { + case *proto.DataplaneSoftwareDetails_AppProtectWafDetails: + log.Debugf("DataplaneStatus is syncing with NAP details - %+v", data.AppProtectWafDetails) + dps.napDetailsMutex.Lock() + dps.napDetails = data + dps.napDetailsMutex.Unlock() + } case msg.Exact(core.NginxConfigValidationPending): log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) @@ -100,6 +107,7 @@ func (dps *DataPlaneStatus) Process(msg *core.Message) { default: log.Errorf("Expected the type %T but got %T", &proto.AgentActivityStatus{}, data) } + case msg.Exact(core.NginxConfigApplyFailed) || msg.Exact(core.NginxConfigApplySucceeded): log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic()) switch data := msg.Data().(type) { @@ -116,7 +124,7 @@ func (dps *DataPlaneStatus) Process(msg *core.Message) { func (dps *DataPlaneStatus) Subscriptions() []string { return []string{ core.AgentConfigChanged, - core.NginxAppProtectDetailsGenerated, + core.DataplaneSoftwareDetailsUpdated, core.NginxConfigValidationPending, core.NginxConfigApplyFailed, core.NginxConfigApplySucceeded, @@ -330,15 +338,3 @@ func (dps *DataPlaneStatus) syncAgentConfigChange() { dps.tags = &conf.Tags dps.configDirs = conf.ConfigDirs } - -func (dps *DataPlaneStatus) syncNAPDetails(msg *core.Message) { - switch commandData := msg.Data().(type) { - case *proto.DataplaneSoftwareDetails_AppProtectWafDetails: - log.Debugf("DataPlaneStatus is syncing with NAP details - %+v", commandData.AppProtectWafDetails) - dps.napDetailsMutex.Lock() - dps.napDetails = commandData - dps.napDetailsMutex.Unlock() - default: - log.Errorf("Expected the type %T but got %T", &proto.DataplaneSoftwareDetails_AppProtectWafDetails{}, commandData) - } -} diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_app_protect.go b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_app_protect.go index dd078a49c..83b455f1b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_app_protect.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/plugins/nginx_app_protect.go @@ -108,7 +108,7 @@ func (n *NginxAppProtect) addSoftwareDetailsToRegistration(msg *core.Message) { func (n *NginxAppProtect) monitor() { initialDetails := n.generateNAPDetailsProtoCommand() log.Infof("Initial Nginx App Protect details: %+v", initialDetails) - n.messagePipeline.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, initialDetails)) + n.messagePipeline.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, initialDetails)) napUpdateChannel := n.nap.Monitor(n.reportInterval) @@ -119,7 +119,7 @@ func (n *NginxAppProtect) monitor() { // Communicate the update in NAP status via message pipeline log.Infof("Change in NAP detected... Previous: %+v... Updated: %+v", updateMsg.PreviousReport, updateMsg.UpdatedReport) napReportMsg := n.generateNAPDetailsProtoCommand() - n.messagePipeline.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, napReportMsg)) + n.messagePipeline.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, napReportMsg)) case <-time.After(n.reportInterval): log.Infof("No NAP changes detected after %v seconds... NAP Values: %+v", n.reportInterval.Seconds(), n.nap.GenerateNAPReport()) diff --git a/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go b/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go index 903408281..0d8ac2fec 100644 --- a/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go +++ b/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go @@ -123,7 +123,6 @@ func (m *Metadata) GetCategory() string { type Event struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=Metadata,proto3" json:"metadata"` // Types that are valid to be assigned to Data: - // // *Event_ActivityEvent // *Event_SecurityViolationEvent Data isEvent_Data `protobuf_oneof:"data"`