Skip to content

Commit

Permalink
build(deps): bump go.einride.tech/sage from 0.275.0 to 0.305.0 in /.sage
Browse files Browse the repository at this point in the history
Bumps [go.einride.tech/sage](https://github.com/einride/sage) from 0.275.0 to 0.305.0.
- [Release notes](https://github.com/einride/sage/releases)
- [Commits](einride/sage@v0.275.0...v0.305.0)

---
updated-dependencies:
- dependency-name: go.einride.tech/sage
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
dependabot[bot] committed Aug 29, 2024
1 parent a9c700f commit 3927371
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .sage/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module sage

go 1.17

require go.einride.tech/sage v0.275.0
require go.einride.tech/sage v0.305.0
4 changes: 2 additions & 2 deletions .sage/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
go.einride.tech/sage v0.275.0 h1:t+4asK8qcNsy9/q6vuGrM3LU7KV+NCzrQFVugH0u1CM=
go.einride.tech/sage v0.275.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ=
go.einride.tech/sage v0.305.0 h1:TUJekrRnMlkxoyLSoz/aLkeIkQVDxY0nBVJ4OVn9N4U=
go.einride.tech/sage v0.305.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ=
8 changes: 1 addition & 7 deletions .sage/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"go.einride.tech/sage/tools/sggit"
"go.einride.tech/sage/tools/sggo"
"go.einride.tech/sage/tools/sggolangcilint"
"go.einride.tech/sage/tools/sggoreview"
"go.einride.tech/sage/tools/sgmdformat"
"go.einride.tech/sage/tools/sgyamlfmt"
)
Expand All @@ -23,7 +22,7 @@ func main() {
}

func All(ctx context.Context) error {
sg.Deps(ctx, ConvcoCheck, GolangciLint, GoReview, GoTest, FormatMarkdown, FormatYAML)
sg.Deps(ctx, ConvcoCheck, GolangciLint, GoTest, FormatMarkdown, FormatYAML)
sg.SerialDeps(ctx, GoModTidy, GitVerifyNoDiff)
return nil
}
Expand All @@ -43,11 +42,6 @@ func GoTest(ctx context.Context) error {
return sggo.TestCommand(ctx).Run()
}

func GoReview(ctx context.Context) error {
sg.Logger(ctx).Println("reviewing Go files...")
return sggoreview.Command(ctx, "-c", "1", "./...").Run()
}

func GolangciLint(ctx context.Context) error {
sg.Logger(ctx).Println("linting Go files...")
return sggolangcilint.Run(ctx)
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ git-verify-no-diff: $(sagefile)
go-mod-tidy: $(sagefile)
@$(sagefile) GoModTidy

.PHONY: go-review
go-review: $(sagefile)
@$(sagefile) GoReview

.PHONY: go-test
go-test: $(sagefile)
@$(sagefile) GoTest
Expand Down
20 changes: 11 additions & 9 deletions bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"google.golang.org/protobuf/proto"
)

// indexOfUDPPayload is the first byte index of the payload in a a UDP packet.
// indexOfUDPPayload is the first byte index of the payload in a UDP packet.
const (
indexOfUDPPayload = 8
offsetHeaderMagic = indexOfUDPPayload + indexOfHeaderMagic
Expand Down Expand Up @@ -42,11 +42,11 @@ func shortMessageChannelFilter(channels ...string) []bpf.Instruction {
// check for each channel, accept if any matches
for _, channel := range channels {
remaining := []byte(channel)
var i int
var i uint32
for ; len(remaining) >= 4; i += 4 {
program = append(
program,
bpf.LoadAbsolute{Off: offsetChannel + uint32(i), Size: 4},
bpf.LoadAbsolute{Off: offsetChannel + i, Size: 4},
bpf.JumpIf{Cond: bpf.JumpNotEqual, Val: binary.BigEndian.Uint32(remaining), SkipTrue: jumpNextChannelPlaceholder},
)
remaining = remaining[4:]
Expand All @@ -63,7 +63,7 @@ func shortMessageChannelFilter(channels ...string) []bpf.Instruction {
case 3:
val, size = uint32(remaining[2])<<8|uint32(remaining[1])<<16|uint32(remaining[0])<<24, 4
}
program = append(program, bpf.LoadAbsolute{Off: offsetChannel + uint32(i), Size: size})
program = append(program, bpf.LoadAbsolute{Off: offsetChannel + i, Size: size})
if len(remaining) == 2 {
// When this happens we actually read 1 byte into the payload. So a packet with no payload
// will be rejected too. But why would you do that?
Expand All @@ -83,14 +83,16 @@ func shortMessageChannelFilter(channels ...string) []bpf.Instruction {
bpf.RetConstant{Val: lengthOfLargestUDPMessage}, // Accept instruction
)
// Start with next channel pointing to the rejection we just added
//nolint:gosec // overflow shouldn't be an issue here.
progLen := uint8(len(program))
rewrite := map[uint8]uint8{
jumpNextChannelPlaceholder: uint8(len(program)) - 2,
jumpRejectPlaceholder: uint8(len(program)) - 2,
jumpAcceptPlaceholder: uint8(len(program)) - 1,
jumpNextChannelPlaceholder: progLen - 2,
jumpRejectPlaceholder: progLen - 2,
jumpAcceptPlaceholder: progLen - 1,
}
// Now we back-track through the program to find the placeholders and
// rewrite those to a real jump to the next channel (or the reject instruction).
for i := uint8(len(program)) - 1; i > 0; i-- {
for i := progLen - 1; i > 0; i-- {
switch instr := program[i].(type) {
case bpf.JumpIf:
if offset, ok := rewrite[instr.SkipTrue]; ok {
Expand All @@ -100,7 +102,7 @@ func shortMessageChannelFilter(channels ...string) []bpf.Instruction {
}
case bpf.LoadAbsolute:
// Each channel matching starts with a load of the first byte, uint16 or uint32 in channel.
// If it's not, it's not the start of a the channel name
// If it's not, it's not the start of the channel name
if instr.Off == offsetChannel {
rewrite[jumpNextChannelPlaceholder] = i
}
Expand Down
1 change: 1 addition & 0 deletions lcm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func TestLCM_OneTransmitter_OneReceiver_ManyCompressed(t *testing.T) {
assert.NilError(t, g.Wait())
assert.Equal(t, "first", rx.Message().Channel)
assert.DeepEqual(t, []byte(strings.Repeat("foo", i)), rx.Message().Data)
//nolint:gosec // i starts at 100 so no risk for underflow.
assert.Equal(t, uint32(i-100), rx.Message().SequenceNumber)
})
}
Expand Down
5 changes: 5 additions & 0 deletions lcmlog/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (m *Message) WriteTo(w io.Writer) (int64, error) {
func (m *Message) UnmarshalBinary(b []byte) {
m.EventNumber = binary.BigEndian.Uint64(b[indexOfEventNumber:endOfEventNumber])
timestampMicros := binary.BigEndian.Uint64(b[indexOfTimestamp:endOfTimestamp])
//nolint:gosec // false positive for the integer overflow.
m.Timestamp = time.Unix(0, (time.Duration(timestampMicros) * time.Microsecond).Nanoseconds())
channelLength := binary.BigEndian.Uint32(b[indexOfChannelLength:endOfChannelLength])
dataLength := binary.BigEndian.Uint32(b[indexOfDataLength:endOfDataLength])
Expand All @@ -121,14 +122,18 @@ func (m *Message) UnmarshalBinary(b []byte) {
// MarshalBinary will output the message this function is called on to a byte slice.
// The inverse of this function is UnmarshalBinary.
func (m *Message) MarshalBinary() []byte {
//nolint:gosec // false positive for integer overflow.
endofChannel := endOfDataLength + uint32(len(m.Channel))
//nolint:gosec // length won't be negative.
endOfData := endofChannel + uint32(len(m.Data))
b := make([]byte, endOfDataLength+len(m.Channel)+len(m.Data))
binary.BigEndian.PutUint32(b[indexOfSyncWord:endOfSyncWord], syncWord)
binary.BigEndian.PutUint64(b[indexOfEventNumber:endOfEventNumber], m.EventNumber)
timestampMicros := uint64(time.Duration(m.Timestamp.UnixNano()) / time.Microsecond)
binary.BigEndian.PutUint64(b[indexOfTimestamp:endOfTimestamp], timestampMicros)
//nolint:gosec // length won't be negative.
binary.BigEndian.PutUint32(b[indexOfChannelLength:endOfChannelLength], uint32(len(m.Channel)))
//nolint:gosec // length won't be negative.
binary.BigEndian.PutUint32(b[indexOfDataLength:endOfDataLength], uint32(len(m.Data)))
copy(b[endOfDataLength:endofChannel], m.Channel)
copy(b[endofChannel:endOfData], m.Data)
Expand Down

0 comments on commit 3927371

Please sign in to comment.