Fixing gosec failures

Change-Id: I925211cd62e4abab740154078917c64163d120b8
diff --git a/VERSION b/VERSION
index 73a1fbb..47b322c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.4.1-dev
+3.4.1
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index bc88adf..a08e73d 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -19,7 +19,6 @@
 
 import (
 	"flag"
-	"fmt"
 	"os"
 	"time"
 )
@@ -127,83 +126,57 @@
 // ParseCommandArguments parses the arguments when running read-write adaptercore service
 func (so *AdapterFlags) ParseCommandArguments() {
 
-	help := fmt.Sprintf("Kafka - Adapter messaging address")
-	flag.StringVar(&(so.KafkaAdapterAddress), "kafka_adapter_address", defaultKafkaadapteraddress, help)
+	flag.StringVar(&(so.KafkaAdapterAddress), "kafka_adapter_address", defaultKafkaadapteraddress, "Kafka - Adapter messaging address")
 
-	help = fmt.Sprintf("Kafka - Cluster messaging address")
-	flag.StringVar(&(so.KafkaClusterAddress), "kafka_cluster_address", defaultKafkaclusteraddress, help)
+	flag.StringVar(&(so.KafkaClusterAddress), "kafka_cluster_address", defaultKafkaclusteraddress, "Kafka - Cluster messaging address")
 
-	help = fmt.Sprintf("Open OLT topic")
-	flag.StringVar(&(so.Topic), "adapter_topic", defaultTopic, help)
+	flag.StringVar(&(so.Topic), "adapter_topic", defaultTopic, "Open OLT topic")
 
-	help = fmt.Sprintf("Core topic")
-	flag.StringVar(&(so.CoreTopic), "core_topic", defaultCoretopic, help)
+	flag.StringVar(&(so.CoreTopic), "core_topic", defaultCoretopic, "Core topic")
 
-	help = fmt.Sprintf("Event topic")
-	flag.StringVar(&(so.EventTopic), "event_topic", defaultEventtopic, help)
+	flag.StringVar(&(so.EventTopic), "event_topic", defaultEventtopic, "Event topic")
 
-	help = fmt.Sprintf("KV store type")
-	flag.StringVar(&(so.KVStoreType), "kv_store_type", defaultKvstoretype, help)
+	flag.StringVar(&(so.KVStoreType), "kv_store_type", defaultKvstoretype, "KV store type")
 
-	help = fmt.Sprintf("The default timeout when making a kv store request")
-	flag.DurationVar(&(so.KVStoreTimeout), "kv_store_request_timeout", defaultKvstoretimeout, help)
+	flag.DurationVar(&(so.KVStoreTimeout), "kv_store_request_timeout", defaultKvstoretimeout, "The default timeout when making a kv store request")
 
-	help = fmt.Sprintf("KV store address")
-	flag.StringVar(&(so.KVStoreAddress), "kv_store_address", defaultKvstoreaddress, help)
+	flag.StringVar(&(so.KVStoreAddress), "kv_store_address", defaultKvstoreaddress, "KV store address")
 
-	help = fmt.Sprintf("Log level")
-	flag.StringVar(&(so.LogLevel), "log_level", defaultLoglevel, help)
+	flag.StringVar(&(so.LogLevel), "log_level", defaultLoglevel, "Log level")
 
-	help = fmt.Sprintf("Number of ONUs")
-	flag.IntVar(&(so.OnuNumber), "onu_number", defaultOnunumber, help)
+	flag.IntVar(&(so.OnuNumber), "onu_number", defaultOnunumber, "Number of ONUs")
 
-	help = fmt.Sprintf("Show startup banner log lines")
-	flag.BoolVar(&(so.Banner), "banner", defaultBanner, help)
+	flag.BoolVar(&(so.Banner), "banner", defaultBanner, "Show startup banner log lines")
 
-	help = fmt.Sprintf("Show version information and exit")
-	flag.BoolVar(&(so.DisplayVersionOnly), "version", defaultDisplayVersionOnly, help)
+	flag.BoolVar(&(so.DisplayVersionOnly), "version", defaultDisplayVersionOnly, "Show version information and exit")
 
-	help = fmt.Sprintf("The address on which to listen to answer liveness and readiness probe queries over HTTP.")
-	flag.StringVar(&(so.ProbeAddress), "probe_address", defaultProbeAddress, help)
+	flag.StringVar(&(so.ProbeAddress), "probe_address", defaultProbeAddress, "The address on which to listen to answer liveness and readiness probe queries over HTTP.")
 
-	help = fmt.Sprintf("Number of seconds for the default liveliness check")
-	flag.DurationVar(&(so.LiveProbeInterval), "live_probe_interval", defaultLiveProbeInterval, help)
+	flag.DurationVar(&(so.LiveProbeInterval), "live_probe_interval", defaultLiveProbeInterval, "Number of seconds for the default liveliness check")
 
-	help = fmt.Sprintf("Number of seconds for liveliness check if probe is not running")
-	flag.DurationVar(&(so.NotLiveProbeInterval), "not_live_probe_interval", defaultNotLiveProbeInterval, help)
+	flag.DurationVar(&(so.NotLiveProbeInterval), "not_live_probe_interval", defaultNotLiveProbeInterval, "Number of seconds for liveliness check if probe is not running")
 
-	help = fmt.Sprintf("Number of seconds for heartbeat check interval.")
-	flag.DurationVar(&(so.HeartbeatCheckInterval), "heartbeat_check_interval", defaultHeartbeatCheckInterval, help)
+	flag.DurationVar(&(so.HeartbeatCheckInterval), "heartbeat_check_interval", defaultHeartbeatCheckInterval, "Number of seconds for heartbeat check interval")
 
-	help = fmt.Sprintf("Number of seconds adapter has to wait before reporting core on the hearbeat check failure.")
-	flag.DurationVar(&(so.HeartbeatFailReportInterval), "heartbeat_fail_interval", defaultHeartbeatFailReportInterval, help)
+	flag.DurationVar(&(so.HeartbeatFailReportInterval), "heartbeat_fail_interval", defaultHeartbeatFailReportInterval, "Number of seconds adapter has to wait before reporting core on the heartbeat check failure")
 
-	help = fmt.Sprintf("Number of seconds for GRPC timeout.")
-	flag.DurationVar(&(so.GrpcTimeoutInterval), "grpc_timeout_interval", defaultGrpcTimeoutInterval, help)
+	flag.DurationVar(&(so.GrpcTimeoutInterval), "grpc_timeout_interval", defaultGrpcTimeoutInterval, "Number of seconds for GRPC timeout")
 
-	help = "Replica number of this particular instance (default: %s)"
-	flag.IntVar(&(so.CurrentReplica), "current_replica", defaultCurrentReplica, help)
+	flag.IntVar(&(so.CurrentReplica), "current_replica", defaultCurrentReplica, "Replica number of this particular instance")
 
-	help = "Total number of instances for this adapter"
-	flag.IntVar(&(so.TotalReplicas), "total_replica", defaultTotalReplicas, help)
+	flag.IntVar(&(so.TotalReplicas), "total_replica", defaultTotalReplicas, "Total number of instances for this adapter")
 
-	help = fmt.Sprintf("Whether to send logs to tracing agent?")
-	flag.BoolVar(&(so.TraceEnabled), "trace_enabled", defaultTraceEnabled, help)
+	flag.BoolVar(&(so.TraceEnabled), "trace_enabled", defaultTraceEnabled, "Whether to send logs to tracing agent?")
 
-	help = fmt.Sprintf("The address of tracing agent to which span info should be sent.")
-	flag.StringVar(&(so.TraceAgentAddress), "trace_agent_address", defaultTraceAgentAddress, help)
+	flag.StringVar(&(so.TraceAgentAddress), "trace_agent_address", defaultTraceAgentAddress, "The address of tracing agent to which span info should be sent")
 
-	help = fmt.Sprintf("Whether to enrich log statements with fields denoting operation being executed for achieving correlation?")
-	flag.BoolVar(&(so.LogCorrelationEnabled), "log_correlation_enabled", defaultLogCorrelationEnabled, help)
+	flag.BoolVar(&(so.LogCorrelationEnabled), "log_correlation_enabled", defaultLogCorrelationEnabled, "Whether to enrich log statements with fields denoting operation being executed for achieving correlation?")
 
-	help = fmt.Sprintf("OMCI Channel encryption status")
-	flag.BoolVar(&(so.OmccEncryption), "omcc_encryption", defaultOmccEncryption, help)
+	flag.BoolVar(&(so.OmccEncryption), "omcc_encryption", defaultOmccEncryption, "OMCI Channel encryption status")
 
-	help = fmt.Sprintf("Enable ONU Statistics")
-	flag.BoolVar(&(so.EnableONUStats), "enable_onu_stats", defaultEnableONUStats, help)
+	flag.BoolVar(&(so.EnableONUStats), "enable_onu_stats", defaultEnableONUStats, "Enable ONU Statistics")
 
-	help = fmt.Sprintf("Enable GEM Statistics")
-	flag.BoolVar(&(so.EnableGEMStats), "enable_gem_stats", defaultEnableGEMStats, help)
+	flag.BoolVar(&(so.EnableGEMStats), "enable_gem_stats", defaultEnableGEMStats, "Enable GEM Statistics")
 
 	flag.Parse()
 	containerName := getContainerInfo()
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 43a588c..7f2b53e 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -1774,10 +1774,10 @@
 					"device-id": dh.device.Id,
 					"pon-port":  ponPort}, err).Log()
 			}
-			for _, onu := range onuGemData {
+			for i, onu := range onuGemData {
 				onuID := make([]uint32, 1)
 				logger.Debugw(ctx, "onu-data", log.Fields{"onu": onu})
-				if err = dh.clearUNIData(ctx, &onu); err != nil {
+				if err = dh.clearUNIData(ctx, &onuGemData[i]); err != nil {
 					logger.Errorw(ctx, "failed-to-clear-data-for-onu", log.Fields{"onu-device": onu})
 				}
 				// Clear flowids for gem cache.
@@ -2211,7 +2211,7 @@
 			for i, onu := range onuGemData {
 				if onu.OnuID == onuID && onu.SerialNumber == onuSn {
 					logger.Debugw(ctx, "onu-data", log.Fields{"onu": onu})
-					if err := dh.clearUNIData(ctx, &onu); err != nil {
+					if err := dh.clearUNIData(ctx, &onuGemData[i]); err != nil {
 						logger.Warnw(ctx, "failed-to-clear-uni-data-for-onu", log.Fields{
 							"device-id":  dh.device.Id,
 							"onu-device": onu,
diff --git a/internal/pkg/core/olt_platform_test.go b/internal/pkg/core/olt_platform_test.go
index d38b9fb..4c89eaa 100644
--- a/internal/pkg/core/olt_platform_test.go
+++ b/internal/pkg/core/olt_platform_test.go
@@ -313,7 +313,7 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(2),
 			fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2)),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.EthType(2048),
 		},
 
diff --git a/internal/pkg/core/openolt_flowmgr_test.go b/internal/pkg/core/openolt_flowmgr_test.go
index 3a561be..44a02fb 100644
--- a/internal/pkg/core/openolt_flowmgr_test.go
+++ b/internal/pkg/core/openolt_flowmgr_test.go
@@ -297,7 +297,7 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(2),
 			fu.Metadata_ofp(2),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
@@ -402,7 +402,7 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(536870912),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
@@ -433,7 +433,7 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1000),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
@@ -452,7 +452,7 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1000),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			fu.Experimenter(257, []byte{1, 2, 3, 4}),
@@ -465,7 +465,7 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1000),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			fu.Output(0),
@@ -483,7 +483,7 @@
 			fu.InPort(536870912),
 			fu.TunnelId(16),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
@@ -548,7 +548,7 @@
 			fu.InPort(536870912),
 			fu.TunnelId(16),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.VlanPcp(1000),
 			fu.UdpDst(1048576),
 			fu.UdpSrc(536870912),
@@ -568,7 +568,7 @@
 			fu.InPort(65533),
 			//	fu.TunnelId(16),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.VlanPcp(1000),
 			fu.UdpDst(65535),
 			fu.UdpSrc(536870912),
@@ -933,7 +933,7 @@
 			fu.Metadata_ofp(1),
 			fu.IpProto(17), // dhcp
 			fu.VlanPcp(0),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
@@ -968,11 +968,11 @@
 			fu.InPort(536870912),
 			fu.Metadata_ofp(1),
 			//fu.EthType(0x8100),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
-			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0)),
+			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
 			fu.Output(1048576),
 			fu.PushVlan(0x8100),
 		},
@@ -983,12 +983,12 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1048576),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.VlanPcp(1),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
-			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0)),
+			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
 			fu.Output(536870912),
 			fu.PopVlan(),
 		},
@@ -1351,7 +1351,7 @@
 			fu.Metadata_ofp(1),
 			fu.IpProto(17), // dhcp
 			fu.VlanPcp(0),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.TunnelId(16),
 		},
 		Actions: []*ofp.OfpAction{
@@ -1388,12 +1388,12 @@
 			fu.InPort(536870912),
 			fu.Metadata_ofp(1),
 			//fu.EthType(0x8100),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.TunnelId(16),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
-			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0)),
+			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
 			fu.Output(1048576),
 			fu.PushVlan(0x8100),
 		},
@@ -1405,13 +1405,13 @@
 		MatchFields: []*ofp.OfpOxmOfbField{
 			fu.InPort(1048576),
 			fu.Metadata_ofp(1),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.VlanPcp(1),
 			fu.TunnelId(16),
 		},
 		Actions: []*ofp.OfpAction{
 			//fu.SetField(fu.Metadata_ofp(uint64(ofp.OfpInstructionType_OFPIT_WRITE_METADATA | 2))),
-			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0)),
+			fu.SetField(fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT))),
 			fu.Output(536870912),
 			fu.PopVlan(),
 		},
@@ -1425,7 +1425,7 @@
 			fu.Metadata_ofp(1),
 			fu.IpProto(17), // dhcp
 			fu.VlanPcp(0),
-			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT) | 0),
+			fu.VlanVid(uint32(ofp.OfpVlanId_OFPVID_PRESENT)),
 			fu.TunnelId(16),
 		},
 		Actions: []*ofp.OfpAction{