11package main
22
33import (
4- "bytes"
5- "io"
64 "net"
75 "net/http"
86
@@ -24,13 +22,6 @@ func startGRPCServer() error {
2422 if err != nil {
2523 return catcher .Error ("failed to listen on port 9003" , err , map [string ]any {"process" : "plugin_com.utmstack.modules-config" })
2624 }
27- // Remove after testing, before release to production
28- catcher .Info ("startGRPCServer: initializing decrypter" , map [string ]any {
29- "process" : "plugin_com.utmstack.modules-config" ,
30- "InternalKey" : InternalKey ,
31- "InternalKeyLen" : len (InternalKey ),
32- "BackendService" : BackendService ,
33- })
3425
3526 config .GetConfigServer ().SetDecrypter (func (section * config.ConfigurationSection ) error {
3627 return crypto .DecryptConfigurationSection (section , InternalKey )
@@ -78,62 +69,13 @@ func UpdateModuleConfig(c *gin.Context) {
7869 return
7970 }
8071
81- rawBody , readErr := io .ReadAll (c .Request .Body )
82- if readErr != nil {
83- _ = catcher .Error ("failed to read request body" , readErr , map [string ]any {
84- "process" : "plugin_com.utmstack.modules-config" ,
85- "module" : moduleName ,
86- })
87- c .JSON (http .StatusInternalServerError , gin.H {"error" : "failed to read body" })
88- return
89- }
90- c .Request .Body = io .NopCloser (bytes .NewBuffer (rawBody ))
91- // Remove after testing, before release to production
92- catcher .Info ("UpdateModuleConfig: raw request body" , map [string ]any {
93- "process" : "plugin_com.utmstack.modules-config" ,
94- "module" : moduleName ,
95- "bodyLen" : len (rawBody ),
96- "rawBody" : string (rawBody ),
97- })
98-
9972 body := []config.ConfigurationSection {}
10073 if err := c .ShouldBindJSON (& body ); err != nil {
101- _ = catcher .Error ("failed to bind JSON in UpdateModuleConfig" , err , map [string ]any {
102- "process" : "plugin_com.utmstack.modules-config" ,
103- "module" : moduleName ,
104- })
10574 c .JSON (http .StatusBadRequest , gin.H {"error" : "Invalid request body" })
10675 return
10776 }
10877
109- catcher .Info ("UpdateModuleConfig: parsed body" , map [string ]any {
110- "process" : "plugin_com.utmstack.modules-config" ,
111- "module" : moduleName ,
112- "sectionCount" : len (body ),
113- })
114- // Remove after testing, before release to production
11578 if len (body ) != 0 {
116- for _ , g := range body [0 ].ModuleGroups {
117- for _ , cnf := range g .ModuleGroupConfigurations {
118- catcher .Info ("incoming Update field (pre-decrypt)" , map [string ]any {
119- "process" : "plugin_com.utmstack.modules-config" ,
120- "module" : moduleName ,
121- "groupId" : g .Id ,
122- "confKey" : cnf .ConfKey ,
123- "confDataType" : cnf .ConfDataType ,
124- "valueLen" : len (cnf .ConfValue ),
125- "confValue" : cnf .ConfValue ,
126- })
127- }
128- }
129- // Remove after testing, before release to production
130- catcher .Info ("UpdateModuleConfig: calling decrypter" , map [string ]any {
131- "process" : "plugin_com.utmstack.modules-config" ,
132- "module" : moduleName ,
133- "InternalKey" : InternalKey ,
134- "InternalKeyLen" : len (InternalKey ),
135- })
136-
13779 if err := crypto .DecryptConfigurationSection (& body [0 ], InternalKey ); err != nil {
13880 _ = catcher .Error ("failed to decrypt module config on update" , err , map [string ]any {
13981 "process" : "plugin_com.utmstack.modules-config" ,
@@ -142,21 +84,6 @@ func UpdateModuleConfig(c *gin.Context) {
14284 c .JSON (http .StatusInternalServerError , gin.H {"error" : "failed to decrypt configuration" })
14385 return
14486 }
145- // Remove after testing, before release to production
146- for _ , g := range body [0 ].ModuleGroups {
147- for _ , cnf := range g .ModuleGroupConfigurations {
148- catcher .Info ("Update field (post-decrypt)" , map [string ]any {
149- "process" : "plugin_com.utmstack.modules-config" ,
150- "module" : moduleName ,
151- "groupId" : g .Id ,
152- "confKey" : cnf .ConfKey ,
153- "confDataType" : cnf .ConfDataType ,
154- "valueLen" : len (cnf .ConfValue ),
155- "confValue" : cnf .ConfValue ,
156- })
157- }
158- }
159-
16087 config .GetConfigServer ().NotifyUpdate (moduleName , & body [0 ])
16188 } else {
16289 catcher .Info ("Received empty configuration body, no updates made" , map [string ]any {"process" : "plugin_com.utmstack.modules-config" })
@@ -177,7 +104,7 @@ func ValidateModuleConfig(c *gin.Context) {
177104 c .JSON (http .StatusBadRequest , gin.H {"error" : "Invalid request body" })
178105 return
179106 }
180- // Remove after testing, before release to production
107+
181108 if err := crypto .DecryptModuleGroup (moduleName , & body , InternalKey ); err != nil {
182109 _ = catcher .Error ("failed to decrypt module config on validate" , err , map [string ]any {
183110 "process" : "plugin_com.utmstack.modules-config" ,
0 commit comments