Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies #132

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
.env

# Dist
/dist
8 changes: 4 additions & 4 deletions decoders/netflow/netflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ func (ts *BasicTemplateSystem) GetTemplates() map[uint16]map[uint32]map[uint16]i
func (ts *BasicTemplateSystem) AddTemplate(version uint16, obsDomainId uint32, template interface{}) {
ts.templateslock.Lock()
_, exists := ts.templates[version]
if exists != true {
if !exists {
ts.templates[version] = make(map[uint32]map[uint16]interface{})
}
_, exists = ts.templates[version][obsDomainId]
if exists != true {
if !exists {
ts.templates[version][obsDomainId] = make(map[uint16]interface{})
}
var templateId uint16
Expand Down Expand Up @@ -322,13 +322,13 @@ func DecodeMessage(payload *bytes.Buffer, templates NetFlowTemplateSystem) (inte
utils.BinaryDecoder(payload, &packetNFv9.Count, &packetNFv9.SystemUptime, &packetNFv9.UnixSeconds, &packetNFv9.SequenceNumber, &packetNFv9.SourceId)
size = packetNFv9.Count
packetNFv9.Version = version
returnItem = *(&packetNFv9)
returnItem = packetNFv9
obsDomainId = packetNFv9.SourceId
} else if version == 10 {
utils.BinaryDecoder(payload, &packetIPFIX.Length, &packetIPFIX.ExportTime, &packetIPFIX.SequenceNumber, &packetIPFIX.ObservationDomainId)
size = packetIPFIX.Length
packetIPFIX.Version = version
returnItem = *(&packetIPFIX)
returnItem = packetIPFIX
obsDomainId = packetIPFIX.ObservationDomainId
} else {
return nil, NewErrorVersion(version)
Expand Down
2 changes: 1 addition & 1 deletion decoders/netflowlegacy/netflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func DecodeMessage(payload *bytes.Buffer) (interface{}, error) {
)

if packet.Count > MAX_FLOWS_PER_PACKET {
return nil, fmt.Errorf("Invalid amount of flows: %d", packet.Count)
return nil, fmt.Errorf("invalid amount of flows: %d", packet.Count)
}

packet.Records = make([]RecordsNetFlowV5, int(packet.Count))
Expand Down
15 changes: 7 additions & 8 deletions decoders/sflow/sflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sflow

import (
"bytes"
"errors"
"fmt"

"github.com/cloudflare/goflow/v3/decoders/utils"
Expand Down Expand Up @@ -214,10 +213,10 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
return flowRecord, err
}
if int(extendedGateway.ASPathLength) > payload.Len()-4 {
return flowRecord, errors.New(fmt.Sprintf("Invalid AS path length: %v.", extendedGateway.ASPathLength))
return flowRecord, fmt.Errorf("invalid AS path length: %v", extendedGateway.ASPathLength)
}
if extendedGateway.ASPathLength > MAX_AS_PATH_LENGTH {
return flowRecord, fmt.Errorf("Invalid AS path length: %d", extendedGateway.ASPathLength)
return flowRecord, fmt.Errorf("invalid AS path length: %d", extendedGateway.ASPathLength)
}
asPath = make([]uint32, extendedGateway.ASPathLength)
if len(asPath) > 0 {
Expand All @@ -234,11 +233,11 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,
return flowRecord, err
}
if int(extendedGateway.CommunitiesLength) > payload.Len()-4 {
return flowRecord, errors.New(fmt.Sprintf("Invalid Communities length: %v.", extendedGateway.CommunitiesLength))
return flowRecord, fmt.Errorf("invalid Communities length: %v", extendedGateway.CommunitiesLength)
}

if extendedGateway.CommunitiesLength > MAX_COMMUNITIES_LENGTH {
return flowRecord, fmt.Errorf("Invalid communities length: %d", extendedGateway.CommunitiesLength)
return flowRecord, fmt.Errorf("invalid communities length: %d", extendedGateway.CommunitiesLength)
}
communities := make([]uint32, extendedGateway.CommunitiesLength)
if len(communities) > 0 {
Expand All @@ -255,7 +254,7 @@ func DecodeFlowRecord(header *RecordHeader, payload *bytes.Buffer) (FlowRecord,

flowRecord.Data = extendedGateway
default:
return flowRecord, errors.New(fmt.Sprintf("Unknown data format %v.", (*header).DataFormat))
return flowRecord, fmt.Errorf("unknown data format %v", (*header).DataFormat)
}
return flowRecord, nil
}
Expand Down Expand Up @@ -301,7 +300,7 @@ func DecodeSample(header *SampleHeader, payload *bytes.Buffer) (interface{}, err
}
recordsCount = flowSample.FlowRecordsCount
if recordsCount > MAX_FLOW_RECORDS {
return flowSample, fmt.Errorf("Invalid number of flows records: %d", recordsCount)
return flowSample, fmt.Errorf("invalid number of flows records: %d", recordsCount)
}
flowSample.Records = make([]FlowRecord, recordsCount)
sample = flowSample
Expand All @@ -316,7 +315,7 @@ func DecodeSample(header *SampleHeader, payload *bytes.Buffer) (interface{}, err
}

if recordsCount > MAX_SAMPLES_PER_PACKET {
return flowSample, fmt.Errorf("Invalid number of samples: %d", recordsCount)
return flowSample, fmt.Errorf("invalid number of samples: %d", recordsCount)
}
counterSample.Records = make([]CounterRecord, recordsCount)
sample = counterSample
Expand Down
49 changes: 42 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
module github.com/cloudflare/goflow/v3

go 1.12
go 1.21

toolchain go1.23.4

require (
github.com/Shopify/sarama v1.38.1
github.com/golang/protobuf v1.5.4
github.com/libp2p/go-reuseport v0.4.0
github.com/prometheus/client_golang v1.20.5
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.10.0
)

require (
github.com/Shopify/sarama v1.22.0
github.com/golang/protobuf v1.4.3
github.com/libp2p/go-reuseport v0.0.1
github.com/prometheus/client_golang v1.11.1
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.4.0
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eapache/go-resiliency v1.7.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect
google.golang.org/protobuf v1.36.3 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading