From 28a750201c86631bdc1e45eadb8f547d60571860 Mon Sep 17 00:00:00 2001 From: Andrew Morozko Date: Thu, 20 Jun 2024 19:22:14 +0400 Subject: [PATCH 1/3] More correct versions --- .goreleaser-dev.yaml | 2 +- cmd/version.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.goreleaser-dev.yaml b/.goreleaser-dev.yaml index 875dec9a..b1ee9e16 100644 --- a/.goreleaser-dev.yaml +++ b/.goreleaser-dev.yaml @@ -8,7 +8,7 @@ env: - CGO_ENABLED=0 snapshot: - name_template: "{{.Tag}}-dev{{if .IsGitDirty}}+dirty{{end}}+rev.{{.FullCommit}}" + name_template: "{{ .Version }}-dev+{{if .IsGitDirty}}dirty.{{end}}rev.{{.FullCommit}}" builds: # CLI diff --git a/cmd/version.go b/cmd/version.go index 81e42ca6..e3e07d42 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -34,25 +34,29 @@ func versionFromBuildInfo() (result string) { return } if info.Main.Version != "(devel)" { - result = info.Main.Version + result = strings.ToLower(info.Main.Version) if !strings.HasPrefix(result, "v") { result = "v" + result } return } + var meta []string // It's a dev version not built by goreleaser, add extra info dirtyIdx := slices.IndexFunc(info.Settings, func(s debug.BuildSetting) bool { return s.Key == "vcs.modified" }) if dirtyIdx != -1 && info.Settings[dirtyIdx].Value == "true" { - result += "+dirty" + meta = append(meta, "dirty") } shaIdx := slices.IndexFunc(info.Settings, func(s debug.BuildSetting) bool { return s.Key == "vcs.revision" }) if shaIdx != -1 { - result = fmt.Sprintf("%s+rev.%s", result, info.Settings[shaIdx].Value) + meta = append(meta, "rev", info.Settings[shaIdx].Value) + } + if len(meta) != 0 { + result += "+" + strings.Join(meta, ".") } return } From 3819b057ca6d18a6eb29c5e7b12e39c4ccbf72f9 Mon Sep 17 00:00:00 2001 From: Andrew Morozko Date: Thu, 20 Jun 2024 19:23:02 +0400 Subject: [PATCH 2/3] Keep debug info for dev builds --- .goreleaser-dev.yaml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.goreleaser-dev.yaml b/.goreleaser-dev.yaml index b1ee9e16..f6227623 100644 --- a/.goreleaser-dev.yaml +++ b/.goreleaser-dev.yaml @@ -18,7 +18,7 @@ builds: ldflags: - -X github.com/blackstork-io/fabric/cmd.version={{.Version}} - -X github.com/blackstork-io/fabric/cmd.builtBy=goreleaser - + gcflags: all=-N -l no_unique_dist_dir: true # Plugins @@ -27,88 +27,103 @@ builds: main: ./internal/elastic/cmd binary: "plugins/blackstork/elastic@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: github main: ./internal/github/cmd binary: "plugins/blackstork/github@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: graphql main: ./internal/graphql/cmd binary: "plugins/blackstork/graphql@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: openai main: ./internal/openai/cmd binary: "plugins/blackstork/openai@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: opencti main: ./internal/opencti/cmd binary: "plugins/blackstork/opencti@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: nistnvd main: ./internal/nistnvd/cmd binary: "plugins/blackstork/nist_nvd@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: postgresql main: ./internal/postgresql/cmd binary: "plugins/blackstork/postgresql@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: sqlite main: ./internal/sqlite/cmd binary: "plugins/blackstork/sqlite@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: terraform main: ./internal/terraform/cmd binary: "plugins/blackstork/terraform@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: hackerone main: ./internal/hackerone/cmd binary: "plugins/blackstork/hackerone@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: virustotal main: ./internal/virustotal/cmd binary: "plugins/blackstork/virustotal@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: splunk main: ./internal/splunk/cmd binary: "plugins/blackstork/splunk@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: stixview main: ./internal/stixview/cmd binary: "plugins/blackstork/stixview@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: snyk main: ./internal/snyk/cmd binary: "plugins/blackstork/snyk@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true - id: microsoft main: ./internal/microsoft/cmd binary: "plugins/blackstork/microsoft@{{ .Version }}" ldflags: "-X main.version={{.Version}}" + gcflags: all=-N -l no_unique_dist_dir: true From 88c79e458335f81ba1a220139dceba5884ffdf9e Mon Sep 17 00:00:00 2001 From: Andrew Morozko Date: Thu, 20 Jun 2024 19:23:53 +0400 Subject: [PATCH 3/3] Fix error on nil args/config for remote plugins --- plugin/pluginapi/v1/dataspec_decoder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/pluginapi/v1/dataspec_decoder.go b/plugin/pluginapi/v1/dataspec_decoder.go index 923f9f65..201792dd 100644 --- a/plugin/pluginapi/v1/dataspec_decoder.go +++ b/plugin/pluginapi/v1/dataspec_decoder.go @@ -10,7 +10,7 @@ import ( func decodeRootSpec(src *Spec) (dataspec.RootSpec, error) { sp, err := decodeSpec(src) - if err != nil { + if sp == nil || err != nil { return nil, err } rs, ok := sp.(dataspec.RootSpec)