Skip to content

Commit 4961b27

Browse files
authored
Merge branch 'main' into rule-deletion
2 parents b0c2227 + f626137 commit 4961b27

32 files changed

+291
-78
lines changed

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,32 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Changed
1111

12+
- Fix panic in `parseSockaddr` for malformed socket address. [#152](https://github.com/elastic/go-libaudit/pull/152)
13+
1214
### Removed
1315

1416
### Deprecated
1517

18+
## [2.5.0]
19+
20+
### Added
21+
22+
- Add ECS normalization for `exit_group` syscall. [#149](https://github.com/elastic/go-libaudit/pull/149)
23+
24+
### Changed
25+
26+
- Update syscall and architecture tables. [#147](https://github.com/elastic/go-libaudit/pull/147)
27+
28+
## [2.4.0]
29+
30+
### Added
31+
32+
- Support `saddr_fam` filters. [#145](https://github.com/elastic/go-libaudit/pull/145)
33+
34+
### Changed
35+
36+
- Update Vagrant file gvm and ubuntu versions. [#145](https://github.com/elastic/go-libaudit/pull/145)
37+
1638
## [2.3.3]
1739

1840
### Changed
@@ -248,7 +270,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
248270
Linux kernel.
249271
- Added auparse package for parsing audit logs.
250272

251-
[Unreleased]: https://github.com/elastic/go-libaudit/compare/v2.3.3...HEAD
273+
[Unreleased]: https://github.com/elastic/go-libaudit/compare/v2.5.0...HEAD
274+
[2.5.0]: https://github.com/elastic/go-libaudit/releases/tag/v2.5.0
275+
[2.4.0]: https://github.com/elastic/go-libaudit/releases/tag/v2.4.0
252276
[2.3.3]: https://github.com/elastic/go-libaudit/releases/tag/v2.3.3
253277
[2.3.2]: https://github.com/elastic/go-libaudit/releases/tag/v2.3.2
254278
[2.3.1]: https://github.com/elastic/go-libaudit/releases/tag/v2.3.1

Vagrantfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SCRIPT
1111
install_gvm = <<SCRIPT
1212
mkdir -p ~/bin
1313
if [ ! -e "~/bin/gvm" ]; then
14-
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.4.0/gvm-linux-amd64
14+
curl -sL -o ~/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-linux-amd64
1515
chmod +x ~/bin/gvm
1616
~/bin/gvm #{GO_VERSION}
1717
echo 'export GOPATH=$HOME/go' >> ~/.bash_profile
@@ -29,7 +29,7 @@ rm -f golangci-lint-#{GOLANGCI_LINT_VERSION}-linux-amd64.deb
2929
SCRIPT
3030

3131
Vagrant.configure(2) do |config|
32-
config.vm.box = "ubuntu/impish64"
32+
config.vm.box = "ubuntu/mantic64"
3333
config.vm.network :forwarded_port, guest: 22, host: 2228, id: "ssh", auto_correct: true
3434
config.vm.provision "shell", inline: create_symlink, privileged: false
3535
config.vm.provision "shell", inline: install_gvm, privileged: false

aucoalesce/coalesce_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"bufio"
2222
"encoding/json"
2323
"flag"
24-
"io/ioutil"
2524
"os"
2625
"path/filepath"
2726
"sort"
@@ -30,7 +29,7 @@ import (
3029

3130
"github.com/stretchr/testify/assert"
3231
"github.com/stretchr/testify/require"
33-
"gopkg.in/yaml.v2"
32+
"gopkg.in/yaml.v3"
3433

3534
"github.com/elastic/go-libaudit/v2/auparse"
3635
)
@@ -110,7 +109,7 @@ func testCoalesceEvent(t *testing.T, file string) {
110109
}
111110

112111
func readEventsFromYAML(t testing.TB, name string) []testEvent {
113-
file, err := ioutil.ReadFile(name)
112+
file, err := os.ReadFile(name)
114113
if err != nil {
115114
t.Fatal(err)
116115
}
@@ -125,7 +124,7 @@ func readEventsFromYAML(t testing.TB, name string) []testEvent {
125124
t.Fatal("failed to find 'tests' in yaml")
126125
}
127126

128-
cases, ok := tests.(map[interface{}]interface{})
127+
cases, ok := tests.(map[string]interface{})
129128
if !ok {
130129
t.Fatalf("unexpected type %T for 'tests'", tests)
131130
}
@@ -147,7 +146,7 @@ func readEventsFromYAML(t testing.TB, name string) []testEvent {
147146
}
148147

149148
testEvents = append(testEvents, testEvent{
150-
name: name.(string),
149+
name: name,
151150
messages: msgs,
152151
})
153152
}
@@ -184,7 +183,7 @@ func writeGoldenFile(name string, events []testEventOutput) error {
184183
func readGoldenFile(name string) ([]map[string]interface{}, error) {
185184
name = strings.TrimSuffix(name, ".yaml")
186185

187-
data, err := ioutil.ReadFile(name + ".json.golden")
186+
data, err := os.ReadFile(name + ".json.golden")
188187
if err != nil {
189188
return nil, err
190189
}

aucoalesce/normalizations.yaml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
# Macros declares some YAML anchors that can be referenced for some common
33
# object type normalizations like user-session, socket, or process.
44
macros:
5-
- &defaults
6-
subject:
7-
primary: auid
8-
secondary: uid
9-
how: [exe, comm]
10-
115
- &macro-user-session
126
subject:
137
primary: auid
@@ -18,21 +12,6 @@ macros:
1812
what: user-session
1913
how: [exe, terminal]
2014

21-
- &macro-socket
22-
<<: *defaults
23-
object:
24-
primary: [addr, path]
25-
secondary: port
26-
what: socket
27-
28-
- &macro-process
29-
<<: *defaults
30-
object:
31-
primary: [cmd, exe, comm]
32-
secondary: pid
33-
what: process
34-
how: terminal
35-
3615
- &ecs-iam
3716
category: iam
3817
type: info
@@ -548,6 +527,15 @@ normalizations:
548527
ecs:
549528
<<: *ecs-process
550529
type: change
530+
- action: end
531+
object:
532+
what: process
533+
how: syscall
534+
syscalls:
535+
# exit_group - exit all threads in a process
536+
- exit_group
537+
ecs: *ecs-process
538+
type: end
551539

552540
# Currently unhandled
553541
# this list comes from parsing linux man pages at https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
@@ -673,7 +661,6 @@ normalizations:
673661
# acct - switch process accounting on or off
674662
# sigsuspend - wait for a signal
675663
# rt_sigsuspend - wait for a signal
676-
# exit_group - exit all threads in a process
677664
# socket - create an endpoint for communication
678665
# ioctl_userfaultfd - create a file descriptor for handling page faults in user space
679666
# sched_get_priority_max - get static priority range
@@ -1531,6 +1518,7 @@ normalizations:
15311518
object:
15321519
primary: addr
15331520
secondary: [rport]
1521+
what: user-session
15341522
record_types: CRYPTO_SESSION
15351523
source_ip: [addr]
15361524
ecs: *ecs-process

aucoalesce/normalize.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"fmt"
2323
"strings"
2424

25-
"gopkg.in/yaml.v2"
25+
"gopkg.in/yaml.v3"
2626
)
2727

2828
var (

aucoalesce/normalize_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
package aucoalesce
1919

2020
import (
21-
"io/ioutil"
21+
"os"
2222
"testing"
2323

2424
"github.com/stretchr/testify/assert"
25-
"gopkg.in/yaml.v2"
25+
"gopkg.in/yaml.v3"
2626
)
2727

2828
func TestNormInit(t *testing.T) {
@@ -31,7 +31,7 @@ func TestNormInit(t *testing.T) {
3131
}
3232

3333
func TestLoadNormalizationConfig(t *testing.T) {
34-
b, err := ioutil.ReadFile("normalizations.yaml")
34+
b, err := os.ReadFile("normalizations.yaml")
3535
if err != nil {
3636
t.Fatal(err)
3737
}

audit.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import (
3030
"time"
3131
"unsafe"
3232

33-
"go.uber.org/multierr"
34-
3533
"github.com/elastic/go-libaudit/v2/auparse"
3634
)
3735

@@ -451,7 +449,7 @@ func (c *AuditClient) Close() error {
451449
err = c.set(status, NoWait)
452450
}
453451

454-
err = multierr.Append(err, c.Netlink.Close())
452+
err = errors.Join(err, c.Netlink.Close())
455453
})
456454

457455
return err

auparse/auparse.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
//go:generate sh -c "perl mk_audit_syscalls.pl > zaudit_syscalls.go && gofmt -s -w zaudit_syscalls.go"
3434
//go:generate perl mk_audit_arches.pl
3535
//go:generate go run mk_audit_exit_codes.go
36+
//go:generate go run github.com/elastic/go-licenser
3637

3738
const (
3839
typeToken = "type="
@@ -55,6 +56,8 @@ type AuditMessage struct {
5556
Sequence uint32 // Sequence parsed from payload.
5657
RawData string // Raw message as a string.
5758

59+
Payload interface{} // Opaque payload. This can be anything that is needed to be preserved along with the message and returned back after aggregation.
60+
5861
offset int // offset is the index into RawData where the header ends and message begins.
5962
data map[string]string // The key value pairs parsed from the message.
6063
tags []string // The keys associated with the event (e.g. the values set in rules with -F key=exec).

auparse/auparse_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"encoding/json"
2323
"flag"
2424
"fmt"
25-
"io/ioutil"
2625
"os"
2726
"path/filepath"
2827
"regexp"
@@ -436,7 +435,7 @@ func writeGoldenFile(sourceName string, events []*AuditMessage) error {
436435
}
437436

438437
func readGoldenFile(name string) ([]*StoredAuditMessage, error) {
439-
data, err := ioutil.ReadFile(name)
438+
data, err := os.ReadFile(name)
440439
if err != nil {
441440
return nil, err
442441
}
@@ -480,7 +479,7 @@ func BenchmarkParseLogLine(b *testing.B) {
480479
require.NoError(b, err)
481480
var msgs []string
482481
for _, f := range files {
483-
data, err := ioutil.ReadFile(f)
482+
data, err := os.ReadFile(f)
484483
require.NoError(b, err)
485484
for _, line := range strings.Split(strings.TrimSpace(string(data)), "\n") {
486485
if _, err = ParseLogLine(line); err == nil {

auparse/defs_audit_arches.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)