Skip to content

Commit 28df562

Browse files
authored
Merge pull request #2 from Issif/workflow
add workflow to publish the plugin and its rules
2 parents 66e0bc8 + 3ceb52d commit 28df562

File tree

8 files changed

+223
-8
lines changed

8 files changed

+223
-8
lines changed

.github/workflows/release.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release Plugins
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
env:
9+
OCI_REGISTRY: ghcr.io
10+
PLUGIN_NAME: nomad
11+
12+
permissions:
13+
contents: write
14+
packages: write
15+
16+
jobs:
17+
publish-oci-artifacts:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout Falcoctl Repo
21+
uses: actions/checkout@v3
22+
with:
23+
repository: falcosecurity/falcoctl
24+
ref: v0.5.1
25+
path: tools/falcoctl
26+
- name: Setup Golang
27+
uses: actions/setup-go@v4
28+
with:
29+
go-version: '^1.20'
30+
cache-dependency-path: tools/falcoctl/go.sum
31+
- name: Build falcoctl
32+
run: make
33+
working-directory: tools/falcoctl
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
with:
37+
path: plugin
38+
- name: Build the plugin
39+
run: make build
40+
working-directory: plugin
41+
- id: StringRepoName
42+
uses: ASzc/change-string-case-action@v5
43+
with:
44+
string: ${{ github.repository }}
45+
- name: Upload OCI artifacts to GitHub packages
46+
run: |
47+
MAJOR=$(echo ${{ github.ref_name }} | cut -f1 -d".")
48+
MINOR=$(echo ${{ github.ref_name }} | cut -f1,2 -d".")
49+
DIR=$(pwd)
50+
51+
cd plugin/
52+
$DIR/tools/falcoctl/falcoctl registry push \
53+
${{ env.OCI_REGISTRY }}/${{ steps.StringRepoName.outputs.lowercase }}/plugin/${{ env.PLUGIN_NAME }}:${{ github.ref_name }} \
54+
--config /dev/null \
55+
--type plugin \
56+
--version "${{ github.ref_name }}" \
57+
--tag latest --tag $MAJOR --tag $MINOR \
58+
--platform linux/amd64 \
59+
--requires plugin_api_version:2.0.0 \
60+
--depends-on ${{ env.PLUGIN_NAME }}-rules:${{ github.ref_name }} \
61+
--name ${{ env.PLUGIN_NAME }} \
62+
lib${{ env.PLUGIN_NAME }}.so
63+
64+
cd rules/
65+
$DIR/tools/falcoctl/falcoctl registry push \
66+
${{ env.OCI_REGISTRY }}/${{ steps.StringRepoName.outputs.lowercase }}/ruleset/${{ env.PLUGIN_NAME }}:${{ github.ref_name }} \
67+
--config /dev/null \
68+
--type rulesfile \
69+
--version "${{ github.ref_name }}" \
70+
--tag latest --tag $MAJOR --tag $MINOR \
71+
--depends-on ${{ env.PLUGIN_NAME }}:${{ github.ref_name }} \
72+
--name ${{ env.PLUGIN_NAME }}-rules \
73+
${{ env.PLUGIN_NAME }}_rules.yaml
74+
env:
75+
FALCOCTL_REGISTRY_AUTH_BASIC: ${{ env.OCI_REGISTRY }},${{ github.repository_owner }},${{ secrets.GITHUB_TOKEN }}
76+
77+
release:
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v3
82+
with:
83+
fetch-depth: 0
84+
- name: Setup Golang
85+
uses: actions/setup-go@v3
86+
with:
87+
go-version: '1.19'
88+
- name: Run GoReleaser
89+
uses: goreleaser/goreleaser-action@v4
90+
with:
91+
version: latest
92+
args: release --clean --timeout 120m
93+
env:
94+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95+
LDFLAGS: "-buildmode=c-shared"
96+
GOPATH: /home/runner/go

.goreleaser.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
builds:
2+
- env:
3+
- GODEBUG=cgocheck=0
4+
main: ./plugin
5+
binary: libnomad.so
6+
goos:
7+
- linux
8+
goarch:
9+
- amd64
10+
flags: -buildmode=c-shared
11+
checksum:
12+
name_template: "checksums.txt"

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@ GO ?= go
33

44
NAME := nomad
55
OUTPUT := lib$(NAME).so
6+
DESTDIR := /usr/share/falco/plugins
67

78
ifeq ($(DEBUG), 1)
89
GODEBUGFLAGS= GODEBUG=cgocheck=2
910
else
1011
GODEBUGFLAGS= GODEBUG=cgocheck=0
1112
endif
1213

13-
all: $(OUTPUT)
14+
all: build
1415

1516
clean:
16-
@rm -f $(OUTPUT)
17+
@rm -f lib$(NAME).so
1718

18-
$(OUTPUT):
19-
@$(GODEBUGFLAGS) $(GO) build -buildmode=c-shared -o $(OUTPUT) ./plugin
19+
build: clean
20+
@$(GODEBUGFLAGS) $(GO) build -buildmode=c-shared -buildvcs=false -o $(OUTPUT) ./plugin
21+
22+
install: build
23+
mv $(OUTPUT) $(DESTDIR)/

go.mod

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module github.com/albertollamaso/nomad-plugin
2+
3+
go 1.20
4+
5+
require (
6+
github.com/alecthomas/jsonschema v0.0.0-20220216202328-9eeeec9d044b
7+
github.com/falcosecurity/plugin-sdk-go v0.7.1
8+
github.com/hashicorp/nomad/api v0.0.0-20230615131811-288ff2f0c437
9+
)
10+
11+
require (
12+
github.com/gorilla/websocket v1.5.0 // indirect
13+
github.com/hashicorp/cronexpr v1.1.1 // indirect
14+
github.com/hashicorp/errwrap v1.1.0 // indirect
15+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
16+
github.com/hashicorp/go-multierror v1.1.1 // indirect
17+
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
18+
github.com/iancoleman/orderedmap v0.2.0 // indirect
19+
github.com/mitchellh/go-homedir v1.1.0 // indirect
20+
github.com/mitchellh/mapstructure v1.5.0 // indirect
21+
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect
22+
)

go.sum

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
github.com/alecthomas/jsonschema v0.0.0-20220216202328-9eeeec9d044b h1:doCpXjVwui6HUN+xgNsNS3SZ0/jUZ68Eb+mJRNOZfog=
2+
github.com/alecthomas/jsonschema v0.0.0-20220216202328-9eeeec9d044b/go.mod h1:/n6+1/DWPltRLWL/VKyUxg6tzsl5kHUCcraimt4vr60=
3+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
7+
github.com/falcosecurity/plugin-sdk-go v0.7.1 h1:tVi5MdQ9dq6i5f5R29ufhsgKs0gYOXLZQ4d83gEbanE=
8+
github.com/falcosecurity/plugin-sdk-go v0.7.1/go.mod h1:NP+y22DYOS+G3GDXIXNmzf0CBL3nfPPMoQuHvAzfitQ=
9+
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
10+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
11+
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
12+
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
13+
github.com/hashicorp/cronexpr v1.1.1 h1:NJZDd87hGXjoZBdvyCF9mX4DCq5Wy7+A/w+A7q0wn6c=
14+
github.com/hashicorp/cronexpr v1.1.1/go.mod h1:P4wA0KBl9C5q2hABiMO7cp6jcIg96CDh1Efb3g1PWA4=
15+
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
16+
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
17+
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
18+
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
19+
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
20+
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
21+
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
22+
github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
23+
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
24+
github.com/hashicorp/nomad/api v0.0.0-20230615131811-288ff2f0c437 h1:zKGebmv70+p0/vEqhnpCSUvMGgmNvwaeNd8f9ElChIs=
25+
github.com/hashicorp/nomad/api v0.0.0-20230615131811-288ff2f0c437/go.mod h1:Xjd3OXUTfsWbCCBsQd3EdfPTz5evDi+fxqdvpN+WqQg=
26+
github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
27+
github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA=
28+
github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
29+
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
30+
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
31+
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
32+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
33+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
34+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
35+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
36+
github.com/shoenig/test v0.6.6 h1:Oe8TPH9wAbv++YPNDKJWUnI8Q4PPWCx3UbOfH+FxiMU=
37+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
38+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
39+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
40+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
41+
github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
42+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
43+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
44+
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
45+
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
46+
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
47+
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
48+
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
49+
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
50+
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
51+
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
52+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
53+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
54+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
55+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

index.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- name: nomad
2+
type: plugin
3+
registry: ghcr.io
4+
repository: albertollamaso/nomad-plugin/plugin/nomad
5+
description: Reads events from Nomad
6+
home: https://github.com/albertollamaso/nomad-plugin
7+
keywords:
8+
- nomad
9+
license: Apache-2.0
10+
maintainers:
11+
- name: Alberto Llamas
12+
sources:
13+
- https://github.com/albertollamaso/nomad-plugin
14+
- name: nomad-rules
15+
type: rulesfile
16+
registry: ghcr.io
17+
repository: albertollamaso/nomad-plugin/ruleset/nomad
18+
description: Rules for the Nomad plugin
19+
home: https://github.com/albertollamaso/nomad-plugin/tree/main/rules
20+
keywords:
21+
- nomad
22+
license: Apache-2.0
23+
maintainers:
24+
- name: Alberto Llamas
25+
sources:
26+
- https://github.com/albertollamaso/nomad-plugin/tree/main/rules/nomad_rules.yaml

pkg/nomad/plugin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ const (
1010
// note: 999 is for development only. Once released, plugins need to
1111
// get assigned an ID in the public Falcosecurity registry.
1212
// See: https://github.com/falcosecurity/plugins#plugin-registry
13-
PluginID uint32 = 999
13+
PluginID uint32 = 10
1414
PluginName = "nomad"
1515
PluginDescription = "Falcosecurity Nomad Plugin"
1616
PluginContact = "github.com/albertollamaso/nomad-plugin"
17-
PluginVersion = "0.1.0"
17+
PluginVersion = "0.2.0"
1818
PluginEventSource = "nomad"
1919
)
2020

rules/nomad_rules.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
- required_plugin_versions:
55
- name: nomad
6-
version: 0.1.0
7-
- name: json
86
version: 0.2.0
7+
- name: json
8+
version: 0.7.0
99

1010
- macro: nomad_alloc_updated
1111
condition: nomad.event.topic="Allocation"

0 commit comments

Comments
 (0)