From b59a8f4769c20c1d076bf7ff8c9b9b175f0f5969 Mon Sep 17 00:00:00 2001 From: Anderson Queiroz Date: Wed, 20 Dec 2023 11:36:50 +0100 Subject: [PATCH] Replace EOL modules: github.com/golang/protobuf by google.golang.org/protobuf (#37212) --- NOTICE.txt | 76 +++++++++---------- go.mod | 2 +- .../provider/aws/aws/kinesis_test.go | 7 +- .../aws/aws/transformer/transformer_test.go | 7 +- .../gcp/metrics/cloudsql/metadata_test.go | 10 +-- .../gcp/metrics/compute/metadata_test.go | 10 +-- .../module/gcp/metrics/metrics_requester.go | 11 ++- .../gcp/metrics/metrics_requester_test.go | 12 +-- .../module/gcp/metrics/metricset.go | 6 +- .../module/gcp/metrics/redis/metadata_test.go | 10 +-- 10 files changed, 76 insertions(+), 75 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index cfc6e641dd8..cca066349fa 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -17323,44 +17323,6 @@ Contents of probable licence file $GOMODCACHE/github.com/golang/mock@v1.6.0/LICE limitations under the License. --------------------------------------------------------------------------------- -Dependency : github.com/golang/protobuf -Version: v1.5.3 -Licence type (autodetected): BSD-3-Clause --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/golang/protobuf@v1.5.3/LICENSE: - -Copyright 2010 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -------------------------------------------------------------------------------- Dependency : github.com/golang/snappy Version: v0.0.4 @@ -37758,6 +37720,44 @@ third-party archives. limitations under the License. +-------------------------------------------------------------------------------- +Dependency : github.com/golang/protobuf +Version: v1.5.3 +Licence type (autodetected): BSD-3-Clause +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/golang/protobuf@v1.5.3/LICENSE: + +Copyright 2010 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + -------------------------------------------------------------------------------- Dependency : github.com/google/gofuzz Version: v1.2.0 diff --git a/go.mod b/go.mod index bb0ec7a3548..6732fbc6006 100644 --- a/go.mod +++ b/go.mod @@ -95,7 +95,6 @@ require ( github.com/gofrs/uuid v4.4.0+incompatible github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 - github.com/golang/protobuf v1.5.3 github.com/golang/snappy v0.0.4 github.com/gomodule/redigo v1.8.3 github.com/google/flatbuffers v23.3.3+incompatible @@ -291,6 +290,7 @@ require ( github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect github.com/google/s2a-go v0.1.4 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect diff --git a/x-pack/functionbeat/provider/aws/aws/kinesis_test.go b/x-pack/functionbeat/provider/aws/aws/kinesis_test.go index 242ed63d4a8..20d92ce3606 100644 --- a/x-pack/functionbeat/provider/aws/aws/kinesis_test.go +++ b/x-pack/functionbeat/provider/aws/aws/kinesis_test.go @@ -14,8 +14,9 @@ import ( "github.com/aws/aws-lambda-go/events" "github.com/awslabs/kinesis-aggregation/go/v2/deaggregator" aggRecProto "github.com/awslabs/kinesis-aggregation/go/v2/records" - "github.com/golang/protobuf/proto" //nolint:staticcheck // SA1019 dependency uses deprecated package "github.com/stretchr/testify/assert" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/runtime/protoimpl" "github.com/elastic/beats/v7/x-pack/functionbeat/function/provider" conf "github.com/elastic/elastic-agent-libs/config" @@ -133,14 +134,14 @@ func generateAggregatedKinesisEvent(validRec bool) events.KinesisEvent { partKeyTable = append(partKeyTable, "0") aggRec.PartitionKeyTable = partKeyTable - data, _ := proto.Marshal(aggRec) + data, _ := proto.Marshal(protoimpl.X.ProtoMessageV2Of(aggRec)) md5Hash := md5.Sum(data) aggRecBytes = append(aggRecBytes, data...) aggRecBytes = append(aggRecBytes, md5Hash[:]...) return events.KinesisEvent{ Records: []events.KinesisEventRecord{ - events.KinesisEventRecord{ + { AwsRegion: "east-1", EventID: "1234", EventName: "connect", diff --git a/x-pack/functionbeat/provider/aws/aws/transformer/transformer_test.go b/x-pack/functionbeat/provider/aws/aws/transformer/transformer_test.go index e29bba6cde3..ae0dcb12eee 100644 --- a/x-pack/functionbeat/provider/aws/aws/transformer/transformer_test.go +++ b/x-pack/functionbeat/provider/aws/aws/transformer/transformer_test.go @@ -14,12 +14,13 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/service/kinesis/types" + "google.golang.org/protobuf/runtime/protoimpl" "github.com/aws/aws-lambda-go/events" "github.com/awslabs/kinesis-aggregation/go/v2/deaggregator" aggRecProto "github.com/awslabs/kinesis-aggregation/go/v2/records" - "github.com/golang/protobuf/proto" //nolint:staticcheck // SA1019 dependency uses deprecated package "github.com/stretchr/testify/assert" + "google.golang.org/protobuf/proto" "github.com/elastic/beats/v7/libbeat/beat" "github.com/elastic/elastic-agent-libs/mapstr" @@ -33,7 +34,7 @@ func TestCloudwatch(t *testing.T) { SubscriptionFilters: []string{"MyFilter"}, MessageType: "DATA_MESSAGE", LogEvents: []events.CloudwatchLogsLogEvent{ - events.CloudwatchLogsLogEvent{ + { ID: "1234567890123456789", Timestamp: 1566908691193, Message: "my interesting message", @@ -393,7 +394,7 @@ func generateKinesisAggregateRecord(numRecords int, valid bool) []byte { } aggRec.PartitionKeyTable = partKeyTable - data, _ := proto.Marshal(aggRec) + data, _ := proto.Marshal(protoimpl.X.ProtoMessageV2Of(aggRec)) md5Hash := md5.Sum(data) aggRecBytes = append(aggRecBytes, data...) aggRecBytes = append(aggRecBytes, md5Hash[:]...) diff --git a/x-pack/metricbeat/module/gcp/metrics/cloudsql/metadata_test.go b/x-pack/metricbeat/module/gcp/metrics/cloudsql/metadata_test.go index cb678607c24..b6cd6e228f8 100644 --- a/x-pack/metricbeat/module/gcp/metrics/cloudsql/metadata_test.go +++ b/x-pack/metricbeat/module/gcp/metrics/cloudsql/metadata_test.go @@ -8,9 +8,9 @@ import ( "testing" monitoring "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" - "github.com/golang/protobuf/ptypes/timestamp" "google.golang.org/genproto/googleapis/api/metric" "google.golang.org/genproto/googleapis/api/monitoredres" + "google.golang.org/protobuf/types/known/timestamppb" "gotest.tools/assert" "github.com/elastic/elastic-agent-libs/mapstr" @@ -43,10 +43,10 @@ var fake = &monitoring.TimeSeries{ Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.0041224284852319215}, }, Interval: &monitoring.TimeInterval{ - StartTime: ×tamp.Timestamp{ + StartTime: ×tamppb.Timestamp{ Seconds: 1569932700, }, - EndTime: ×tamp.Timestamp{ + EndTime: ×tamppb.Timestamp{ Seconds: 1569932700, }, }, @@ -55,10 +55,10 @@ var fake = &monitoring.TimeSeries{ Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.004205757571772513}, }, Interval: &monitoring.TimeInterval{ - StartTime: ×tamp.Timestamp{ + StartTime: ×tamppb.Timestamp{ Seconds: 1569932640, }, - EndTime: ×tamp.Timestamp{ + EndTime: ×tamppb.Timestamp{ Seconds: 1569932640, }, }, diff --git a/x-pack/metricbeat/module/gcp/metrics/compute/metadata_test.go b/x-pack/metricbeat/module/gcp/metrics/compute/metadata_test.go index 8cfae667592..17213b8e1b8 100644 --- a/x-pack/metricbeat/module/gcp/metrics/compute/metadata_test.go +++ b/x-pack/metricbeat/module/gcp/metrics/compute/metadata_test.go @@ -8,10 +8,10 @@ import ( "testing" monitoring "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" - "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/assert" "google.golang.org/genproto/googleapis/api/metric" "google.golang.org/genproto/googleapis/api/monitoredres" + "google.golang.org/protobuf/types/known/timestamppb" ) var fake = &monitoring.TimeSeries{ @@ -41,10 +41,10 @@ var fake = &monitoring.TimeSeries{ Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.0041224284852319215}, }, Interval: &monitoring.TimeInterval{ - StartTime: ×tamp.Timestamp{ + StartTime: ×tamppb.Timestamp{ Seconds: 1569932700, }, - EndTime: ×tamp.Timestamp{ + EndTime: ×tamppb.Timestamp{ Seconds: 1569932700, }, }, @@ -53,10 +53,10 @@ var fake = &monitoring.TimeSeries{ Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.004205757571772513}, }, Interval: &monitoring.TimeInterval{ - StartTime: ×tamp.Timestamp{ + StartTime: ×tamppb.Timestamp{ Seconds: 1569932640, }, - EndTime: ×tamp.Timestamp{ + EndTime: ×tamppb.Timestamp{ Seconds: 1569932640, }, }, diff --git a/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go b/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go index a39f320ef44..e7e7f081e52 100644 --- a/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go +++ b/x-pack/metricbeat/module/gcp/metrics/metrics_requester.go @@ -12,12 +12,11 @@ import ( "sync" "time" - "github.com/golang/protobuf/ptypes/duration" - monitoring "cloud.google.com/go/monitoring/apiv3/v2" "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" - "github.com/golang/protobuf/ptypes/timestamp" "google.golang.org/api/iterator" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp" "github.com/elastic/elastic-agent-libs/logp" @@ -256,7 +255,7 @@ func (r *metricsRequester) getFilterForMetric(serviceName, m string) string { } // Returns a GCP TimeInterval based on the ingestDelay and samplePeriod from ListMetricDescriptor -func getTimeIntervalAligner(ingestDelay time.Duration, samplePeriod time.Duration, collectionPeriod *duration.Duration, inputAligner string) (*monitoringpb.TimeInterval, string) { +func getTimeIntervalAligner(ingestDelay time.Duration, samplePeriod time.Duration, collectionPeriod *durationpb.Duration, inputAligner string) (*monitoringpb.TimeInterval, string) { var startTime, endTime, currentTime time.Time var needsAggregation bool currentTime = time.Now().UTC() @@ -280,10 +279,10 @@ func getTimeIntervalAligner(ingestDelay time.Duration, samplePeriod time.Duratio } interval := &monitoringpb.TimeInterval{ - StartTime: ×tamp.Timestamp{ + StartTime: ×tamppb.Timestamp{ Seconds: startTime.Unix(), }, - EndTime: ×tamp.Timestamp{ + EndTime: ×tamppb.Timestamp{ Seconds: endTime.Unix(), }, } diff --git a/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go b/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go index 2b058de2bee..658568b66ca 100644 --- a/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go +++ b/x-pack/metricbeat/module/gcp/metrics/metrics_requester_test.go @@ -8,9 +8,9 @@ import ( "testing" "time" - "github.com/golang/protobuf/ptypes/duration" "github.com/stretchr/testify/assert" "go.uber.org/zap/zapcore" + "google.golang.org/protobuf/types/known/durationpb" "github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp" "github.com/elastic/elastic-agent-libs/logp" @@ -21,7 +21,7 @@ func TestGetTimeIntervalAligner(t *testing.T) { title string ingestDelay time.Duration samplePeriod time.Duration - collectionPeriod *duration.Duration + collectionPeriod *durationpb.Duration inputAligner string expectedAligner string }{ @@ -29,7 +29,7 @@ func TestGetTimeIntervalAligner(t *testing.T) { "test collectionPeriod equals to samplePeriod", time.Duration(240) * time.Second, time.Duration(60) * time.Second, - &duration.Duration{ + &durationpb.Duration{ Seconds: int64(60), }, "", @@ -39,7 +39,7 @@ func TestGetTimeIntervalAligner(t *testing.T) { "test collectionPeriod larger than samplePeriod", time.Duration(240) * time.Second, time.Duration(60) * time.Second, - &duration.Duration{ + &durationpb.Duration{ Seconds: int64(300), }, "ALIGN_MEAN", @@ -49,7 +49,7 @@ func TestGetTimeIntervalAligner(t *testing.T) { "test collectionPeriod smaller than samplePeriod", time.Duration(240) * time.Second, time.Duration(60) * time.Second, - &duration.Duration{ + &durationpb.Duration{ Seconds: int64(30), }, "ALIGN_MAX", @@ -59,7 +59,7 @@ func TestGetTimeIntervalAligner(t *testing.T) { "test collectionPeriod equals to samplePeriod with given aligner", time.Duration(240) * time.Second, time.Duration(60) * time.Second, - &duration.Duration{ + &durationpb.Duration{ Seconds: int64(60), }, "ALIGN_MEAN", diff --git a/x-pack/metricbeat/module/gcp/metrics/metricset.go b/x-pack/metricbeat/module/gcp/metrics/metricset.go index ffe5cd788a1..49cdce5d73a 100644 --- a/x-pack/metricbeat/module/gcp/metrics/metricset.go +++ b/x-pack/metricbeat/module/gcp/metrics/metricset.go @@ -13,10 +13,10 @@ import ( monitoring "cloud.google.com/go/monitoring/apiv3/v2" "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" - "github.com/golang/protobuf/ptypes/duration" "google.golang.org/api/iterator" "google.golang.org/api/option" "google.golang.org/genproto/googleapis/api/metric" + "google.golang.org/protobuf/types/known/durationpb" "github.com/elastic/beats/v7/metricbeat/mb" "github.com/elastic/beats/v7/x-pack/metricbeat/module/gcp" @@ -107,7 +107,7 @@ type config struct { CredentialsJSON string `config:"credentials_json"` opt []option.ClientOption - period *duration.Duration + period *durationpb.Duration } // New creates a new instance of the MetricSet. New is responsible for unpacking @@ -139,7 +139,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { return m, fmt.Errorf("no credentials_file_path or credentials_json specified") } - m.config.period = &duration.Duration{ + m.config.period = &durationpb.Duration{ Seconds: int64(m.Module().Config().Period.Seconds()), } diff --git a/x-pack/metricbeat/module/gcp/metrics/redis/metadata_test.go b/x-pack/metricbeat/module/gcp/metrics/redis/metadata_test.go index 9fc790bf9e5..48ac45661ed 100644 --- a/x-pack/metricbeat/module/gcp/metrics/redis/metadata_test.go +++ b/x-pack/metricbeat/module/gcp/metrics/redis/metadata_test.go @@ -8,10 +8,10 @@ import ( "testing" monitoring "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" - "github.com/golang/protobuf/ptypes/timestamp" "github.com/stretchr/testify/assert" "google.golang.org/genproto/googleapis/api/metric" "google.golang.org/genproto/googleapis/api/monitoredres" + "google.golang.org/protobuf/types/known/timestamppb" ) var fake = &monitoring.TimeSeries{ @@ -41,10 +41,10 @@ var fake = &monitoring.TimeSeries{ Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.0041224284852319215}, }, Interval: &monitoring.TimeInterval{ - StartTime: ×tamp.Timestamp{ + StartTime: ×tamppb.Timestamp{ Seconds: 1569932700, }, - EndTime: ×tamp.Timestamp{ + EndTime: ×tamppb.Timestamp{ Seconds: 1569932700, }, }, @@ -53,10 +53,10 @@ var fake = &monitoring.TimeSeries{ Value: &monitoring.TypedValue_DoubleValue{DoubleValue: 0.004205757571772513}, }, Interval: &monitoring.TimeInterval{ - StartTime: ×tamp.Timestamp{ + StartTime: ×tamppb.Timestamp{ Seconds: 1569932640, }, - EndTime: ×tamp.Timestamp{ + EndTime: ×tamppb.Timestamp{ Seconds: 1569932640, }, },