diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..437bdaa --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,96 @@ +name: Release Plugins + +on: + push: + tags: + - '*' + +env: + OCI_REGISTRY: ghcr.io + PLUGIN_NAME: dnscollector + +permissions: + contents: write + packages: write + +jobs: + publish-oci-artifacts: + runs-on: ubuntu-latest + steps: + - name: Checkout Falcoctl Repo + uses: actions/checkout@v3 + with: + repository: falcosecurity/falcoctl + ref: main + path: tools/falcoctl + - name: Setup Golang + uses: actions/setup-go@v4 + with: + go-version: '^1.20' + cache-dependency-path: tools/falcoctl/go.sum + - name: Build falcoctl + run: make + working-directory: tools/falcoctl + - name: Checkout + uses: actions/checkout@v3 + with: + path: plugin + - name: Build the plugin + run: make build + working-directory: plugin + - id: StringRepoName + uses: ASzc/change-string-case-action@v5 + with: + string: ${{ github.repository }} + - name: Upload OCI artifacts to GitHub packages + run: | + MAJOR=$(echo ${{ github.ref_name }} | cut -f1 -d".") + MINOR=$(echo ${{ github.ref_name }} | cut -f1,2 -d".") + DIR=$(pwd) + + cd plugin/ + $DIR/tools/falcoctl/falcoctl registry push \ + ${{ env.OCI_REGISTRY }}/${{ steps.StringRepoName.outputs.lowercase }}/plugin/${{ env.PLUGIN_NAME }}:${{ github.ref_name }} \ + --config /dev/null \ + --type plugin \ + --version "${{ github.ref_name }}" \ + --tag latest --tag $MAJOR --tag $MINOR \ + --platform linux/amd64 \ + --requires plugin_api_version:2.0.0 \ + --depends-on ${{ env.PLUGIN_NAME }}-rules:${{ github.ref_name }} \ + --name ${{ env.PLUGIN_NAME }} \ + lib${{ env.PLUGIN_NAME }}.so + + cd rules/ + $DIR/tools/falcoctl/falcoctl registry push \ + ${{ env.OCI_REGISTRY }}/${{ steps.StringRepoName.outputs.lowercase }}/ruleset/${{ env.PLUGIN_NAME }}:${{ github.ref_name }} \ + --config /dev/null \ + --type rulesfile \ + --version "${{ github.ref_name }}" \ + --tag latest --tag $MAJOR --tag $MINOR \ + --depends-on ${{ env.PLUGIN_NAME }}:${{ github.ref_name }} \ + --name ${{ env.PLUGIN_NAME }}-rules \ + ${{ env.PLUGIN_NAME }}_rules.yaml + env: + FALCOCTL_REGISTRY_AUTH_BASIC: ${{ env.OCI_REGISTRY }},${{ github.repository_owner }},${{ secrets.GITHUB_TOKEN }} + + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Golang + uses: actions/setup-go@v3 + with: + go-version: '1.20' + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --clean --timeout 120m + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + LDFLAGS: "-buildmode=c-shared" + GOPATH: /home/runner/go \ No newline at end of file diff --git a/.gitignore b/.gitignore index 21857fe..65f1fe2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ falco.yaml -git_clean.sh \ No newline at end of file +git_clean.sh +dist +.vscode +lib* \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..41da1e5 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,12 @@ +builds: + - env: + - GODEBUG=cgocheck=0 + main: ./plugin + binary: libdocker.so + goos: + - linux + goarch: + - amd64 + flags: -buildmode=c-shared +checksum: + name_template: "checksums.txt" \ No newline at end of file diff --git a/index.yaml b/index.yaml new file mode 100644 index 0000000..515cd40 --- /dev/null +++ b/index.yaml @@ -0,0 +1,26 @@ +- name: dnscollector + type: plugin + registry: ghcr.io + repository: sysdigdan/dnscollector-plugin/plugin/dnscollector + description: Reads events from dnscollector Engine + home: https://github.com/SysdigDan/dnscollector-falco-plugin + keywords: + - dnscollector + license: Apache-2.0 + mastertainers: + - name: Daniel Moloney + sources: + - https://github.com/SysdigDan/dnscollector-falco-plugin +- name: dnscollector-rules + type: rulesfile + registry: ghcr.io + repository: sysdigdan/dnscollector-plugin/ruleset/dnscollector + description: Rules for the dnscollector plugin + home: https://github.com/SysdigDan/dnscollector-falco-plugin/tree/master/rules + keywords: + - dnscollector + license: Apache-2.0 + mastertainers: + - name: Daniel Moloney + sources: + - https://github.com/SysdigDan/dnscollector-falco-plugin/tree/master/rules/dnscollector_rules.yaml \ No newline at end of file diff --git a/plugin/dnscollector.go b/plugin/main.go similarity index 100% rename from plugin/dnscollector.go rename to plugin/main.go