Skip to content

Commit

Permalink
proto compilation errors resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
valllabh committed Nov 7, 2023
1 parent a99f147 commit 73c61ff
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
34 changes: 25 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
.PHONY: clean create-proto compile-proto run

clean:
rm -rf ./docs/*
rm -rf ./output/*
install-protoc-linux:
sudo apt-get update
sudo apt-get install -y protobuf-compiler
export PATH="$PATH:$(go env GOPATH)/bin"
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc --version

clean-output-java:
rm -rf ./output/java/*
clean-output-golang:
rm -rf ./output/golang/*
clean-output-proto:
rm -rf ./output/proto/*
clean-bin:
rm -rf ./bin/*

docs:
clean-docs:
rm -rf ./docs/*

clean-all: clean-output clean-bin clean-docs

build-docs: clean-docs
go run doc-generator/doc-generator.go

build:
build-project: clean-bin
mkdir -p ./bin/
go build -o ./bin/ocsf-tool

compile-proto:
test-compile-proto: clean-output-java clean-output-golang
mkdir -p ./output/java
mkdir -p ./output/golang
find ./output/proto -type f -name "*.proto" | xargs protoc --proto_path=./output/proto --java_out=./output/java --go_opt=paths=source_relative --go_out=./output/golang

test-run:
./bin/ocsf-tool generate-proto file_activity security_finding
test-create-proto: clean-output-proto
./bin/ocsf-tool generate-proto file_activity

run: clean docs build test-run
run: build-docs build-project test-create-proto test-compile-proto
1 change: 1 addition & 0 deletions commands/generate_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func runGenerateProtoCmd(cmd *cobra.Command, args []string) {
if len(protoRootPackage) > 0 && len(protoOutput) > 0 {
rootPackage := protobuff_v3.NewPackage(protoRootPackage, nil)
rootPackage.Path = protoOutput
mapper.OutputPath = protoOutput
mapper.RootPackage = protobuff_v3.NewPackage(toVersionPackage(strcase.ToSnake(ocsfSchema.Version)), rootPackage)
}

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ require (

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/text v0.3.8 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)

Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand All @@ -95,6 +98,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -444,6 +448,10 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
2 changes: 1 addition & 1 deletion ocsf/mappers/protobuff_v3/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import (

func (i *Import) Marshal() string {
path := i.Name
path = strings.ReplaceAll(path, GetMapper().RootPackage.GetDirPath()+"/", "")
path = strings.ReplaceAll(path, GetMapper().OutputPath+"/", "")
return fmt.Sprintf("import \"%s\";", path)
}
1 change: 0 additions & 1 deletion ocsf/mappers/protobuff_v3/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func (p *Pkg) GetDirName() string {
}

func (p *Pkg) GetDirPath() string {

path := p.Path

if p.Parent != nil {
Expand Down
1 change: 1 addition & 0 deletions ocsf/mappers/protobuff_v3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ type mapper struct {
Enums Enums
Cache CacheMap
RootPackage *Pkg
OutputPath string
Fs afero.Fs
}

0 comments on commit 73c61ff

Please sign in to comment.