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

Use Go embed for normalizations.yaml data #104

Merged
merged 5 commits into from
Feb 7, 2022
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://editorconfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.go]
indent_style = tab
indent_size = 4
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Update syscall, arches, and audit msg type tables for Linux 5.16. [#96](https://github.com/elastic/go-libaudit/pull/96)
- Go 1.16 or newer is required because the project uses the embed package. [#104](https://github.com/elastic/go-libaudit/pull/104)
- Fixed error messages from `AddRule()` in the audit client. [#103](https://github.com/elastic/go-libaudit/pull/103)

### Removed
Expand Down
8 changes: 3 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
GO_VERSION = File.read(File.join(File.dirname(__FILE__), ".go-version")).strip

create_symlink = <<SCRIPT
echo 'Creating github.com/elastic in the GOPATH'
mkdir -p ~/go/src/github.com/elastic
echo 'Symlinking /vagrant to ~/go/src/github.com/elastic'
cd ~/go/src/github.com/elastic
if [ -d "/vagrant" ] && [ ! -e "go-libaudit" ]; then ln -s /vagrant go-libaudit; fi
echo "Creating go-libaudit symlink in $HOME"
cd $HOME
if [ -d "/vagrant" ] && [ ! -e "go-libaudit" ]; then ln -s /vagrant go-libaudit; fi
SCRIPT

install_gvm = <<SCRIPT
Expand Down
126 changes: 0 additions & 126 deletions aucoalesce/mknormalize_data.go

This file was deleted.

14 changes: 6 additions & 8 deletions aucoalesce/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,24 @@
package aucoalesce

import (
_ "embed"
"fmt"
"strings"

"gopkg.in/yaml.v2"
)

//go:generate sh -c "go run mknormalize_data.go normalizationData normalizations.yaml > znormalize_data.go"

var (
//go:embed normalizations.yaml
normalizationDataYAML []byte

syscallNorms map[string]*Normalization
recordTypeNorms map[string][]*Normalization
)

func init() {
data, err := asset("normalizationData")
if err != nil {
panic("normalizationData not found in assets")
}

syscallNorms, recordTypeNorms, err = LoadNormalizationConfig(data)
var err error
syscallNorms, recordTypeNorms, err = LoadNormalizationConfig(normalizationDataYAML)
if err != nil {
panic(fmt.Errorf("failed to parse built in normalization mappings: %w", err))
}
Expand Down
42 changes: 0 additions & 42 deletions aucoalesce/znormalize_data.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/elastic/go-libaudit/v2

go 1.14
go 1.16

require (
github.com/davecgh/go-spew v1.1.0 // indirect
Expand Down