Compare commits

...

237 Commits

Author SHA1 Message Date
dependabot[bot] 341b572157 chore(deps): bump docker/login-action in the actions group
Bumps the actions group with 1 update: [docker/login-action](https://github.com/docker/login-action).


Updates `docker/login-action` from 3.4.0 to 3.5.0
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](74a5d14239...184bdaa072)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-06 10:34:03 +02:00
dependabot[bot] ad17b051e2 chore(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 28.3.0+incompatible to 28.3.3+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.3.0...v28.3.3)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.3.3+incompatible
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-30 09:01:16 +02:00
Dominic Evans 612342a7d5 chore(deps): migrate blang/semver to v4
The semver package moved to the versioned import path some time back.
Move to /v4 to sync with falcoctl and avoid pulling in two copies of the
module.

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>
2025-07-29 22:22:12 +02:00
Federico Di Pierro 77a9076701 fix(docker): fixed buster builder docker image.
As buster reached its EOL, the official debian repo URL doesn't
host anymore buster packages info. For this reason, pin
to the `20250630T203427Z` snapshot, which still contains them.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-07-23 11:27:34 +02:00
dependabot[bot] 956b590d1d chore(deps): bump docker/setup-buildx-action in the actions group
Bumps the actions group with 1 update: [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action).


Updates `docker/setup-buildx-action` from 3.11.0 to 3.11.1
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](18ce135bb5...e468171a9d)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-version: 3.11.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-21 11:27:31 +02:00
dependabot[bot] aa62de7da3 chore(deps): bump github.com/go-viper/mapstructure/v2
Bumps [github.com/go-viper/mapstructure/v2](https://github.com/go-viper/mapstructure) from 2.2.1 to 2.3.0.
- [Release notes](https://github.com/go-viper/mapstructure/releases)
- [Changelog](https://github.com/go-viper/mapstructure/blob/main/CHANGELOG.md)
- [Commits](https://github.com/go-viper/mapstructure/compare/v2.2.1...v2.3.0)

---
updated-dependencies:
- dependency-name: github.com/go-viper/mapstructure/v2
  dependency-version: 2.3.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-21 11:26:31 +02:00
Dominic Evans e6b7eb6266 chore(deps): bump github.com/docker/docker to v28
Update api references from v27 to v28 to account for some
movement/renaming of options structs

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>
2025-07-21 11:25:31 +02:00
dependabot[bot] 14146be3fb chore(deps): bump docker/setup-buildx-action in the actions group
Bumps the actions group with 1 update: [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action).


Updates `docker/setup-buildx-action` from 3.10.0 to 3.11.0
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](b5ca514318...18ce135bb5)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-version: 3.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-25 09:50:50 +02:00
dependabot[bot] d5ad21b1d1 chore(deps): bump actions/setup-go in the actions group
Bumps the actions group with 1 update: [actions/setup-go](https://github.com/actions/setup-go).


Updates `actions/setup-go` from 5.4.0 to 5.5.0
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](0aaccfd150...d35c59abb0)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: 5.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-13 18:04:30 +02:00
Federico Di Pierro d2a8f5def5 cleanup(cmd): fixup non-constant format string in call to fmt.Errorf.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-05-07 15:22:49 +02:00
Federico Di Pierro 3d66199c20 update(go): bumped falcoctl dep to latest release.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-05-07 15:22:49 +02:00
dependabot[bot] f366f93c16 chore(deps): bump actions/download-artifact in the actions group
Bumps the actions group with 1 update: [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/download-artifact` from 4.2.1 to 4.3.0
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](95815c38cf...d3f86a106a)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 4.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-29 09:07:06 +02:00
dependabot[bot] 2722e67473 chore(deps): bump golang.org/x/net from 0.36.0 to 0.38.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.36.0 to 0.38.0.
- [Commits](https://github.com/golang/net/compare/v0.36.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-version: 0.38.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-18 09:34:50 +02:00
Federico Di Pierro 390d219a4a chore(pkg): default to gcc14 image for kernels >= 6.9.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-04-11 16:49:13 +02:00
Federico Di Pierro 1c79541976 new(docker): add a `any` distro gcc 14.0.0 image.
Drop archlinux-specific gcc14.0.0 image.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-04-11 16:49:13 +02:00
dependabot[bot] 297b55b22c chore(deps): bump goreleaser/goreleaser-action in the actions group
Bumps the actions group with 1 update: [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action).


Updates `goreleaser/goreleaser-action` from 6.2.1 to 6.3.0
- [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
- [Commits](90a3faa9d0...9c156ee8a1)

---
updated-dependencies:
- dependency-name: goreleaser/goreleaser-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-02 10:54:16 +02:00
dependabot[bot] 016635f87f chore(deps): bump the actions group with 3 updates
Bumps the actions group with 3 updates: [actions/setup-go](https://github.com/actions/setup-go), [actions/download-artifact](https://github.com/actions/download-artifact) and [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/setup-go` from 5.3.0 to 5.4.0
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](f111f3307d...0aaccfd150)

Updates `actions/download-artifact` from 4.1.9 to 4.2.1
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](cc20338598...95815c38cf)

Updates `actions/upload-artifact` from 4.6.1 to 4.6.2
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](4cec3d8aa0...ea165f8d65)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-24 21:29:19 +01:00
Luca Guerra 7277fc9e82 cleanup(ci): use gh action hashes
Signed-off-by: Luca Guerra <luca@guerra.sh>
2025-03-18 17:27:16 +01:00
dependabot[bot] 9eda7d869c chore(deps): bump docker/login-action in the actions group
Bumps the actions group with 1 update: [docker/login-action](https://github.com/docker/login-action).


Updates `docker/login-action` from 3.3.0 to 3.4.0
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](9780b0c442...74a5d14239)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-17 18:57:08 +01:00
Federico Di Pierro 725dcf27d0 chore(go): ran go mod tidy.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-03-14 11:40:50 +01:00
dependabot[bot] 7f3df16352 chore(deps): bump golang.org/x/net from 0.33.0 to 0.36.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.33.0 to 0.36.0.
- [Commits](https://github.com/golang/net/compare/v0.33.0...v0.36.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-14 11:40:50 +01:00
dependabot[bot] 326387b458 chore(deps): bump the actions group with 2 updates
Bumps the actions group with 2 updates: [actions/download-artifact](https://github.com/actions/download-artifact) and [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action).


Updates `actions/download-artifact` from 4.1.8 to 4.1.9
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](fa0a91b85d...cc20338598)

Updates `docker/setup-buildx-action` from 3.9.0 to 3.10.0
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](f7ce87c1d6...b5ca514318)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-12 09:49:41 +01:00
dependabot[bot] 219a3e5b6e chore(deps): bump actions/upload-artifact in the actions group
Bumps the actions group with 1 update: [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/upload-artifact` from 4.6.0 to 4.6.1
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](65c4c4a1dd...4cec3d8aa0)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-27 15:31:33 +01:00
dependabot[bot] 238d1fdd81 chore(deps): bump goreleaser/goreleaser-action in the actions group
Bumps the actions group with 1 update: [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action).


Updates `goreleaser/goreleaser-action` from 6.1.0 to 6.2.1
- [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
- [Commits](9ed2f89a66...90a3faa9d0)

---
updated-dependencies:
- dependency-name: goreleaser/goreleaser-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-17 17:18:33 +01:00
dependabot[bot] 6e5086a9b0 chore(deps): bump golang.org/x/net from 0.31.0 to 0.33.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.31.0 to 0.33.0.
- [Commits](https://github.com/golang/net/compare/v0.31.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-12 19:37:05 +01:00
dependabot[bot] 97d109a367 chore(deps): bump docker/setup-buildx-action in the actions group
Bumps the actions group with 1 update: [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action).


Updates `docker/setup-buildx-action` from 3.8.0 to 3.9.0
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](6524bf65af...f7ce87c1d6)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-12 12:00:05 +01:00
Federico Di Pierro 07fef60f94 chore(docker,pkg): added new archlinux builder image to build recent archlinux kernels (>= 6.10).
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-01-27 10:26:30 +01:00
Federico Di Pierro b59107a0f5 fix(pkg/driverbuilder): fixed archlinux kernel URLs support.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-01-27 10:26:30 +01:00
Federico Di Pierro 743165d933 chore(ci): switch to github provided arm64 runners.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-01-17 10:37:32 +01:00
dependabot[bot] 6997939d9c chore(deps): bump actions/upload-artifact in the actions group
Bumps the actions group with 1 update: [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/upload-artifact` from 4.5.0 to 4.6.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](6f51ac03b9...65c4c4a1dd)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-17 10:29:32 +01:00
Federico Di Pierro 1eacd333d9 chore(github): default to NONE for release-note section in the PR template.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-01-08 12:27:40 +01:00
Federico Di Pierro 9b7ed7025e fix(docs): fixed release document.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2025-01-08 12:27:40 +01:00
dependabot[bot] fdd95dd973 chore(deps): bump golang.org/x/crypto from 0.29.0 to 0.31.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.29.0 to 0.31.0.
- [Commits](https://github.com/golang/crypto/compare/v0.29.0...v0.31.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-02 10:05:05 +01:00
dependabot[bot] 1df92e24af chore(deps): bump actions/upload-artifact in the actions group
Bumps the actions group with 1 update: [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/upload-artifact` from 4.4.3 to 4.5.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](b4b15b8c7c...6f51ac03b9)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-23 17:03:11 +01:00
dependabot[bot] 5d8fdca821 chore(deps): bump docker/setup-buildx-action in the actions group
Bumps the actions group with 1 update: [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action).


Updates `docker/setup-buildx-action` from 3.7.1 to 3.8.0
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](c47758b77c...6524bf65af)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-17 11:21:37 +01:00
dependabot[bot] 0b1df9a424 chore(deps): bump actions/upload-artifact from 3.1.3 to 4.4.3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.3 to 4.4.3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](a8a3f3ad30...b4b15b8c7c)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-06 14:11:45 +01:00
dependabot[bot] 087c634831 chore(deps): bump actions/checkout from 3.5.0 to 4.2.2
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v3.5.0...v4.2.2)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-06 14:10:46 +01:00
dependabot[bot] 5f8abcc5dc chore(deps): bump actions/download-artifact from 3.0.2 to 4.1.8
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3.0.2 to 4.1.8.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](9bc31d5ccc...fa0a91b85d)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-06 14:09:46 +01:00
Luca Guerra 092d9779e3 update(build): update cmake in debian buster image to 3.22
Signed-off-by: Luca Guerra <luca@guerra.sh>
2024-12-06 14:08:46 +01:00
dependabot[bot] 2e08155cb0 chore(deps): bump dorny/paths-filter from 2.11.1 to 3.0.2
Bumps [dorny/paths-filter](https://github.com/dorny/paths-filter) from 2.11.1 to 3.0.2.
- [Release notes](https://github.com/dorny/paths-filter/releases)
- [Changelog](https://github.com/dorny/paths-filter/blob/master/CHANGELOG.md)
- [Commits](4512585405...de90cc6fb3)

---
updated-dependencies:
- dependency-name: dorny/paths-filter
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-06 13:38:46 +01:00
dependabot[bot] ba721c3547 chore(deps): bump the actions group with 3 updates
Bumps the actions group with 3 updates: [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action), [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) and [docker/login-action](https://github.com/docker/login-action).


Updates `goreleaser/goreleaser-action` from 6.0.0 to 6.1.0
- [Release notes](https://github.com/goreleaser/goreleaser-action/releases)
- [Commits](286f3b13b1...9ed2f89a66)

Updates `docker/setup-buildx-action` from 3.0.0 to 3.7.1
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](f95db51fdd...c47758b77c)

Updates `docker/login-action` from 3.0.0 to 3.3.0
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](343f7c4344...9780b0c442)

---
updated-dependencies:
- dependency-name: goreleaser/goreleaser-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-06 13:37:46 +01:00
dependabot[bot] 5945f3a64c chore(deps): bump actions/setup-go from 4 to 5
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-06 13:35:46 +01:00
Federico Di Pierro a1c5330926 fix(pkg/driverbuilder): fixed ubuntu related tests.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-12-06 13:20:46 +01:00
Federico Di Pierro 1279afd390 new(ci): add dependabot for github actions.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-12-06 13:20:46 +01:00
Federico Di Pierro 7c00da080a chore(go): update falcoctl to latest main.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-11-20 16:07:19 +01:00
Federico Di Pierro a3925d612b chore(ci): switch to use cncf provided runners for arm64.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-10-29 10:01:33 +01:00
Federico Di Pierro 5c896b1c75 fix(pkg/kernelrelease): fixed kernelrelease regex for weird COS kernels.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-09-09 10:10:23 +02:00
Federico Di Pierro 126a99b76b fix(pkg/driverbuilder): fix amazonlinux2023 support.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-09-03 13:21:00 +02:00
dependabot[bot] fea50f4997 chore(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 27.0.3+incompatible to 27.1.1+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v27.0.3...v27.1.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-20 17:45:45 +02:00
Andrea Jemmett 3633363a59 chore(pkg/driverbuilder): log warn if no download script was generated
Signed-off-by: Andrea Jemmett <1787979+acidghost@users.noreply.github.com>
2024-08-20 11:26:44 +02:00
Andrea Jemmett cf1eed3e6d fix(pkg/driverbuilder): add fedora updates-archive
Signed-off-by: Andrea Jemmett <1787979+acidghost@users.noreply.github.com>
2024-08-20 11:26:44 +02:00
Federico Di Pierro 9ee5859bb6 fix(docker): fixed centos7 builder because of EoL.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-07-30 10:15:38 +02:00
Federico Di Pierro 2da5fab2b6 chore(pkg,docs): use a working mirror for archlinux arm64.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-07-30 10:14:38 +02:00
Aldo Lacuku ba7f79b19f update(gorelease): bump to v2.0
Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
2024-07-25 17:06:17 +02:00
Aldo Lacuku 5641bd60ee chore(docker): bump docker packaget to v27.0.3+incompatible
Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
2024-07-25 16:54:16 +02:00
Aldo Lacuku 9a5047b94b fix(ci): fix paths filters
Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
2024-07-25 16:41:17 +02:00
Federico Di Pierro 9e6dca81b4 new(pkg,docker): added an amazonlinux2 gcc10 builder.
This fixes driver build issues on al2 5.10 kernels.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-07-19 15:44:35 +02:00
Enzo Venturi 508fb749db docs/builder.md: remove BuilderByTarget references
The 'Target name' subsection is old. BuilderByTarget isn't used anymore; it's now 'byTarget' in target.go. Add a hyperlink for clarity and accessibility.

Signed-off-by: Enzo Venturi <nzventuri@proton.me>
2024-05-23 12:48:23 +02:00
Federico Di Pierro a170df233e chore(pkg/driverbuilder): if envMap is nil, default at empty map.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-05-10 16:00:33 +02:00
Federico Di Pierro 4c7df39332 fix(pkg/driverbuilder): fixed local builder template.
Fix on top of #342.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-05-10 16:00:33 +02:00
Federico Di Pierro 5be1cafdbe chore(cmd,go): bumped falcoctl to latest main.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-05-07 20:50:49 +02:00
Federico Di Pierro 45c4f60cfc fix(pkg/driverbuilder): multiple small fixes to local builder.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-05-07 20:50:49 +02:00
Federico Di Pierro b82fe94867 update: bumped deps and use go1.22 (required by k8s.io/apimachinery)
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-23 15:25:19 +02:00
Federico Di Pierro f0777208d8 update(pkg/kernelrelease): update kernelrelease regex to match more kernels.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-23 15:02:19 +02:00
Federico Di Pierro 00c7e79f2f chore(go.sum): bumped docker library.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-23 15:01:19 +02:00
Federico Di Pierro ad1f711146 chore(cmd,docs): updated docs and fixed cmd related tests.
Moreover, moved cmd output to more strictly follow `falcoctl` one,
with regards to printing usage/helper messages.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-23 15:01:19 +02:00
Federico Di Pierro 95714547c7 chore(cmd,pkg): allow cli test to disable styling.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-23 15:01:19 +02:00
Federico Di Pierro b74bee6de5 chore(cmd,pkg): small improvements and initial test fixes.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-23 15:01:19 +02:00
Federico Di Pierro 038bac2744 new(cmd,pkg,docs,docgen,validate): switched from `slog` go library to use rich-text falcoctl log library.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-23 15:01:19 +02:00
Luca Guerra 634870ffe7 chore(OWNERS): trigger automation
Signed-off-by: Luca Guerra <luca@guerra.sh>
2024-04-22 10:16:15 +02:00
dependabot[bot] 487563ec35 chore(deps): bump golang.org/x/net from 0.22.0 to 0.23.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.22.0 to 0.23.0.
- [Commits](https://github.com/golang/net/compare/v0.22.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-22 09:31:15 +02:00
Federico Di Pierro 11e44ed58a chore(ci): enable PR docker build if `docker/` folder was touched.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-19 16:53:57 +02:00
Federico Di Pierro f07543ce3e chore(docker): fix master CI by using debian:buster with no backports repo for builder gcc8.
Debian-buster backports repo is no more present upstream.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-04-19 16:53:57 +02:00
dependabot[bot] 0bc919d1af chore(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 26.0.0+incompatible to 26.0.2+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.0.0...v26.0.2)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 08:53:56 +02:00
Luca Guerra 8e3e286051 update(owners): trigger automation
Signed-off-by: Luca Guerra <luca@guerra.sh>
2024-04-12 12:25:31 +02:00
Luca Guerra a7da4a43cc update(owners): trigger group update automation
Signed-off-by: Luca Guerra <luca@guerra.sh>
2024-04-12 11:00:31 +02:00
Luca Guerra 8276af82a8 vote: update(owners): add LucaGuerra to owners
Signed-off-by: Luca Guerra <luca@guerra.sh>
2024-04-11 16:17:29 +02:00
Federico Di Pierro 8ea62ad5b7 fix(pkg/driverbuilder): fix `local` executor to correctly fetch KERNELDIR.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-29 13:53:24 +01:00
Federico Di Pierro a6610e6bb2 fix(pkg/driverbuilder): properly export KERNELDIR in kernel-download scripts.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
2024-03-29 13:53:24 +01:00
Federico Di Pierro 712dd3a5da fix(pkg/driverbuilder): fixed debian `rpi` and `rt` flavors kernel urls fetching.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-29 13:52:24 +01:00
Federico Di Pierro 80466fd774 chore: bumped all deps.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-28 14:28:16 +01:00
Federico Di Pierro 9763327cb0 chore(pkg): bumped docker dep to v26.0.0.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-28 14:28:16 +01:00
Federico Di Pierro c12a122672 new(pkg/driverbuilder): added a node selector on kubernetes executor on `kubernetes.io/arch` label.
This implements support for arm64 build for kubernetes executor.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-28 14:27:16 +01:00
Federico Di Pierro 0f094fc0ba fix(pkg/driverbuilder): fixed kubernetes command.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-25 15:28:06 +01:00
Federico Di Pierro cd9e5b30b6 chore(cmd,pkg): support automatic kernel headers download/extraction in local builder.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-25 15:28:06 +01:00
Federico Di Pierro 4f6ee10e09 fix(pkg/driverbuilder): fixed archlinux kernel urls discovering.
Moreover, let KernelDownloadScript method take just kernelUrls instead of full build config.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-25 15:28:06 +01:00
Federico Di Pierro 4ac18aa4fb fix(pkg/driverbuilder): fixed debian_kernel template.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-25 15:28:06 +01:00
Federico Di Pierro e6b6a2e44a new(pkg,cmd): refactored builder script logic.
Builder script has been split in 3 different scripts:
* download libs
* download headers
* build

This way, we can reuse `download libs` script among all of them.
Moreover, it is useful to have a download headers script that is invokeable by itself,
because it has the logic to download and extract headers for a given distro.

Finally, fixed a couple of things with local builder:
* redirect stderr to stdout so that we catch errors too while building
* pre initialize envMap to an empty map, instead of nil
* manage KERNELDIR env var, if set, while building with dkms

The last point allows for consumer to pass `KERNELDIR` inside `envMap` local builder processor
argument to customize the build.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-25 15:28:06 +01:00
dependabot[bot] e828609e05 chore(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 25.0.3+incompatible to 25.0.5+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v25.0.3...v25.0.5)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-25 10:12:05 +01:00
dependabot[bot] ef81d6a9bf chore(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0
Bumps google.golang.org/protobuf from 1.32.0 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-14 16:34:26 +01:00
Federico Di Pierro 318bf04cd5 chore(pkg/driverbuilder): remove some debug `ls`.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-07 18:05:59 +01:00
Federico Di Pierro 28d558197f chore(pkg/driverbuilder): avoid verbose tar command in debian template script.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-03-07 18:05:59 +01:00
Federico Di Pierro 0753b39d89 fix(pkg/driverbuilder): force-set login shell when starting driverkit script.
This will enforce bash to parse bashrc / bash profile files.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-29 18:24:34 +01:00
Federico Di Pierro 69ddbd97ae chore(test): added a centos_3.x regression test to highlight the bug.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-29 18:24:34 +01:00
Federico Di Pierro bdd6cebd6b fix(pkg/driverbuilder): fixed support for ubuntu-lts.
Moreover, properly use newer gcc image from kernel 6.5+.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-29 14:56:34 +01:00
Federico Di Pierro 31c7e6ab08 fix(cmd,pkg,validate): src-dir is not a mandatory parameter for `local` cmd.
Moreover, properly fill CmakeCmd for local target too.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro dd7a2f19c7 chore(pkg/driverbuilder): small fixes for local builder.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro eb850f44d3 fix(pkg/driverbuilder): use a single constant for the Cmake command.
Moreover, add back some now unused cmake variables, ie:
* PROBE_NAME
* PROBE_VERSION
* PROBE_DEVICE_NAME

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro 659d750308 chore(build,ci): allow users to run integration tests against multiple driverversions.
In CI, enable multiple driverversions to test that we do not break against
old driver versions.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro 509cda9565 chore(pkg/driverbuilder): small refactor in local template script.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro 199130da0d chore(pkg,cmd,validate): properly validate that `src-dir` is an absolute existing dir path.
Moreover, take into account srcDir in local builder: when src-dir is specified, sources do not
need to be configured through cmake.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro a5352dea4e fix(pkg): use correct {Module,Probe}FullPath so that we do save a `mv` in template scripts.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro b0f3b394df chore(pkg/driver): fixed up builder templates.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro cbad2a0e39 fix(pkg): ported local builder to use cmake.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro 859270eaab new(docker,pkg/driverbuilder): use cmake instead of makefile template to build kmod and bpf.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:54:28 +01:00
Federico Di Pierro 522466a960 chore(ci): use `go-version-file` for `setup-go` action.
Moreover, switch to setup-go@v4 that supports caching by default.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:05:28 +01:00
Federico Di Pierro e5cf52a971 new(docker,pkg): add new builder with gcc13 for newer kernels.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:05:28 +01:00
Federico Di Pierro eacaee856d update: updated all deps through `go get -u`.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:01:28 +01:00
Federico Di Pierro c08c3cda07 fix(pkg/driverbuilder): fixed local cmd build up using os.Environ().
Moreover, properly mount debugfs before attempting the bpf probe build if needed.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2024-02-28 16:01:28 +01:00
dependabot[bot] be7a75ffad chore(deps): bump github.com/opencontainers/runc from 1.1.9 to 1.1.12
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.9 to 1.1.12.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/v1.1.12/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.9...v1.1.12)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-01 07:30:36 +01:00
Federico Di Pierro 905e423f9c fix(pkg/driverbuilder): fixed debian rpi drivers build.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-20 12:42:12 +01:00
dependabot[bot] 98be2018b9 chore(deps): bump github.com/containerd/containerd from 1.7.5 to 1.7.11
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.5 to 1.7.11.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.5...v1.7.11)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-20 09:10:12 +01:00
dependabot[bot] 39040064e4 chore(deps): bump golang.org/x/crypto from 0.14.0 to 0.17.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.14.0 to 0.17.0.
- [Commits](https://github.com/golang/crypto/compare/v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-19 08:56:06 +01:00
Federico Di Pierro 54beb96d13 chore: fixed manifest creation and push.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 17:21:01 +01:00
Federico Di Pierro 0a763761ed fix(ci): fixed needs name in master and release CI.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro 6a3b6235ce chore(ci): better names.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro 9a07a66c98 chore(ci): use matrixes where needed.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro 4e3bd32bf5 chore(ci): moved manifest step to its own reusable workflow.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro be593e07bf cleanup(ci): dropped circleci.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro 8da011bb36 chore(ci): we can build on ubuntu-latest instead of alpine.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro 7d4894d5d6 chore: disable builmode pie.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro 68188bfe9f new(ci): added gha support.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-18 16:48:02 +01:00
Federico Di Pierro d54b1f307c new(docker): add `cmake` and `git` packages to builders images.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-12 14:50:44 +01:00
Federico Di Pierro e2a4d60d8e fix(pkg): fixed docker multiplexed output function.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-12 14:33:44 +01:00
Logan Bond ba598bcf53 simplify the check
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-12-01 15:27:13 +01:00
Logan Bond c697ed7d12 netmode interface
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-12-01 15:27:13 +01:00
Logan Bond ca7496bbd9 whitespace
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-12-01 15:27:13 +01:00
Logan Bond 9f2d7e65a1 apply these settings to the builderimage, not the driverkit one
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-12-01 15:27:13 +01:00
Logan Bond fb738a4f5f fix syntax
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-12-01 15:27:13 +01:00
Logan Bond db09261782 fixing netmode for sles and adjust target type from sle to sles
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-12-01 15:27:13 +01:00
Federico Di Pierro 53a49eae72 cleanup(cmd): require kernelrelease and kernelversion in local command.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-12-01 14:49:12 +01:00
Federico Di Pierro 2c7d6f04aa new(cmd,pkg/driverbuilder): support `env`,`src-dir` and `dkms` build options in local builder.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-11-24 09:01:48 +01:00
Federico Di Pierro 78bb75af8b new(cmd,pkg): added new `local` command to build local kernel using local kernel sources / gccs / clang.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-11-24 09:01:48 +01:00
Federico Di Pierro 4500840b5b fix(pkg/driverbuilder): fixed docker container output when multiplexed.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-11-13 17:28:48 +01:00
Logan Bond 67451e4a93 sles template
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-11-13 16:24:47 +01:00
Logan Bond 5075ff1df3 add sle target type
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-11-13 16:24:47 +01:00
Federico Di Pierro 1babd00be8 chore(pkg): let KernelRelease type implement `Stringer` interface.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-11-08 18:33:25 +01:00
Federico Di Pierro 344fd254cc cleanup(pkg): store kernelversion inside the kernelrelease type.
It is only used by ubuntu; avoid directly calling `viper.GetString()`.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-11-08 18:33:25 +01:00
Federico Di Pierro 44b8b59f6a fix(pkg/driverbuilder): fixed PhotonOS builder template regex.
Properly match any kernel flavor.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-11-02 16:21:06 +01:00
dependabot[bot] 0ce54a2a2c chore(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 24.0.5+incompatible to 24.0.7+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v24.0.5...v24.0.7)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-30 21:41:56 +01:00
Federico Di Pierro 56573f4059 cleanup(cmd,pkg): properly manage ubuntu flavors at builders level.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-10-23 15:13:18 +02:00
Federico Di Pierro c40e6cec5c fix(docker): fix master ci.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-10-13 15:16:50 +02:00
Federico Di Pierro 6f318ca1fe new(pkg/driverbuilder): support photonOS 5.0.
Moreover, support aarch64 drivers for it.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-10-13 15:16:50 +02:00
dependabot[bot] 9e804b8b0a chore(deps): bump golang.org/x/net from 0.14.0 to 0.17.0
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.14.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.14.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-12 08:05:46 +02:00
Federico Di Pierro fb7fb6445a fix(docker/builders): fixed libelf-dev and dwarves incompatibilities in debian backports.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-10-11 16:24:45 +02:00
Leonardo Grasso a0ecbe7c9e docs: add license headers and spdx id
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2023-10-11 11:29:44 +02:00
Federico Di Pierro 8599637bfe fix(pkg/driverbuilder): fixed flaky test.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-10-10 15:23:38 +02:00
Federico Di Pierro 9e7e4acfe1 chore(cmd,pkg): skip build attempt when no artifacts are supported.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-10-10 15:23:38 +02:00
Federico Di Pierro ed32894a64 chore: updated gitignore.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-20 16:11:44 +02:00
Federico Di Pierro deca8f94cf chore: properly enforce GOEXPERIMENT=loopvar to avoid stupid errors.
The flag will be part of go 1.22.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-20 16:11:44 +02:00
Federico Di Pierro 5a0bda9060 chore: do not enforce debug loglevel.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-05 14:31:57 +02:00
Federico Di Pierro 9f0ca29397 chore: fixed tests with new slog.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-05 14:31:57 +02:00
Federico Di Pierro ac56bc225a fix(validate): use String method for isloglevel.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-05 14:31:57 +02:00
Federico Di Pierro c4f5da6456 chore: bumped to go 1.21.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-05 14:31:57 +02:00
Federico Di Pierro 802c27462d chore(cmd,pkg,validate): drop logrus direct dependency.
Make use of golang 1.21 slog package.
Moreover, avoid enforcing a cobra.OnInitialize() function that would run even
when driverkit is invoked as a library.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-05 14:31:57 +02:00
Federico Di Pierro c00878ece6 chore: use `alpine:3.18` image.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-01 21:01:35 +02:00
Federico Di Pierro 4f6419543d chore(pkg/driverbuilder): properly negotiate correct docker client API version.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-01 21:01:35 +02:00
Federico Di Pierro 021baffb99 chore: bump setup_remote_docker version.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-01 21:01:35 +02:00
Federico Di Pierro f19f1327f0 fix(cmd): fixed test.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-01 21:01:35 +02:00
Federico Di Pierro 2e36f4aae9 chore: bump golang to 1.20.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-01 21:01:35 +02:00
Federico Di Pierro 8ffafe0ba5 chore: updated project deps.
Fixed build.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-01 21:01:35 +02:00
Federico Di Pierro 07523f1a2e chore(cmd): expose ToBuild method.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-09-01 15:49:34 +02:00
Federico Di Pierro 835307efe0 chore(pkg): expose GetResolvingURLs API.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-08-28 15:47:18 +02:00
Federico Di Pierro 20cd9553e3 cleanup(pkg): cleaned up URLs builder interface method removing config parameter.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-08-28 15:47:18 +02:00
Logan Bond 1fe1e7b129 add sed command to centos template for adding no-incompatible-pointer-types KCFLAG
Signed-off-by: Logan Bond <logantbond@gmail.com>
2023-07-19 19:32:38 +02:00
Aldo Lacuku 2602b28259 feat(imagelister): support private repositories for builder images
Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
2023-07-10 09:22:53 +02:00
Federico Di Pierro f8b4e5b089 fix(pkg): fixed ubuntu flaky test.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-07-07 15:18:41 +02:00
Federico Di Pierro c8c6bff9f4 cleanup(pkg,cmd): small images listers refactor.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-07-07 15:18:41 +02:00
Leonardo Grasso 6ea3db1a9d docs(README.md): add scope and status badges
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
2023-06-06 18:04:40 +02:00
Federico Di Pierro 0fadc3be66 fix(pkg): fixed mainline kernel URLs.
Moreover, properly enforce KBUILD_MODPOST_WARN in vanilla template.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-06-05 15:02:37 +02:00
Tom Müller 56be153a91 fixed typos and improved RHEL9 builder image explanation
Fixed typos and improved explanation

Signed-off-by: Tom Müller <60851960+toamto94@users.noreply.github.com>
2023-06-04 18:34:28 +02:00
Tom e187b3a3ba added additional redhat 9 builder image documentation
Signed-off-by: Tom Mueller <tom_mueller94@gmx.de>
2023-06-04 15:01:28 +02:00
Logan Bond 2debab8a8e adjust centos 4.18+ kernels to use gcc 9
Signed-off-by: Logan Bond <lbond@secureworks.com>
2023-05-25 18:46:11 +02:00
Federico Di Pierro 246e90f871 chore(pkg): added RepoImagesLister tests.
Dropped default values for Arch and Tag for FileImagesLister to be more coherent with RepoImagesLister.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-19 14:14:05 +02:00
Federico Di Pierro 80be7cda80 fix(pkg,ci): enabled back integration tests.
Plus, fixed an issue with ListImage from docker.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-19 14:14:05 +02:00
Federico Di Pierro 4e42618a1f chore(pkg): added tests from FileImagesLister.
Moreover, added multiple checks for FileImages yaml.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-18 15:58:03 +02:00
Federico Di Pierro 4d13594d2f chore(ci): remove integration tests from ci.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-18 15:58:03 +02:00
Federico Di Pierro d8a6ed733b fix(test): fixed tests.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-18 15:58:03 +02:00
Federico Di Pierro 2ebbadb676 chore(docs,cmd): updated default falcosecurity builderrepo; updated docs.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-18 15:58:03 +02:00
Federico Di Pierro 3c1af57d70 fix(Makefile): properly push images using new image name protocol.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-18 15:58:03 +02:00
Federico Di Pierro 7afc02d944 cleanup(cmd,docs,pkg): FileRepoLister should explicitly set all required fields.
This means that Arch and Tag too must be available.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-18 15:58:03 +02:00
Federico Di Pierro 8ee04d7a3a fix(pkg,makefile): added back default builder images tag value support.
It defaults to current commit hash; useful so that each driverkit tag can use builder images tagged with it.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-18 15:58:03 +02:00
Federico Di Pierro 2380025b7d fix(pkg): small fixes to new OCI tags support.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
2023-05-18 15:58:03 +02:00
Aldo Lacuku 6e5617817d update(pkg/images.go): select builder image based on tag info
GCC versions, architecture and flavor are set using the tag. Builder image
is selected by listing the tags and not using docker search anymore. Driverkit
does not need anymore access to the docker socket.

Co-authored-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Aldo Lacuku <aldo@lacuku.eu>
2023-05-18 15:58:03 +02:00
Federico Di Pierro 648bafb35d update(docs): updated autogenerated docs.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-16 09:18:25 +02:00
Federico Di Pierro be77d3a397 new(pkg): added talos builder.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-16 09:18:25 +02:00
Federico Di Pierro 829757e9fa new(pkg): support RC releases for vanilla target.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-05-12 16:18:43 +02:00
dependabot[bot] 584e423d51 chore(deps): bump github.com/docker/distribution
Bumps [github.com/docker/distribution](https://github.com/docker/distribution) from 2.8.1+incompatible to 2.8.2+incompatible.
- [Release notes](https://github.com/docker/distribution/releases)
- [Commits](https://github.com/docker/distribution/compare/v2.8.1...v2.8.2)

---
updated-dependencies:
- dependency-name: github.com/docker/distribution
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-12 12:27:45 +02:00
dependabot[bot] 454eff8fcc chore(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 20.10.14+incompatible to 20.10.24+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v20.10.14...v20.10.24)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-26 11:14:14 +02:00
Federico Di Pierro a3ede2fbeb new(pkg,docs): added al2023 support.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-04-14 15:07:07 +02:00
Logan Bond fb1e65f298 adjust gcc 12 selector to kernels 5.15+
Signed-off-by: Logan Bond <lbond@secureworks.com>

fixing some tests

Signed-off-by: Logan Bond <lbond@secureworks.com>
2023-04-06 20:00:57 +02:00
dependabot[bot] 9fc7aa4e74 chore(deps): bump github.com/opencontainers/runc from 1.1.2 to 1.1.5
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.2 to 1.1.5.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/v1.1.5/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.2...v1.1.5)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 09:17:39 +02:00
Logan Bond aef0925d54 allow uppercase chars in builder image name/tag and add mawk to build image
Signed-off-by: Logan Bond <lbond@secureworks.com>

remove debug

Signed-off-by: Logan Bond <lbond@secureworks.com>

remove unneeded fmt

Signed-off-by: Logan Bond <lbond@secureworks.com>

tabs

Signed-off-by: Logan Bond <lbond@secureworks.com>
2023-03-31 17:54:34 +02:00
Daniele De Lorenzi c092be2930 Removed docker example and note for ArchLinux
Signed-off-by: Daniele De Lorenzi <daniele.delorenzi@fastnetserv.net>
2023-03-28 12:14:37 +02:00
Daniele De Lorenzi 6c81c50341 make docs
Signed-off-by: Daniele De Lorenzi <daniele.delorenzi@fastnetserv.net>
2023-03-28 12:14:37 +02:00
Daniele De Lorenzi 36f6d1f3e3 Added Aliyun Linux, Almalinux and Rockylinux, sorted all example in alphabetical order
Signed-off-by: Daniele De Lorenzi <daniele.delorenzi@fastnetserv.net>
2023-03-28 12:14:37 +02:00
Daniele De Lorenzi dd28403650 Changed TargetType to match /etc/os-releases, single target for AliyunLinux 2 and 3
Signed-off-by: Daniele De Lorenzi <daniele.delorenzi@fastnetserv.net>
2023-03-28 12:14:37 +02:00
Lyonel Martinez be6a21b308 vote: Applying for Maintainer
Signed-off-by: Lyonel Martinez <lyonel.martinez@numberly.com>
2023-03-27 15:17:55 +02:00
Daniele De Lorenzi 5a40723a96 Fix CI issues
Signed-off-by: Daniele De Lorenzi <daniele.delorenzi@fastnetserv.net>
2023-03-26 17:25:24 +02:00
Daniele De Lorenzi 34c55a848e Alibaba Cloud Linux(AliyunLinux) 2 and 3 drivekit
Signed-off-by: Daniele De Lorenzi <daniele.delorenzi@fastnetserv.net>
2023-03-26 17:25:24 +02:00
Federico Di Pierro ee18ba2fda fix(pkg): fix gcc version from builder images setter.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-03-24 09:55:39 -05:00
Lyonel Martinez 197a3a9a3f feat(builder-indexes): yaml file for builderrepo
Signed-off-by: Lyonel Martinez <lyonel.martinez@numberly.com>
2023-03-24 15:43:18 +01:00
Lyonel Martinez f5ce9266d6 feat(builder-indexes): default value + target extraction + fail when no image found
Signed-off-by: Lyonel Martinez <lyonel.martinez@numberly.com>
2023-03-24 15:43:18 +01:00
Lyonel Martinez da978b4be5 feat(builder-indexes): fix loop over builder repos
Signed-off-by: Lyonel Martinez <lyonel.martinez@numberly.com>
2023-03-24 15:43:18 +01:00
Lyonel Martinez dd4c83e445 feat(builder-indexes): factorization
Signed-off-by: Lyonel Martinez <lyonel.martinez@numberly.com>
2023-03-24 15:43:18 +01:00
Lyonel Martinez f49ddfba38 feat(builder-indexes): apply reviews
Signed-off-by: Lyonel Martinez <lyonel.martinez@numberly.com>
2023-03-24 15:43:18 +01:00
Lyonel Martinez ac3a37dcb0 feat(builder-indexes): Update builderrepo flag to handle index file path
Signed-off-by: Lyonel Martinez <lyonel.martinez@numberly.com>
2023-03-24 15:43:18 +01:00
Logan Bond b91a018e44 add gcc-4.9 from new ubuntu source - debian source now produces 404s
Signed-off-by: Logan Bond <lbond@secureworks.com>

change target to "ol" to match /etc/os-release, update documentation with examples

Signed-off-by: Logan Bond <lbond@secureworks.com>

adding in UEKR7 and another URL path: appstream

Signed-off-by: Logan Bond <lbond@secureworks.com>
2023-03-24 09:30:59 -05:00
Logan Bond 8795345094 adding in initial oracle support
Signed-off-by: Logan Bond <logantbond@gmail.com>

remove uek from non-uek kernels

Signed-off-by: Logan Bond <logantbond@gmail.com>

add oracle 8 url

Signed-off-by: Logan Bond <logantbond@gmail.com>

make comments more explicit

Signed-off-by: Logan Bond <logantbond@gmail.com>

add an exception that needs handled for Oracle 8 versioning

Signed-off-by: Logan Bond <logantbond@gmail.com>

make comment more explicit

Signed-off-by: Logan Bond <logantbond@gmail.com>

add gawk to build image, seems useful

Signed-off-by: Logan Bond <lbond@secureworks.com>

uncomment gcc 4.9

Signed-off-by: Logan Bond <lbond@secureworks.com>
2023-03-24 09:30:59 -05:00
dependabot[bot] 53fb00701f chore(deps): bump golang.org/x/net
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.0.0-20220722155237-a158d28d115b to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/commits/v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-02 10:44:30 +01:00
dependabot[bot] d86016cdee chore(deps): bump golang.org/x/text from 0.3.7 to 0.3.8
Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-24 15:29:44 +01:00
Federico Di Pierro 52a89a02ce cleanup: removed `builderrepo` option pointing to my dockerhub.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-20 14:48:17 +01:00
Federico Di Pierro d6415dec5a fix(makefile): fixed images push: we don't need `docker manifest` anymore for builder images.
They are now platform dependent images (ie: we push them under different names for each arch),
because architecture is part of the new builder image name protocol.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-17 15:21:45 +01:00
Federico Di Pierro a3b171a372 update(docs): multiple improvements to docs.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 98581a3f6c chore: renamed `dockerrepo` to `builderrepo`.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>

Co-authored-by: David Windsor <dwindsor@secureworks.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro bedfa64889 fix(pkg): properly made `LoadImages()` aware of fixed gccversion set by user, if any.
In this way, we are able to support `--gccversion` properly.
Moreover, `images` cmd is now `--gccversion` aware.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 34b74c0912 chore(makefile): add `docker.io/fededp/driverkit` as builder images repo to integration tests.
This should allow us to test them.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 0f3cc06cf1 update(docs): add a note about image tags.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro e32462b41d fix(docker): correctly named gcc{8,6,5,4.8} image.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro a81145809f fix(docker): fixed small typo in builder-any-x86_64_gcc12.0.0_gcc11.0.0.Dockerfile.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 2f205c178a new(docker): added a centos gcc 4.8.5 docker image.
3.10.X centos kernels need this. Refs #236

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 1e3bcc291b docs: updated documentation for builder images.
Moreover, fixed a small `ln -s` bug in a builder dockerfile.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 479fd7a4be update(build): moved dockerfiles under docker subdir.
Moreover, builders will now be under docker/builders/.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 1a8ee642ca new(cmd): add a new `images` command to just list builder images.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 21a1430c26 cleanup(pkg/driverbuilder): only load images for needed target (or any) and needed arch.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro f93c7d31fc fix(cmd): fixed tests.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 4bbc30867f update(docs): run `make docs`.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 42adbd5957 fix(pkg): only propose GCCs from builder images that have either "any" target or requested one.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 85b54fab12 cleanup(pkg): small refactor.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro d0fd236d6d new(pkg,cmd): allow to pass list of descending priority docker repos.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 9bfac966f1 new(builder,makefile,pkg): ported images to new name template.
Ported makefile too.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
Federico Di Pierro 43caf7a75b new(pkg): initial implementation of dynamic builder images loading and indexing given a docker repo.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-02-16 18:24:41 +01:00
dependabot[bot] 6b8acdb1a5 chore(deps): bump github.com/containerd/containerd from 1.6.6 to 1.6.18
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.6 to 1.6.18.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.6.6...v1.6.18)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-16 15:45:40 +01:00
Austin Brogle 19f869623f feat: support amazonlinux2 5.15.x kernel
Signed-off-by: Austin Brogle <abrogle@snapchat.com>
2023-02-09 01:39:31 +01:00
Federico Di Pierro fa0af9d712 fix(pkg): minimum kver to build kmod for arm64 is 3.16.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2023-01-31 20:56:06 +01:00
Massimiliano Giovagnoli 9ccb920ffd fix(pkg/kernelrelease): allow plus char as sublevel and extra separator
Some distributions like Debian distributes release versions with the
plus character ('+') as separator between elements.

For example this change will match and will allow parsing of release versions
like '4.19+105+deb10u4~bpo9+1'.

Signed-off-by: Massimiliano Giovagnoli <me@maxgio.it>
2023-01-14 04:25:10 +01:00
John Gornowich b8f8a98115 fix(pkg/driverbuilder): rocky release urls
Break out the vault releases from the mainstream releases,
and append them all to the url list

Signed-off-by: John Gornowich <john.gornowich@progeny.net>
2023-01-14 04:23:11 +01:00
152 changed files with 6561 additions and 3620 deletions

View File

@ -1,235 +0,0 @@
version: 2.1
jobs:
"build-test":
docker:
- image: alpine:3.16
steps:
- checkout
- setup_remote_docker: # used by integration tests that runs driverkit binary that needs docker
version: 20.10.12
- run:
name: Install deps
command: apk add gcc musl-dev make bash git go
- run:
name: Build
command: make build
- run:
name: Test
command: make test
- run:
name: Integration tests
command: make integration_test
- run:
name: Prepare Artifacts
command: |
mkdir -p /tmp/build-amd64
cp _output/bin/driverkit /tmp/build-amd64/
- store_artifacts:
path: /tmp/build-amd64/driverkit
destination: driverkit_amd64
- persist_to_workspace:
root: /tmp
paths:
- build-amd64/
"build-test-arm64":
machine:
enabled: true
image: ubuntu-2004:2022.04.1
resource_class: arm.medium
steps:
- checkout:
path: /tmp/source
- run:
name: Prepare project
command: |
docker run --rm -it -v /tmp/source:/source -v /var/run/docker.sock:/var/run/docker.sock -w /source --name alpine_sh -d alpine:3.16 sh
docker exec alpine_sh apk add gcc musl-dev make bash git go docker
docker exec alpine_sh git config --global --add safe.directory /source
- run:
name: Build
command: docker exec alpine_sh make build
- run:
name: Test
command: docker exec alpine_sh make test
- run:
name: Integration tests
command: docker exec alpine_sh make integration_test
- run:
name: Prepare Artifacts
command: |
mkdir -p /tmp/build-arm64
cp /tmp/source/_output/bin/driverkit /tmp/build-arm64/
- store_artifacts:
path: /tmp/build-arm64/driverkit
destination: driverkit_arm64
- persist_to_workspace:
root: /tmp
paths:
- build-arm64/
"build-images":
docker:
- image: alpine:3.16
steps:
- attach_workspace:
at: /
- checkout
- setup_remote_docker:
version: 20.10.12
docker_layer_caching: true
- run:
name: Install deps
command: |
apk update
apk add make bash git docker docker-cli-buildx
- run:
name: Login to registry
command: echo ${DOCKERHUB_SECRET} | docker login -u ${DOCKERHUB_USER} --password-stdin
- run:
name: Prepare artifact for driverkit image
command: | # driverkit dockerfile expects the binary there
mkdir -p build-amd64
cp /build-amd64/driverkit build-amd64/
- run:
name: Build and Push docker images
command: GIT_BRANCH="$CIRCLE_BRANCH" GIT_TAG="$CIRCLE_TAG" make push/all
- run:
name: Push latest images
command: |
if [ -n "$CIRCLE_TAG" ]
then
GIT_BRANCH="$CIRCLE_BRANCH" GIT_TAG="$CIRCLE_TAG" make push/latest
else
echo "Skipping (no git tag)"
fi
"build-images-arm64":
machine:
enabled: true
image: ubuntu-2004:2022.04.1
docker_layer_caching: true
resource_class: arm.medium
steps:
- attach_workspace:
at: /tmp
- checkout:
path: /tmp/source
- run:
name: Install deps
command: |
sudo apt update
sudo apt install make bash git
- run:
name: Login to registry
command: echo ${DOCKERHUB_SECRET} | docker login -u ${DOCKERHUB_USER} --password-stdin
- run:
name: Prepare artifact for driverkit image
command: | # driverkit dockerfile expects the binary there
mkdir -p /tmp/source/build-arm64
cp /tmp/build-arm64/driverkit /tmp/source/build-arm64/
- run:
name: Build and Push docker images
command: |
cd /tmp/source
GIT_BRANCH="$CIRCLE_BRANCH" GIT_TAG="$CIRCLE_TAG" make push/all
- run:
name: Push latest images if needed
command: |
cd /tmp/source
if [ -n "$CIRCLE_TAG" ]
then
GIT_BRANCH="$CIRCLE_BRANCH" GIT_TAG="$CIRCLE_TAG" make push/latest
else
echo "Skipping (no git tag)"
fi
"images":
docker:
- image: cimg/base:stable
user: root
steps:
- checkout
- setup_remote_docker:
version: 20.10.12
- run:
name: Prepare env
command: |
echo ${DOCKERHUB_SECRET} | docker login -u ${DOCKERHUB_USER} --password-stdin
sudo apt update
sudo apt install make bash git
- run:
name: Build and Push manifest to registry
command: |
GIT_BRANCH="$CIRCLE_BRANCH" GIT_TAG="$CIRCLE_TAG" make manifest/all
- run:
name: Push latest manifest if needed
command: |
if [ -n "$CIRCLE_TAG" ]
then
GIT_BRANCH="$CIRCLE_BRANCH" GIT_TAG="$CIRCLE_TAG" make manifest/latest
else
echo "Skipping (no git tag)"
fi
"release":
docker:
- image: cimg/go:1.18
steps:
- checkout
- run:
name: Install goreleaser
command: |
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt update
sudo apt install goreleaser
- run:
name: Release
command: GIT_TAG="$CIRCLE_TAG" make release
workflows:
version: 2.1
build:
jobs:
- "build-test":
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
- "build-test-arm64":
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
- "build-images":
context: falco
filters:
branches:
only:
- master
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
requires:
- "build-test"
- "build-images-arm64":
context: falco
filters:
branches:
only:
- master
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
requires:
- "build-test-arm64"
- "images":
context: falco
filters:
branches:
only:
- master
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
requires:
- "build-images"
- "build-images-arm64"
- "release":
context: falco
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
requires:
- "images"

View File

@ -66,5 +66,5 @@ For example, `action required: change the API interface of the rule engine`.
-->
```release-note
NONE
```

12
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
groups:
actions:
update-types:
- "minor"
- "patch"

77
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,77 @@
name: CI Build
on:
pull_request:
branches: [master]
workflow_dispatch:
# Checks if any concurrent jobs under the same pull request or branch are being executed
# NOTE: this will cancel every workflow that is being ran against a PR as group is just the github ref (without the workflow name)
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-test-dev:
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/reusable_build_test_driverkit.yml
with:
arch: ${{ matrix.arch }}
paths-filter:
runs-on: ubuntu-latest
outputs:
docker_needs_build: ${{ steps.filter.outputs.docker }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
docker:
- 'docker/**'
build-images-dev:
needs: [build-test-dev,paths-filter]
if: needs.paths-filter.outputs.docker_needs_build == 'true'
strategy:
matrix:
arch: [ amd64, arm64 ]
uses: ./.github/workflows/reusable_build_push_images.yml
with:
arch: ${{ matrix.arch }}
push: false
secrets: inherit
gomodtidy:
name: Enforce go.mod tidiness
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: "${{ github.event.pull_request.head.sha }}"
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version-file: 'go.mod'
- name: Execute go mod tidy and check the outcome
working-directory: ./
run: |
go mod tidy
exit_code=$(git diff --exit-code)
exit ${exit_code}
- name: Print a comment in case of failure
run: |
echo "The go.mod and/or go.sum files appear not to be correctly tidied.
Please, rerun go mod tidy to fix the issues."
exit 1
if: |
failure() && github.event.pull_request.head.repo.full_name == github.repository

36
.github/workflows/master.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Master CI
on:
push:
branches: [master]
# Checks if any concurrent jobs is running for master CI and eventually cancel it
concurrency:
group: ci-master
cancel-in-progress: true
jobs:
build-test-master:
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/reusable_build_test_driverkit.yml
with:
arch: ${{ matrix.arch }}
push-images-master:
needs: build-test-master
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/reusable_build_push_images.yml
with:
arch: ${{ matrix.arch }}
push: true
secrets: inherit
images-master:
needs: push-images-master
uses: ./.github/workflows/reusable_manifest_images.yml
secrets: inherit

68
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,68 @@
name: Release
on:
push:
tags:
- v*
permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
jobs:
build-test-release:
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/reusable_build_test_driverkit.yml
with:
arch: ${{ matrix.arch }}
push-images-release:
needs: build-test-release
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/reusable_build_push_images.yml
with:
arch: ${{ matrix.arch }}
tag: ${{ github.ref_name }}
is_latest: true
push: true
secrets: inherit
images-release:
needs: push-images-release
uses: ./.github/workflows/reusable_manifest_images.yml
with:
tag: ${{ github.ref_name }}
is_latest: true
secrets: inherit
release:
needs: images-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Fetch
run: git fetch --prune --force --tags
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version-file: 'go.mod'
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
with:
install-only: true
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_TAG: ${{ github.ref_name }}
run: make release

View File

@ -0,0 +1,72 @@
# This is a reusable workflow used by master and release CI
on:
workflow_call:
inputs:
arch:
description: amd64 or arm64
required: true
type: string
branch:
description: name of the branch
required: false
type: string
default: 'master'
tag:
description: The tag to use (e.g. "master" or "0.35.0")
required: false
type: string
default: ''
is_latest:
description: Update the latest tag with the new image
required: false
type: boolean
default: false
push:
description: Whether to also push images
required: false
type: boolean
default: false
jobs:
build-images:
runs-on: ${{ (inputs.arch == 'arm64' && 'ubuntu-22.04-arm') || 'ubuntu-22.04' }}
env:
GIT_BRANCH: ${{ inputs.branch }}
GIT_TAG: ${{ inputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Create download folder
run: mkdir -p build-${{ inputs.arch }}
- name: Download Driverkit
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: driverkit-${{ inputs.arch }}
path: build-${{ inputs.arch }}
- name: Enforce executable bit
run: chmod +x build-${{ inputs.arch }}/driverkit
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to Docker Hub
if: inputs.push
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_SECRET }}
- name: Build and Push docker images
if: inputs.push
run: make push/all
- name: Build docker images
if: inputs.push == false
run: make image/all
- name: Push latest images if needed
if: inputs.push && inputs.is_latest
run: make push/latest

View File

@ -0,0 +1,47 @@
# This is a reusable workflow used by master and release CI
on:
workflow_call:
inputs:
arch:
description: amd64 or arm64
required: true
type: string
jobs:
build-test:
# See https://github.com/actions/runner/issues/409#issuecomment-1158849936
runs-on: ${{ (inputs.arch == 'arm64' && 'ubuntu-22.04-arm') || 'ubuntu-22.04' }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
with:
go-version-file: 'go.mod'
- name: Build
run: make build
- name: Test
run: make test
- name: Set integration tests DRIVERVERSIONS env
if: inputs.arch == 'amd64'
run: echo "DRIVERVERSIONS=master 6.0.1+driver 2.0.0+driver 17f5df52a7d9ed6bb12d3b1768460def8439936d" >> $GITHUB_ENV
- name: Set integration tests DRIVERVERSIONS env
if: inputs.arch == 'arm64'
run: echo "DRIVERVERSIONS=master 6.0.1+driver 2.0.0+driver" >> $GITHUB_ENV
- name: Integration tests
run: make integration_test
- name: Upload driverkit
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: driverkit-${{ inputs.arch }}
path: |
${{ github.workspace }}/_output/bin/driverkit

View File

@ -0,0 +1,45 @@
# This is a reusable workflow used by master and release CI
on:
workflow_call:
inputs:
branch:
description: name of the branch
required: false
type: string
default: 'master'
tag:
description: The tag to use (e.g. "master" or "0.35.0")
required: false
type: string
default: ''
is_latest:
description: Update the latest tag with the new image
required: false
type: boolean
default: false
jobs:
push-manifest:
runs-on: ubuntu-latest
env:
GIT_BRANCH: ${{ inputs.branch }}
GIT_TAG: ${{ inputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
- name: Login to Docker Hub
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_SECRET }}
- name: Build and Push manifest to registry
run: make manifest/all
- name: Push latest manifest if needed
if: inputs.is_latest
run: make manifest/latest

4
.gitignore vendored
View File

@ -1,7 +1,7 @@
_output/
dist/
vendor/
.idea/
driverkit
coverage.out
coverage.out

View File

@ -1,6 +1,10 @@
version: 2
project_name: driverkit
builds:
- id: "driverkit"
env:
- GOEXPERIMENT=loopvar
goos:
- linux
goarch:
@ -9,7 +13,6 @@ builds:
main: .
flags:
- -v
- -buildmode=pie
ldflags:
- "{{.Env.LDFLAGS}}"
binary: driverkit

View File

@ -1,81 +1,35 @@
# Example Configs
## ubuntu
Example configuration file to build both the Kernel module and eBPF probe for Ubuntu (works with any flavor!).
## aliyun linux 2 (Alibaba Cloud Linux 2)
```yaml
kernelrelease: 5.0.0-1021-aws-5.0
kernelversion: 24~18.04.1
target: ubuntu
kernelrelease: 4.19.91-26.al7.x86_64
target: alinux
output:
module: /tmp/falco-ubuntu-generic.ko
probe: /tmp/falco-ubuntu-generic.o
module: /tmp/falco_alinux_4.19.91-26.al7.x86_64.ko
probe: /tmp/falco_alinux_4.19.91-26.al7.x86_64.o
driverversion: master
```
## ubuntu-generic
Example configuration file to build both the Kernel module and eBPF probe for Ubuntu generic.
## aliyun linux 3 (Alibaba Cloud Linux 3)
```yaml
kernelrelease: 4.15.0-72-generic
kernelversion: 81
target: ubuntu-generic
kernelrelease: 5.10.84-10.4.al8.x86_64
target: alinux
output:
module: /tmp/falco-ubuntu-generic.ko
probe: /tmp/falco-ubuntu-generic.o
module: /tmp/falco_alinux_4.19.91-26.al7.x86_64.ko
probe: /tmp/falco_alinux_4.19.91-26.al7.x86_64.o
driverversion: master
```
> **NOTE:** ubuntu-generic exists to retain backward compatibility only,
> and should not be used in new configs.
## ubuntu-aws
Example configuration file to build both the Kernel module and eBPF probe for Ubuntu AWS.
## alma linux
```yaml
kernelrelease: 4.15.0-1057-aws
kernelversion: 59
target: ubuntu-aws
kernelrelease: 5.14.0-162.12.1.el9_1.x86_64
target: almalinux
output:
module: /tmp/falco-ubuntu-aws.ko
probe: /tmp/falco-ubuntu-aws.o
driverversion: master
```
> **NOTE:** ubuntu-aws exists to retain backward compatibility only,
> and should not be used in new configs.
## centos 6
```yaml
kernelrelease: 2.6.32-754.14.2.el6.x86_64
kernelversion: 1
target: centos
output:
module: /tmp/falco-centos6.ko
driverversion: master
```
## centos 7
```yaml
kernelrelease: 3.10.0-957.12.2.el7.x86_64
kernelversion: 1
target: centos
output:
module: /tmp/falco-centos7.ko
driverversion: master
```
## centos 8
```yaml
kernelrelease: 4.18.0-147.5.1.el8_1.x86_64
kernelversion: 1
target: centos
output:
module: /tmp/falco-centos8.ko
module: /tmp/falco_almalinux_5.14.0-162.12.1.el9_1.x86_64.ko
probe: /tmp/falco_almalinux_5.14.0-162.12.1.el9_1.x86_64.o
driverversion: master
```
@ -111,6 +65,58 @@ output:
driverversion: master
```
## archlinux
Example configuration file to build both the Kernel module and eBPF probe for Archlinux.
Note: archlinux target uses the [Arch Linux Archive](https://wiki.archlinux.org/title/Arch_Linux_Archive) to fetch
all ever supported kernel releases.
For arm64, it uses an user-provided mirror, as no official mirror is available: http://tardis.tiny-vps.com/aarm/.
The mirror has been up and updated since 2015.
```yaml
kernelversion: 1
kernelrelease: 6.0.6.arch1-1
target: arch
output:
module: /tmp/falco-arch.ko
probe: /tmp/falco-arch.o
driverversion: master
builderimage: ${ARCH_BUILD_IMAGE_HERE}
```
## centos 6
```yaml
kernelrelease: 2.6.32-754.14.2.el6.x86_64
kernelversion: 1
target: centos
output:
module: /tmp/falco-centos6.ko
driverversion: master
```
## centos 7
```yaml
kernelrelease: 3.10.0-957.12.2.el7.x86_64
kernelversion: 1
target: centos
output:
module: /tmp/falco-centos7.ko
driverversion: master
```
## centos 8
```yaml
kernelrelease: 4.18.0-147.5.1.el8_1.x86_64
kernelversion: 1
target: centos
output:
module: /tmp/falco-centos8.ko
driverversion: master
```
## debian
Example configuration file to build both the Kernel module and eBPF probe for Debian.
@ -125,6 +131,17 @@ target: debian
driverversion: master
```
## fedora
```yaml
kernelrelease: 5.19.16-200.fc36.x86_64
kernelversion: 1
target: fedora
output:
module: /tmp/falco-fedora.ko
driverversion: master
```
## flatcar
Example configuration file to build both the Kernel module and eBPF probe for Flatcar.
@ -154,38 +171,15 @@ output:
kernelconfigdata: Q09ORklHX0ZBTk9USUZZPXkKQ09ORklHX0t...
```
## archlinux
Example configuration file to build both the Kernel module and eBPF probe for Archlinux.
Note: archlinux target uses the [Arch Linux Archive](https://wiki.archlinux.org/title/Arch_Linux_Archive) to fetch
all ever supported kernel releases.
For arm64, it uses an user-provided mirror, as no official mirror is available: http://tardis.tiny-vps.com/aarm/.
The mirror has been up and updated since 2015.
NOTE: ArchLinux has updated to Linux Kernel 6.0+, which appears to enforce generation of BTF for kmod too. The typical Debian container builders in the repo currently do not work for building ArchLinux drivers as a result. While an agreement is being reached on how to handle this upstream, using a custom `--builderimage` with ArchLinux drivers works for now. For example:
```Dockerfile
# archlinux builder example
# Note: ArchLinux is a rolling release, the gcc versions and such will change over time
# pinned for now for gcc 11/12
FROM archlinux:base-20221030.0.98412
RUN pacman -Sy && pacman -Sy --noconfirm \
make \
pahole \
gcc11 \
gcc && \
ln -s /usr/bin/gcc /usr/bin/gcc-12
```
## oracle linux 8
```yaml
kernelrelease: 5.4.17-2011.3.2.1.el8uek.x86_64
kernelversion: 1
kernelrelease: 6.0.6.arch1-1
target: arch
target: ol
output:
module: /tmp/falco-arch.ko
probe: /tmp/falco-arch.o
module: /tmp/falco-ol8.ko
driverversion: master
builderimage: ${ARCH_BUILD_IMAGE_HERE}
```
## redhat 7
@ -275,9 +269,86 @@ and Dockerfile.rhel9:
FROM docker.io/redhat/ubi9
RUN yum install gcc elfutils-libelf-devel kmod make cpio llvm-toolset -y
RUN ln -s /usr/bin/$(uname -p)-redhat-linux-gcc-11 /usr/bin/gcc-11
```
| :exclamation: **subscription-manager does not work on RHEL9 containers**: Host must have a valid RHEL subscription |
|--------------------------------------------------------------------------------------------------------------------|
The `ln -s /usr/bin/$(uname -p)-redhat-linux-gcc-11 /usr/bin/gcc-11` command creates a symbolic link which makes sure driverkit finds the correct compiler binary.
| :exclamation: **subscription-manager does not work on RHEL9 containers**: Host must have a valid RHEL subscription. However, if you want to build the Docker image on a host that is not RHEL9, the container will not have access to the required repositories. In that case, the subscription manager can be enabled with some additional adjustments. |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
Dockerfile.rhel9.containerSkip:
```bash
FROM docker.io/redhat/ubi9
ENV SMDEV_CONTAINER_OFF 1
ARG REDHAT_USERNAME
ARG REDHAT_PASSWORD
RUN subscription-manager register --username $REDHAT_USERNAME --password $REDHAT_PASSWORD --auto-attach
RUN yum install gcc elfutils-libelf-devel kmod make cpio llvm-toolset -y
RUN ln -s /usr/bin/$(uname -p)-redhat-linux-gcc-11 /usr/bin/gcc-11
```
Setting `SMDEV_CONTAINER_OFF 1` makes sure the container detection is skipped and therefore enables the subscription manager again.
## rocky linux
```yaml
kernelrelease: 5.14.0-162.18.1.el9_1.x86_64
target: rocky
output:
module: /tmp/falco_almalinux_5.14.0-162.18.1.el9_1.x86_64.ko
probe: /tmp/falco_almalinux_5.14.0-162.18.1.el9_1.x86_64.o
driverversion: master
```
## ubuntu
Example configuration file to build both the Kernel module and eBPF probe for Ubuntu (works with any flavor!).
```yaml
kernelrelease: 5.0.0-1021-aws-5.0
kernelversion: 24~18.04.1
target: ubuntu
output:
module: /tmp/falco-ubuntu-generic.ko
probe: /tmp/falco-ubuntu-generic.o
driverversion: master
```
## ubuntu-aws
Example configuration file to build both the Kernel module and eBPF probe for Ubuntu AWS.
```yaml
kernelrelease: 4.15.0-1057-aws
kernelversion: 59
target: ubuntu-aws
output:
module: /tmp/falco-ubuntu-aws.ko
probe: /tmp/falco-ubuntu-aws.o
driverversion: master
```
> **NOTE:** ubuntu-aws exists to retain backward compatibility only,
> and should not be used in new configs.
## ubuntu-generic
Example configuration file to build both the Kernel module and eBPF probe for Ubuntu generic.
```yaml
kernelrelease: 4.15.0-72-generic
kernelversion: 81
target: ubuntu-generic
output:
module: /tmp/falco-ubuntu-generic.ko
probe: /tmp/falco-ubuntu-generic.o
driverversion: master
```
> **NOTE:** ubuntu-generic exists to retain backward compatibility only,
> and should not be used in new configs.
## vanilla

View File

@ -16,25 +16,24 @@ ifeq ($(COMMITS_FROM_GIT_TAG),0)
endif
endif
DRIVERVERSIONS ?= master
DOCKER_ORG ?= falcosecurity
BUILDERS := $(patsubst build/builder_%.Dockerfile,%,$(wildcard build/builder_*.Dockerfile))
ARCH := $(shell uname -m)
BUILDERS := $(patsubst docker/builders/builder-%.Dockerfile,%,$(wildcard docker/builders/builder*$(ARCH)*.Dockerfile))
IMAGE_NAME_BUILDER_BASE ?= docker.io/$(DOCKER_ORG)/driverkit-builder
IMAGE_NAME_SUFFIX_REF := ":$(GIT_REF)_$(shell uname -m)"
IMAGE_NAME_SUFFIX_COMMIT := ":$(GIT_COMMIT)_$(shell uname -m)"
IMAGE_NAME_SUFFIX_LATEST := ":latest_$(shell uname -m)"
IMAGE_NAME_DRIVERKIT ?= docker.io/$(DOCKER_ORG)/driverkit
IMAGE_NAME_DRIVERKIT_REF := $(IMAGE_NAME_DRIVERKIT):$(GIT_REF)_$(shell uname -m)
IMAGE_NAME_DRIVERKIT_COMMIT := $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT)_$(shell uname -m)
IMAGE_NAME_DRIVERKIT_LATEST := $(IMAGE_NAME_DRIVERKIT):latest_$(shell uname -m)
IMAGE_NAME_DRIVERKIT_REF := $(IMAGE_NAME_DRIVERKIT):$(GIT_REF)_$(ARCH)
IMAGE_NAME_DRIVERKIT_COMMIT := $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT)_$(ARCH)
IMAGE_NAME_DRIVERKIT_LATEST := $(IMAGE_NAME_DRIVERKIT):latest_$(ARCH)
LDFLAGS := -X github.com/falcosecurity/driverkit/pkg/version.buildTime=$(shell date +%s) -X github.com/falcosecurity/driverkit/pkg/version.gitCommit=${GIT_COMMIT} -X github.com/falcosecurity/driverkit/pkg/version.gitTag=$(if ${GIT_TAG},${GIT_TAG},v0.0.0) -X github.com/falcosecurity/driverkit/pkg/version.commitsFromGitTag=${COMMITS_FROM_GIT_TAG} -X github.com/falcosecurity/driverkit/pkg/driverbuilder/builder.BaseImage=${IMAGE_NAME_BUILDER_BASE}:$(GIT_COMMIT)
TARGET_TEST_ARCH ?= $(shell uname -m)
LDFLAGS := -X github.com/falcosecurity/driverkit/pkg/version.buildTime=$(shell date +%s) -X github.com/falcosecurity/driverkit/pkg/version.gitCommit=${GIT_COMMIT} -X github.com/falcosecurity/driverkit/pkg/version.gitTag=$(if ${GIT_TAG},${GIT_TAG},v0.0.0) -X github.com/falcosecurity/driverkit/pkg/version.commitsFromGitTag=${COMMITS_FROM_GIT_TAG} -X github.com/falcosecurity/driverkit/pkg/driverbuilder/builder.defaultImageTag=$(GIT_COMMIT)
TARGET_TEST_ARCH ?= $(ARCH)
test_configs := $(wildcard test/$(TARGET_TEST_ARCH)/configs/*.yaml)
driverkit ?= _output/bin/driverkit
@ -44,7 +43,7 @@ driverkit_docgen ?= _output/bin/docgen
build: clean ${driverkit}
${driverkit}:
CGO_ENABLED=0 go build -v -buildmode=pie -ldflags '${LDFLAGS}' -o $@ .
CGO_ENABLED=0 GOEXPERIMENT=loopvar go build -v -ldflags '${LDFLAGS}' -o $@ .
.PHONY: release
release: clean
@ -60,71 +59,57 @@ image/all: image/builder image/driverkit
.PHONY: image/builder
image/builder:
$(foreach b,$(BUILDERS),\
$(DOCKER) buildx build -o type=image,push="false" -f build/builder_$b.Dockerfile . ; \
$(DOCKER) buildx build -o type=image,push="false" -f docker/builders/builder-$b.Dockerfile . ; \
)
.PHONY: image/driverkit
image/driverkit:
$(DOCKER) buildx build -o type=image,push="false" -f build/driverkit.Dockerfile .
$(DOCKER) buildx build -o type=image,push="false" -f docker/driverkit.Dockerfile .
push/all: push/builder push/driverkit
.PHONY: push/builder
push/builder:
$(foreach b,$(BUILDERS),\
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_BUILDER_BASE)_$b$(IMAGE_NAME_SUFFIX_REF)" -t "$(IMAGE_NAME_BUILDER_BASE)_$b$(IMAGE_NAME_SUFFIX_COMMIT)" -f build/builder_$b.Dockerfile . ; \
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_BUILDER_BASE):$b-$(GIT_REF)" -t "$(IMAGE_NAME_BUILDER_BASE):$b-$(GIT_COMMIT)" -f docker/builders/builder-$b.Dockerfile . ; \
)
.PHONY: push/driverkit
push/driverkit:
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_DRIVERKIT_REF)" -t "$(IMAGE_NAME_DRIVERKIT_COMMIT)" -f build/driverkit.Dockerfile .
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_DRIVERKIT_REF)" -t "$(IMAGE_NAME_DRIVERKIT_COMMIT)" -f docker/driverkit.Dockerfile .
.PHONY: push/latest
push/latest:
$(foreach b,$(BUILDERS),\
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_BUILDER_BASE)_$b$(IMAGE_NAME_SUFFIX_LATEST)" -f build/builder_$b.Dockerfile . ; \
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_BUILDER_BASE):$b-latest" -f docker/builders/builder-$b.Dockerfile . ; \
)
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_DRIVERKIT_LATEST)" -f build/driverkit.Dockerfile .
$(DOCKER) buildx build --push -t "$(IMAGE_NAME_DRIVERKIT_LATEST)" -f docker/driverkit.Dockerfile .
manifest/all: manifest/builder manifest/driverkit
.PHONY: manifest/builder
manifest/builder:
$(foreach b,$(BUILDERS),\
$(DOCKER) manifest create "$(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_REF)" $(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_REF)_x86_64 $(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_REF)_aarch64 ; \
$(DOCKER) manifest push "$(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_REF)" ; \
$(DOCKER) manifest create $(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_COMMIT) $(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_COMMIT)_x86_64 $(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_COMMIT)_aarch64 ; \
$(DOCKER) manifest push $(IMAGE_NAME_BUILDER_BASE)_$b:$(GIT_COMMIT) ; \
)
manifest/all: manifest/driverkit
.PHONY: manifest/driverkit
manifest/driverkit:
$(DOCKER) manifest create $(IMAGE_NAME_DRIVERKIT):$(GIT_REF) $(IMAGE_NAME_DRIVERKIT):$(GIT_REF)_x86_64 $(IMAGE_NAME_DRIVERKIT):$(GIT_REF)_aarch64
$(DOCKER) manifest push $(IMAGE_NAME_DRIVERKIT):$(GIT_REF)
$(DOCKER) manifest create $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT) $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT)_x86_64 $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT)_aarch64
$(DOCKER) manifest push $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT)
$(DOCKER) buildx imagetools create -t $(IMAGE_NAME_DRIVERKIT):$(GIT_REF) $(IMAGE_NAME_DRIVERKIT):$(GIT_REF)_x86_64 $(IMAGE_NAME_DRIVERKIT):$(GIT_REF)_aarch64
$(DOCKER) buildx imagetools create -t $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT) $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT)_x86_64 $(IMAGE_NAME_DRIVERKIT):$(GIT_COMMIT)_aarch64
.PHONY: manifest/latest
manifest/latest:
$(foreach b,$(BUILDERS),\
$(DOCKER) manifest create "$(IMAGE_NAME_BUILDER_BASE)_$b:latest" $(IMAGE_NAME_BUILDER_BASE)_$b:latest_x86_64 $(IMAGE_NAME_BUILDER_BASE)_$b:latest_aarch64 ; \
$(DOCKER) manifest push "$(IMAGE_NAME_BUILDER_BASE)_$b:latest" ; \
)
$(DOCKER) manifest create $(IMAGE_NAME_DRIVERKIT):latest $(IMAGE_NAME_DRIVERKIT):latest_x86_64 $(IMAGE_NAME_DRIVERKIT):latest_aarch64
$(DOCKER) manifest push $(IMAGE_NAME_DRIVERKIT):latest
$(DOCKER) buildx imagetools create -t $(IMAGE_NAME_DRIVERKIT):latest $(IMAGE_NAME_DRIVERKIT):latest_x86_64 $(IMAGE_NAME_DRIVERKIT):latest_aarch64
.PHONY: test
test:
go clean -testcache
go test -v -cover -race ./...
go test -v -cover -buildmode=pie ./cmd
GOEXPERIMENT=loopvar go test -v -cover -race ./...
GOEXPERIMENT=loopvar go test -v -cover ./cmd
.PHONY: integration_test
integration_test: $(test_configs)
.PHONY: $(test_configs)
$(test_configs): ${driverkit}
${driverkit} docker -c $@ --builderimage auto:master -l debug --timeout 600
$(foreach d,$(DRIVERVERSIONS),\
${driverkit} docker -c $@ --builderimage auto:master -l debug --timeout 600 --driverversion $d; \
)
.PHONY: ${driverkit_docgen}
${driverkit_docgen}: ${PWD}/docgen

3
OWNERS
View File

@ -3,5 +3,8 @@ approvers:
- dwindsor
- fededp
- EXONER4TED
- lowaiz
- LucaGuerra
emeritus_approvers:
- fntlnz

View File

@ -1,5 +1,7 @@
# driverkit
[![Falco Ecosystem Repository](https://github.com/falcosecurity/evolution/blob/main/repos/badges/falco-ecosystem-blue.svg)](https://github.com/falcosecurity/evolution/blob/main/REPOSITORIES.md#ecosystem-scope) [![Incubating](https://img.shields.io/badge/status-incubating-orange?style=for-the-badge)](https://github.com/falcosecurity/evolution/blob/main/REPOSITORIES.md#incubating)
[![Latest](https://img.shields.io/github/v/release/falcosecurity/driverkit?style=for-the-badge)](https://github.com/falcosecurity/driverkit/releases/latest)
![Architectures](https://img.shields.io/badge/ARCHS-x86__64%7Caarch64-blueviolet?style=for-the-badge)
[![Go Report Card](https://goreportcard.com/badge/github.com/falcosecurity/driverkit?style=for-the-badge)](https://goreportcard.com/report/github.com/falcosecurity/driverkit)

View File

@ -1,6 +1,6 @@
# Release Process
Our release process is based upon [CircleCI](https://app.circleci.com/pipelines/github/falcosecurity/driverkit) and [goreleaser](https://github.com/goreleaser/goreleaser) tool for artifacts.
Our release process is fully automated using [Github actions](.github/workflows/release.yml) and [goreleaser](https://github.com/goreleaser/goreleaser) tool for artifacts.
When we release we do the following process:

View File

@ -1,13 +1,24 @@
//go:build !race
// +build !race
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"bytes"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"io/ioutil"
"os"
"path/filepath"
"runtime"
@ -16,6 +27,9 @@ import (
"testing"
"text/template"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"github.com/acarl005/stripansi"
"gotest.tools/assert"
)
@ -116,6 +130,8 @@ var tests = []testCase{
"ubuntu-aws",
"--output-module",
"/tmp/falco-ubuntu-aws.ko",
"--output-probe",
"/tmp/falco-ubuntu-aws.o",
"--loglevel",
"debug",
},
@ -128,6 +144,7 @@ var tests = []testCase{
env: map[string]string{
"DRIVERKIT_KERNELVERSION": "59",
"DRIVERKIT_OUTPUT_MODULE": "/tmp/falco-ubuntu-aws.ko",
"DRIVERKIT_OUTPUT_PROBE": "/tmp/falco-ubuntu-aws.o",
},
args: []string{
"docker",
@ -299,9 +316,14 @@ var tests = []testCase{
func run(t *testing.T, test testCase) {
// Setup
c := NewRootCmd()
b := bytes.NewBufferString("")
c.SetOutput(b)
configOpts, err := NewConfigOptions()
assert.NilError(t, err)
rootOpts, err := NewRootOptions()
assert.NilError(t, err)
var buf bytes.Buffer
configOpts.setOutput(&buf, true)
c := NewRootCmd(configOpts, rootOpts)
c.SetOutput(&buf)
if len(test.args) == 0 || (test.args[0] != "__complete" && test.args[0] != "__completeNoDesc" && test.args[0] != "help" && test.args[0] != "completion") {
test.args = append(test.args, "--dryrun")
}
@ -312,19 +334,18 @@ func run(t *testing.T, test testCase) {
}
}
// Test
err := c.Execute()
err = c.Execute()
if err != nil {
if test.expect.err == "" {
t.Fatalf("error executing CLI: %v", err)
} else {
assert.Error(t, err, test.expect.err)
}
// Exactly same behavior as rootCmd.Start(), but here we use ERROR instead of FATAL to avoid leaving
configOpts.Printer.Logger.Error("error executing driverkit", configOpts.Printer.Logger.Args("err", err.Error()))
}
out, err := ioutil.ReadAll(b)
if err != nil {
t.Fatalf("error reading CLI output: %v", err)
}
res := stripansi.Strip(string(out))
out := buf.String()
res := stripansi.Strip(out)
assert.Equal(t, test.expect.out, res)
// Teardown
for k := range test.env {
@ -349,7 +370,7 @@ type testTemplateData struct {
}
func readTemplateFile(t *testing.T, s string) string {
out, err := ioutil.ReadFile("testdata/templates/" + s)
out, err := os.ReadFile("testdata/templates/" + s)
assert.NilError(t, err)
return string(out)
}
@ -378,7 +399,7 @@ type flagsTemplateData struct {
}
func initFlagsTemplateData(args []string) flagsTemplateData {
targets := builder.BuilderByTarget.Targets()
targets := builder.Targets()
sort.Strings(targets)
cmd := "driverkit"
@ -419,7 +440,7 @@ func TestCLI(t *testing.T) {
test.descr = strings.TrimSuffix(filepath.Base(test.expect.out), ".txt")
}
if test.expect.out != "" {
out, err := ioutil.ReadFile(test.expect.out)
out, err := os.ReadFile(test.expect.out)
if err != nil {
t.Fatalf("output fixture not found: %v", err)
}

View File

@ -1,8 +1,23 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"bytes"
"fmt"
"github.com/spf13/pflag"
"os"
"strings"
"text/template"
@ -32,12 +47,12 @@ func validateArgs() cobra.PositionalArgs {
if len(args) == 0 {
return nil
}
return cobra.ExactValidArgs(1)(c, args)
return cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs)(c, args)
}
}
// NewCompletionCmd ...
func NewCompletionCmd() *cobra.Command {
func NewCompletionCmd(_ *ConfigOptions, _ *RootOptions, _ *pflag.FlagSet) *cobra.Command {
var long bytes.Buffer
tmpl := template.Must(template.New("long").Parse(longUsageTemplate))
tmpl.Execute(&long, map[string]interface{}{
@ -51,25 +66,23 @@ func NewCompletionCmd() *cobra.Command {
Args: validateArgs(),
ValidArgs: cmdArgs,
DisableAutoGenTag: true,
Run: func(c *cobra.Command, args []string) {
RunE: func(c *cobra.Command, args []string) error {
if len(args) == 0 {
c.Help()
return
return c.Help()
}
arg := args[0]
switch arg {
case "bash":
c.Root().GenBashCompletion(os.Stdout)
break
return c.Root().GenBashCompletion(os.Stdout)
case "zsh":
c.Root().GenZshCompletion(os.Stdout)
break
return c.Root().GenZshCompletion(os.Stdout)
case "fish":
c.Root().GenFishCompletion(os.Stdout, true)
return c.Root().GenFishCompletion(os.Stdout, true)
case "help":
c.Help()
return c.Help()
}
return nil
},
}

View File

@ -1,49 +1,155 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"errors"
"github.com/falcosecurity/falcoctl/pkg/output"
"github.com/mitchellh/go-homedir"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"io"
"os"
"strings"
"github.com/creasty/defaults"
"github.com/falcosecurity/driverkit/validate"
"github.com/go-playground/validator/v10"
logger "github.com/sirupsen/logrus"
"github.com/pterm/pterm"
)
var validProcessors = []string{"docker", "kubernetes", "kubernetes-in-cluster"}
var validProcessors = []string{"docker", "kubernetes", "kubernetes-in-cluster", "local"}
var aliasProcessors = []string{"docker", "k8s", "k8s-ic"}
var configOptions *ConfigOptions
// ConfigOptions represent the persistent configuration flags of driverkit.
type ConfigOptions struct {
ConfigFile string
LogLevel string `validate:"logrus" name:"log level" default:"info"`
configFile string
Timeout int `validate:"number,min=30" default:"120" name:"timeout"`
ProxyURL string `validate:"omitempty,proxy" name:"proxy url"`
DryRun bool
dryRun bool
configErrors bool
// Printer used by all commands to output messages.
Printer *output.Printer
// writer is used to write the output of the printer.
writer io.Writer
logLevel *output.LogLevel
disableStyling bool
}
func (co *ConfigOptions) initPrinter() {
// DisableStyling is only enforced by tests.
if co.disableStyling {
pterm.DisableStyling()
}
co.Printer = output.NewPrinter(co.logLevel.ToPtermLogLevel(), pterm.LogFormatterColorful, co.writer)
if co.disableStyling {
// Disable time print for tests
co.Printer.Logger = co.Printer.Logger.WithTime(false)
}
}
// Called by tests to disable styling and set bytes buffer as output
func (co *ConfigOptions) setOutput(writer io.Writer, disableStyling bool) {
co.writer = writer
co.disableStyling = disableStyling
co.initPrinter()
}
// NewConfigOptions creates an instance of ConfigOptions.
func NewConfigOptions() *ConfigOptions {
o := &ConfigOptions{}
if err := defaults.Set(o); err != nil {
logger.WithError(err).WithField("options", "ConfigOptions").Fatal("error setting driverkit options defaults")
func NewConfigOptions() (*ConfigOptions, error) {
o := &ConfigOptions{
writer: os.Stdout,
logLevel: output.NewLogLevel(),
disableStyling: false,
}
return o
o.initPrinter()
if err := defaults.Set(o); err != nil {
// Return ConfigOptions anyway because we need the logger
return o, err
}
return o, nil
}
// Validate validates the ConfigOptions fields.
func (co *ConfigOptions) Validate() []error {
func (co *ConfigOptions) validate() []error {
if err := validate.V.Struct(co); err != nil {
errors := err.(validator.ValidationErrors)
errArr := []error{}
for _, e := range errors {
var errs validator.ValidationErrors
errors.As(err, &errs)
var errArr []error
for _, e := range errs {
// Translate each error one at a time
errArr = append(errArr, fmt.Errorf(e.Translate(validate.T)))
errArr = append(errArr, errors.New(e.Translate(validate.T)))
}
co.configErrors = true
return errArr
}
return nil
}
// AddFlags registers the common flags.
func (co *ConfigOptions) AddFlags(flags *pflag.FlagSet) {
flags.StringVarP(&co.configFile, "config", "c", co.configFile, "config file path (default $HOME/.driverkit.yaml if exists)")
flags.VarP(co.logLevel, "loglevel", "l", "set level for logs "+co.logLevel.Allowed())
flags.IntVar(&co.Timeout, "timeout", co.Timeout, "timeout in seconds")
flags.StringVar(&co.ProxyURL, "proxy", co.ProxyURL, "the proxy to use to download data")
flags.BoolVar(&co.dryRun, "dryrun", co.dryRun, "do not actually perform the action")
}
// Init reads in config file and ENV variables if set.
func (co *ConfigOptions) Init() bool {
configErr := false
if errs := co.validate(); errs != nil {
for _, err := range errs {
co.Printer.Logger.Error("error validating config options",
co.Printer.Logger.Args("err", err.Error()))
}
configErr = true
}
if co.configFile != "" {
viper.SetConfigFile(co.configFile)
} else {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
co.Printer.Logger.Error("error getting the home directory",
co.Printer.Logger.Args("err", err.Error()))
// not setting configErr = true because we fallback to `$HOME/.driverkit.yaml` and try with it
}
viper.AddConfigPath(home)
viper.SetConfigName(".driverkit")
}
viper.AutomaticEnv()
viper.SetEnvPrefix("driverkit")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
// If a config file is found, read it in.
err := viper.ReadInConfig()
// Init printer with either read or existent one,
// so that we can further log considering log level set.
co.initPrinter()
if err == nil {
co.Printer.Logger.Info("using config file",
co.Printer.Logger.Args("file", viper.ConfigFileUsed()))
} else {
var configFileNotFoundError viper.ConfigFileNotFoundError
if errors.As(err, &configFileNotFoundError) {
// Config file not found, ignore ...
co.Printer.Logger.Debug("running without a configuration file")
}
}
return configErr
}

View File

@ -1,25 +1,56 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"bytes"
"github.com/falcosecurity/driverkit/pkg/driverbuilder"
logger "github.com/sirupsen/logrus"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
// NewDockerCmd creates the `driverkit docker` command.
func NewDockerCmd(rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
func NewDockerCmd(configOpts *ConfigOptions, rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
dockerCmd := &cobra.Command{
Use: "docker",
Short: "Build Falco kernel modules and eBPF probes against a docker daemon.",
Run: func(c *cobra.Command, args []string) {
logger.WithField("processor", c.Name()).Info("driver building, it will take a few seconds")
if !configOptions.DryRun {
if err := driverbuilder.NewDockerBuildProcessor(viper.GetInt("timeout"), viper.GetString("proxy")).Start(rootOpts.toBuild()); err != nil {
logger.WithError(err).Fatal("exiting")
RunE: func(c *cobra.Command, args []string) error {
configOpts.Printer.Logger.Info("starting build",
configOpts.Printer.Logger.Args("processor", c.Name()))
if !configOpts.dryRun {
if !rootOpts.Output.HasOutputs() {
configOpts.Printer.Logger.Info("no output specified")
return nil
}
// Since we use a spinner, cache log data to a bytesbuffer;
// we will later print it once we stop the spinner.
var b *builder.Build
if configOpts.disableStyling {
b = rootOpts.ToBuild(configOpts.Printer)
} else {
var buf bytes.Buffer
b = rootOpts.ToBuild(configOpts.Printer.WithWriter(&buf))
configOpts.Printer.Spinner, _ = configOpts.Printer.Spinner.Start("driver building, it will take a few seconds")
defer func() {
configOpts.Printer.DefaultText.Print(buf.String())
}()
}
return driverbuilder.NewDockerBuildProcessor(configOpts.Timeout, configOpts.ProxyURL).Start(b)
}
return nil
},
}
// Add root flags

74
cmd/images.go Normal file
View File

@ -0,0 +1,74 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"bytes"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"os"
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
// NewImagesCmd creates the `driverkit images` command.
func NewImagesCmd(configOpts *ConfigOptions, rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
imagesCmd := &cobra.Command{
Use: "images",
Short: "List builder images",
RunE: func(c *cobra.Command, args []string) error {
configOpts.Printer.Logger.Info("starting loading images",
configOpts.Printer.Logger.Args("processor", c.Name()))
// Since we use a spinner, cache log data to a bytesbuffer;
// we will later print it once we stop the spinner.
var (
buf bytes.Buffer
b *builder.Build
)
if configOpts.disableStyling {
b = rootOpts.ToBuild(configOpts.Printer)
} else {
b = rootOpts.ToBuild(configOpts.Printer.WithWriter(&buf))
configOpts.Printer.Spinner, _ = configOpts.Printer.Spinner.Start("listing images, it will take a few seconds")
}
b.LoadImages()
if !configOpts.disableStyling {
_ = configOpts.Printer.Spinner.Stop()
configOpts.Printer.DefaultText.Print(buf.String())
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Image", "Target", "Arch", "GCC"})
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
for _, img := range b.Images {
data := make([]string, 4)
data[0] = img.Name
data[1] = img.Target.String()
data[2] = b.Architecture
data[3] = img.GCCVersion.String()
table.Append(data)
}
table.Render() // Send output
return nil
},
}
// Add root flags
imagesCmd.PersistentFlags().AddFlagSet(rootFlags)
return imagesCmd
}

View File

@ -1,20 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"bytes"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"regexp"
"strings"
"github.com/falcosecurity/driverkit/pkg/driverbuilder"
"github.com/falcosecurity/driverkit/pkg/kubernetes/factory"
logger "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"k8s.io/cli-runtime/pkg/genericclioptions"
)
// NewKubernetesCmd creates the `driverkit kubernetes` command.
func NewKubernetesCmd(rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
func NewKubernetesCmd(configOpts *ConfigOptions, rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
kubernetesCmd := &cobra.Command{
Use: "kubernetes",
Short: "Build Falco kernel modules and eBPF probes against a Kubernetes cluster.",
@ -43,30 +57,39 @@ func NewKubernetesCmd(rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Co
kubefactory := factory.NewFactory(configFlags)
kubernetesCmd.Run = func(cmd *cobra.Command, args []string) {
logger.WithField("processor", cmd.Name()).Info("driver building, it will take a few seconds")
if !configOptions.DryRun {
if err := kubernetesRun(cmd, args, kubefactory, rootOpts); err != nil {
logger.WithError(err).Fatal("exiting")
kubernetesCmd.RunE = func(c *cobra.Command, args []string) error {
configOpts.Printer.Logger.Info("starting build",
configOpts.Printer.Logger.Args("processor", c.Name()))
if !configOpts.dryRun {
if !rootOpts.Output.HasOutputs() {
configOpts.Printer.Logger.Info("no output specified")
return nil
}
// Since we use a spinner, cache log data to a bytesbuffer;
// we will later print it once we stop the spinner.
var b *builder.Build
if configOpts.disableStyling {
b = rootOpts.ToBuild(configOpts.Printer)
} else {
var buf bytes.Buffer
b = rootOpts.ToBuild(configOpts.Printer.WithWriter(&buf))
configOpts.Printer.Spinner, _ = configOpts.Printer.Spinner.Start("driver building, it will take a few seconds")
defer func() {
configOpts.Printer.DefaultText.Print(buf.String())
}()
}
return kubernetesRun(kubefactory, b, configOpts)
}
return nil
}
return kubernetesCmd
}
func kubernetesRun(cmd *cobra.Command, args []string, kubefactory factory.Factory, rootOpts *RootOptions) error {
f := cmd.Flags()
b := rootOpts.toBuild()
namespaceStr, err := f.GetString("namespace")
if err != nil {
return err
}
if len(namespaceStr) == 0 {
namespaceStr = "default"
}
func kubernetesRun(kubefactory factory.Factory,
b *builder.Build,
configOpts *ConfigOptions,
) error {
kc, err := kubefactory.KubernetesClientSet()
if err != nil {
return err
@ -79,6 +102,12 @@ func kubernetesRun(cmd *cobra.Command, args []string, kubefactory factory.Factor
return err
}
buildProcessor := driverbuilder.NewKubernetesBuildProcessor(kc.CoreV1(), clientConfig, kubernetesOptions.RunAsUser, kubernetesOptions.Namespace, kubernetesOptions.ImagePullSecret, viper.GetInt("timeout"), viper.GetString("proxy"))
buildProcessor := driverbuilder.NewKubernetesBuildProcessor(kc.CoreV1(),
clientConfig,
kubernetesOptions.RunAsUser,
kubernetesOptions.Namespace,
kubernetesOptions.ImagePullSecret,
configOpts.Timeout,
configOpts.ProxyURL)
return buildProcessor.Start(b)
}

View File

@ -1,18 +1,32 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"bytes"
"github.com/falcosecurity/driverkit/pkg/driverbuilder"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"github.com/falcosecurity/driverkit/pkg/kubernetes/factory"
logger "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
)
// NewKubernetesInClusterCmd creates the `driverkit kubernetes` command.
func NewKubernetesInClusterCmd(rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
func NewKubernetesInClusterCmd(configOpts *ConfigOptions, rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
kubernetesInClusterCmd := &cobra.Command{
Use: "kubernetes-in-cluster",
Short: "Build Falco kernel modules and eBPF probes against a Kubernetes cluster inside a Kubernetes cluster.",
@ -26,34 +40,55 @@ func NewKubernetesInClusterCmd(rootOpts *RootOptions, rootFlags *pflag.FlagSet)
// Add root flags
kubernetesInClusterCmd.PersistentFlags().AddFlagSet(rootFlags)
kubernetesInClusterCmd.Run = func(cmd *cobra.Command, args []string) {
logger.WithField("processor", cmd.Name()).Info("driver building, it will take a few seconds")
if !configOptions.DryRun {
config, err := rest.InClusterConfig()
if err != nil {
logger.WithError(err).Fatal("exiting")
kubernetesInClusterCmd.RunE = func(c *cobra.Command, args []string) error {
configOpts.Printer.Logger.Info("starting build",
configOpts.Printer.Logger.Args("processor", c.Name()))
if !configOpts.dryRun {
if !rootOpts.Output.HasOutputs() {
configOpts.Printer.Logger.Info("no output specified")
return nil
}
if err = factory.SetKubernetesDefaults(config); err != nil {
logger.WithError(err).Fatal("exiting")
}
if err = kubernetesInClusterRun(cmd, args, config, rootOpts); err != nil {
logger.WithError(err).Fatal("exiting")
// Since we use a spinner, cache log data to a bytesbuffer;
// we will later print it once we stop the spinner.
var b *builder.Build
if configOpts.disableStyling {
b = rootOpts.ToBuild(configOpts.Printer)
} else {
var buf bytes.Buffer
b = rootOpts.ToBuild(configOpts.Printer.WithWriter(&buf))
configOpts.Printer.Spinner, _ = configOpts.Printer.Spinner.Start("driver building, it will take a few seconds")
defer func() {
configOpts.Printer.DefaultText.Print(buf.String())
}()
}
return kubernetesInClusterRun(b, configOpts)
}
return nil
}
return kubernetesInClusterCmd
}
func kubernetesInClusterRun(_ *cobra.Command, _ []string, kubeConfig *rest.Config, rootOpts *RootOptions) error {
b := rootOpts.toBuild()
func kubernetesInClusterRun(b *builder.Build, configOpts *ConfigOptions) error {
kubeConfig, err := rest.InClusterConfig()
if err != nil {
return err
}
if err = factory.SetKubernetesDefaults(kubeConfig); err != nil {
return err
}
kc, err := kubernetes.NewForConfig(kubeConfig)
if err != nil {
return err
}
buildProcessor := driverbuilder.NewKubernetesBuildProcessor(kc.CoreV1(), kubeConfig, kubernetesOptions.RunAsUser, kubernetesOptions.Namespace, kubernetesOptions.ImagePullSecret, viper.GetInt("timeout"), viper.GetString("proxy"))
buildProcessor := driverbuilder.NewKubernetesBuildProcessor(kc.CoreV1(),
kubeConfig,
kubernetesOptions.RunAsUser,
kubernetesOptions.Namespace,
kubernetesOptions.ImagePullSecret,
configOpts.Timeout,
configOpts.ProxyURL)
return buildProcessor.Start(b)
}

View File

@ -1,3 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import flag "github.com/spf13/pflag"

81
cmd/local.go Normal file
View File

@ -0,0 +1,81 @@
package cmd
import (
"bytes"
"github.com/falcosecurity/driverkit/pkg/driverbuilder"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
type localCmdOptions struct {
useDKMS bool
downloadHeaders bool
srcDir string
envMap map[string]string
}
// NewLocalCmd creates the `driverkit local` command.
func NewLocalCmd(configOpts *ConfigOptions, rootOpts *RootOptions, rootFlags *pflag.FlagSet) *cobra.Command {
opts := localCmdOptions{}
localCmd := &cobra.Command{
Use: "local",
Short: "Build Falco kernel modules and eBPF probes in local env with local kernel sources and gcc/clang.",
RunE: func(c *cobra.Command, args []string) error {
configOpts.Printer.Logger.Info("starting build",
configOpts.Printer.Logger.Args("processor", c.Name()))
if !configOpts.dryRun {
if !rootOpts.Output.HasOutputs() {
configOpts.Printer.Logger.Info("no output specified")
return nil
}
// Since we use a spinner, cache log data to a bytesbuffer;
// we will later print it once we stop the spinner.
var b *builder.Build
if configOpts.disableStyling {
b = rootOpts.ToBuild(configOpts.Printer)
} else {
var buf bytes.Buffer
b = rootOpts.ToBuild(configOpts.Printer.WithWriter(&buf))
configOpts.Printer.Spinner, _ = configOpts.Printer.Spinner.Start("driver building, it will take a few seconds")
defer func() {
configOpts.Printer.DefaultText.Print(buf.String())
}()
}
return driverbuilder.NewLocalBuildProcessor(opts.useDKMS,
opts.downloadHeaders,
false,
opts.srcDir,
opts.envMap,
configOpts.Timeout).Start(b)
}
return nil
},
}
// Add root flags, but not the ones unneeded
unusedFlagsSet := map[string]struct{}{
"architecture": {},
"kernelurls": {},
"builderrepo": {},
"builderimage": {},
"gccversion": {},
"kernelconfigdata": {},
"proxy": {},
"registry-name": {},
"registry-password": {},
"registry-plain-http": {},
"registry-user": {},
}
flagSet := pflag.NewFlagSet("local", pflag.ExitOnError)
rootFlags.VisitAll(func(flag *pflag.Flag) {
if _, ok := unusedFlagsSet[flag.Name]; !ok {
flagSet.AddFlag(flag)
}
})
flagSet.BoolVar(&opts.useDKMS, "dkms", false, "Enforce usage of DKMS to build the kernel module.")
flagSet.BoolVar(&opts.downloadHeaders, "download-headers", false, "Try to automatically download kernel headers.")
flagSet.StringVar(&opts.srcDir, "src-dir", "", "Enforce usage of local source dir to build drivers.")
flagSet.StringToStringVar(&opts.envMap, "env", make(map[string]string), "Env variables to be enforced during the driver build.")
localCmd.PersistentFlags().AddFlagSet(flagSet)
return localCmd
}

View File

@ -1,29 +1,43 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"errors"
"fmt"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"io"
"os"
"runtime"
"sort"
"strings"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"github.com/falcosecurity/driverkit/pkg/version"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
homedir "github.com/mitchellh/go-homedir"
logger "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
func persistentValidateFunc(rootCommand *RootCmd, rootOpts *RootOptions) func(c *cobra.Command, args []string) error {
func persistentValidateFunc(rootCommand *RootCmd, configOpts *ConfigOptions, rootOpts *RootOptions) func(c *cobra.Command, args []string) error {
return func(c *cobra.Command, args []string) error {
var validationError = errors.New("exiting for validation errors")
configErr := configOpts.Init()
// Early exit if detect some error into config flags
if configOptions.configErrors {
return fmt.Errorf("exiting for validation errors")
if configErr {
return validationError
}
// Merge environment variables or config file values into the RootOptions instance
skip := map[string]bool{ // do not merge these
@ -44,13 +58,13 @@ func persistentValidateFunc(rootCommand *RootCmd, rootOpts *RootOptions) func(c
// rather than replace, it appends. Since viper will already have the cli options set
// if supplied, we only need this step if rootCommand doesn't already have them e.g.
// not set on CLI so read from config.
if cli_urls, err := rootCommand.c.Flags().GetStringSlice(name); err == nil && len(cli_urls) != 0 {
if cliURLs, err := rootCommand.c.Flags().GetStringSlice(name); err == nil && len(cliURLs) != 0 {
return
}
value := viper.GetStringSlice(name)
if len(value) != 0 {
strValue := strings.Join(value, ",")
rootCommand.c.Flags().Set(name, strValue)
_ = rootCommand.c.Flags().Set(name, strValue)
}
} else {
value := viper.GetString(name)
@ -62,7 +76,7 @@ func persistentValidateFunc(rootCommand *RootCmd, rootOpts *RootOptions) func(c
}
// set the value, if any, otherwise let the default
if value != "" {
rootCommand.c.Flags().Set(name, value)
_ = rootCommand.c.Flags().Set(name, value)
}
}
}
@ -71,20 +85,16 @@ func persistentValidateFunc(rootCommand *RootCmd, rootOpts *RootOptions) func(c
// Avoid sensitive info into default values help line
rootCommand.StripSensitive()
// We just use ubuntu internally
if strings.HasPrefix(rootOpts.Target, "ubuntu") {
rootOpts.Target = "ubuntu"
}
// Do not block root or help command to exec disregarding the root flags validity
if c.Root() != c && c.Name() != "help" && c.Name() != "__complete" && c.Name() != "__completeNoDesc" && c.Name() != "completion" {
if errs := rootOpts.Validate(); errs != nil {
for _, err := range errs {
logger.WithError(err).Error("error validating build options")
configOpts.Printer.Logger.Error("error validating build options",
configOpts.Printer.Logger.Args("err", err.Error()))
}
return fmt.Errorf("exiting for validation errors")
return validationError
}
rootOpts.Log()
rootOpts.Log(configOpts.Printer)
}
return nil
}
@ -96,9 +106,7 @@ type RootCmd struct {
}
// NewRootCmd instantiates the root command.
func NewRootCmd() *RootCmd {
configOptions = NewConfigOptions()
rootOpts := NewRootOptions()
func NewRootCmd(configOpts *ConfigOptions, rootOpts *RootOptions) *RootCmd {
rootCmd := &cobra.Command{
Use: "driverkit",
Short: "A command line tool to build Falco kernel modules and eBPF probes.",
@ -107,67 +115,51 @@ func NewRootCmd() *RootCmd {
Args: cobra.OnlyValidArgs,
DisableFlagsInUseLine: true,
DisableAutoGenTag: true,
SilenceErrors: true,
SilenceUsage: true,
Version: version.String(),
Run: func(c *cobra.Command, args []string) {
RunE: func(c *cobra.Command, args []string) error {
if len(args) == 0 {
logger.WithField("processors", validProcessors).Info("specify a valid processor")
configOpts.Printer.Logger.Info("specify a valid processor", configOpts.Printer.Logger.Args("processors", validProcessors))
}
// Fallback to help
c.Help()
return c.Help()
},
}
ret := &RootCmd{
c: rootCmd,
}
rootCmd.PersistentPreRunE = persistentValidateFunc(ret, rootOpts)
rootCmd.PersistentPreRunE = persistentValidateFunc(ret, configOpts, rootOpts)
flags := rootCmd.Flags()
targets := builder.BuilderByTarget.Targets()
targets := builder.Targets()
sort.Strings(targets)
flags.StringVarP(&configOptions.ConfigFile, "config", "c", configOptions.ConfigFile, "config file path (default $HOME/.driverkit.yaml if exists)")
flags.StringVarP(&configOptions.LogLevel, "loglevel", "l", configOptions.LogLevel, "log level")
flags.IntVar(&configOptions.Timeout, "timeout", configOptions.Timeout, "timeout in seconds")
flags.BoolVar(&configOptions.DryRun, "dryrun", configOptions.DryRun, "do not actually perform the action")
flags.StringVar(&configOptions.ProxyURL, "proxy", configOptions.ProxyURL, "the proxy to use to download data")
configOpts.AddFlags(flags)
rootOpts.AddFlags(flags, targets)
flags.StringVar(&rootOpts.Output.Module, "output-module", rootOpts.Output.Module, "filepath where to save the resulting kernel module")
flags.StringVar(&rootOpts.Output.Probe, "output-probe", rootOpts.Output.Probe, "filepath where to save the resulting eBPF probe")
flags.StringVar(&rootOpts.Architecture, "architecture", runtime.GOARCH, "target architecture for the built driver, one of "+kernelrelease.SupportedArchs.String())
flags.StringVar(&rootOpts.DriverVersion, "driverversion", rootOpts.DriverVersion, "driver version as a git commit hash or as a git tag")
flags.StringVar(&rootOpts.KernelVersion, "kernelversion", rootOpts.KernelVersion, "kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v'")
flags.StringVar(&rootOpts.KernelRelease, "kernelrelease", rootOpts.KernelRelease, "kernel release to build the module for, it can be found by executing 'uname -v'")
flags.StringVarP(&rootOpts.Target, "target", "t", rootOpts.Target, "the system to target the build for, one of ["+strings.Join(targets, ",")+"]")
flags.StringVar(&rootOpts.KernelConfigData, "kernelconfigdata", rootOpts.KernelConfigData, "base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc")
flags.StringVar(&rootOpts.ModuleDeviceName, "moduledevicename", rootOpts.ModuleDeviceName, "kernel module device name (the default is falco, so the device will be under /dev/falco*)")
flags.StringVar(&rootOpts.ModuleDriverName, "moduledrivername", rootOpts.ModuleDriverName, "kernel module driver name, i.e. the name you see when you check installed modules via lsmod")
flags.StringVar(&rootOpts.BuilderImage, "builderimage", rootOpts.BuilderImage, "docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.")
flags.StringVar(&rootOpts.BuilderImageBase, "builderimagebase", rootOpts.BuilderImageBase, "base docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.")
flags.StringVar(&rootOpts.GCCVersion, "gccversion", rootOpts.GCCVersion, "enforce a specific gcc version for the build")
flags.StringSliceVar(&rootOpts.KernelUrls, "kernelurls", nil, "list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls \"<URL3>,<URL4>\")")
flags.StringVar(&rootOpts.Repo.Org, "repo-org", rootOpts.Repo.Org, "repository github organization")
flags.StringVar(&rootOpts.Repo.Name, "repo-name", rootOpts.Repo.Name, "repository github name")
viper.BindPFlags(flags)
if err := viper.BindPFlags(flags); err != nil {
panic(err)
}
// Flag annotations and custom completions
rootCmd.MarkFlagFilename("config", viper.SupportedExts...)
rootCmd.RegisterFlagCompletionFunc("target", func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
_ = rootCmd.MarkFlagFilename("config", viper.SupportedExts...)
_ = rootCmd.RegisterFlagCompletionFunc("target", func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return targets, cobra.ShellCompDirectiveDefault
})
rootCmd.RegisterFlagCompletionFunc("architecture", func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
_ = rootCmd.RegisterFlagCompletionFunc("architecture", func(c *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return kernelrelease.SupportedArchs.Strings(), cobra.ShellCompDirectiveDefault
})
// Subcommands
rootCmd.AddCommand(NewKubernetesCmd(rootOpts, flags))
rootCmd.AddCommand(NewKubernetesInClusterCmd(rootOpts, flags))
rootCmd.AddCommand(NewDockerCmd(rootOpts, flags))
rootCmd.AddCommand(NewCompletionCmd())
rootCmd.AddCommand(NewKubernetesCmd(configOpts, rootOpts, flags))
rootCmd.AddCommand(NewKubernetesInClusterCmd(configOpts, rootOpts, flags))
rootCmd.AddCommand(NewDockerCmd(configOpts, rootOpts, flags))
rootCmd.AddCommand(NewLocalCmd(configOpts, rootOpts, flags))
rootCmd.AddCommand(NewImagesCmd(configOpts, rootOpts, flags))
rootCmd.AddCommand(NewCompletionCmd(configOpts, rootOpts, flags))
ret.StripSensitive()
@ -196,16 +188,15 @@ func (r *RootCmd) Command() *cobra.Command {
return r.c
}
// SetArgs proxies the arguments to the underlying cobra.Command.
func (r *RootCmd) SetArgs(args []string) {
r.c.SetArgs(args)
}
// SetOutput sets the main command output writer.
func (r *RootCmd) SetOutput(w io.Writer) {
r.c.SetOut(w)
r.c.SetErr(w)
logger.SetOutput(w)
}
// SetArgs proxies the arguments to the underlying cobra.Command.
func (r *RootCmd) SetArgs(args []string) {
r.c.SetArgs(args)
}
// Execute proxies the cobra.Command execution.
@ -215,59 +206,30 @@ func (r *RootCmd) Execute() error {
// Start creates the root command and runs it.
func Start() {
root := NewRootCmd()
if err := root.Execute(); err != nil {
logger.WithError(err).Fatal("error executing driverkit")
}
}
func init() {
logger.SetFormatter(&logger.TextFormatter{
ForceColors: true,
DisableLevelTruncation: false,
DisableTimestamp: true,
})
cobra.OnInitialize(initConfig)
}
// initConfig reads in config file and ENV variables if set.
func initConfig() {
if errs := configOptions.Validate(); errs != nil {
for _, err := range errs {
logger.WithError(err).Error("error validating config options")
}
// configOptions.configErrors should be true here
}
if configOptions.ConfigFile != "" {
viper.SetConfigFile(configOptions.ConfigFile)
} else {
// Find home directory.
home, err := homedir.Dir()
if err != nil {
logger.WithError(err).Debug("error getting the home directory")
// not setting configOptions.configErrors = true because we fallback to `$HOME/.driverkit.yaml` and try with it
}
viper.AddConfigPath(home)
viper.SetConfigName(".driverkit")
}
viper.AutomaticEnv()
viper.SetEnvPrefix("driverkit")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
// If a config file is found, read it in.
if err := viper.ReadInConfig(); err == nil {
logger.WithField("file", viper.ConfigFileUsed()).Info("using config file")
} else {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
// Config file not found, ignore ...
logger.Debug("running without a configuration file")
configOpts, err := NewConfigOptions()
if err != nil {
// configOpts will never be nil here
if configOpts != nil {
configOpts.Printer.Logger.Fatal("error setting driverkit config options defaults",
configOpts.Printer.Logger.Args("err", err.Error()))
} else {
// Config file was found but another error was produced
logger.WithField("file", viper.ConfigFileUsed()).WithError(err).Debug("error running with config file")
configOptions.configErrors = true
os.Exit(1)
}
}
rootOpts, err := NewRootOptions()
if err != nil {
configOpts.Printer.Logger.Fatal("error setting driverkit root options defaults",
configOpts.Printer.Logger.Args("err", err.Error()))
}
// Cleanup spinner upon leaving if any
defer func() {
if configOpts.Printer.Spinner != nil {
_ = configOpts.Printer.Spinner.Stop()
}
}()
root := NewRootCmd(configOpts, rootOpts)
if err = root.Execute(); err != nil {
configOpts.Printer.Logger.Fatal("error executing driverkit", configOpts.Printer.Logger.Args("err", err.Error()))
}
}

View File

@ -1,14 +1,32 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"errors"
"github.com/falcosecurity/falcoctl/pkg/output"
"github.com/spf13/pflag"
"os"
"runtime"
"strings"
"github.com/creasty/defaults"
"github.com/falcosecurity/driverkit/pkg/driverbuilder/builder"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"github.com/falcosecurity/driverkit/validate"
"github.com/go-playground/validator/v10"
logger "github.com/sirupsen/logrus"
)
// OutputOptions wraps the two drivers that driverkit builds.
@ -17,11 +35,22 @@ type OutputOptions struct {
Probe string `validate:"required_without=Module,filepath,omitempty,endswith=.o" name:"output probe path"`
}
func (oo *OutputOptions) HasOutputs() bool {
return oo.Module != "" || oo.Probe != ""
}
type RepoOptions struct {
Org string `default:"falcosecurity" name:"organization name"`
Name string `default:"libs" name:"repo name"`
}
type Registry struct {
Name string `validate:"required_with=Username Password" name:"registry name"`
Username string `validate:"required_with=Registry Password" name:"registry username"`
Password string `validate:"required_with=Username Registry" name:"registry password"`
PlainHTTP bool `default:"false" name:"registry plain http"`
}
// RootOptions ...
type RootOptions struct {
Architecture string `validate:"required,architecture" name:"architecture"`
@ -33,11 +62,12 @@ type RootOptions struct {
Target string `validate:"required,target" name:"target"`
KernelConfigData string `validate:"omitempty,base64" name:"kernel config data"` // fixme > tag "name" does not seem to work when used at struct level, but works when used at inner level
BuilderImage string `validate:"omitempty,imagename" name:"builder image"`
BuilderImageBase string `validate:"omitempty,imagename" name:"builder base image"`
BuilderRepos []string `default:"[\"docker.io/falcosecurity/driverkit-builder\"]" validate:"omitempty" name:"docker repositories to look for builder images or absolute path pointing to a yaml file containing builder images index"`
GCCVersion string `validate:"omitempty,semvertolerant" name:"gcc version"`
KernelUrls []string `name:"kernel header urls"`
Repo RepoOptions
Output OutputOptions
Registry Registry
}
func init() {
@ -45,22 +75,23 @@ func init() {
}
// NewRootOptions ...
func NewRootOptions() *RootOptions {
func NewRootOptions() (*RootOptions, error) {
rootOpts := &RootOptions{}
if err := defaults.Set(rootOpts); err != nil {
logger.WithError(err).WithField("options", "RootOptions").Fatal("error setting driverkit options defaults")
return nil, err
}
return rootOpts
return rootOpts, nil
}
// Validate validates the RootOptions fields.
func (ro *RootOptions) Validate() []error {
if err := validate.V.Struct(ro); err != nil {
errors := err.(validator.ValidationErrors)
var errs validator.ValidationErrors
errors.As(err, &errs)
errArr := []error{}
for _, e := range errors {
for _, e := range errs {
// Translate each error one at a time
errArr = append(errArr, fmt.Errorf(e.Translate(validate.T)))
errArr = append(errArr, errors.New(e.Translate(validate.T)))
}
return errArr
}
@ -69,82 +100,120 @@ func (ro *RootOptions) Validate() []error {
kr := kernelrelease.FromString(ro.KernelRelease)
kr.Architecture = kernelrelease.Architecture(ro.Architecture)
if !kr.SupportsModule() && !kr.SupportsProbe() {
return []error{fmt.Errorf("both module and probe are not supported by given options")}
return []error{errors.New("both module and probe are not supported by given options")}
}
return nil
}
func (ro *RootOptions) AddFlags(flags *pflag.FlagSet, targets []string) {
flags.StringVar(&ro.Output.Module, "output-module", ro.Output.Module, "filepath where to save the resulting kernel module")
flags.StringVar(&ro.Output.Probe, "output-probe", ro.Output.Probe, "filepath where to save the resulting eBPF probe")
flags.StringVar(&ro.Architecture, "architecture", runtime.GOARCH, "target architecture for the built driver, one of "+kernelrelease.SupportedArchs.String())
flags.StringVar(&ro.DriverVersion, "driverversion", ro.DriverVersion, "driver version as a git commit hash or as a git tag")
flags.StringVar(&ro.KernelVersion, "kernelversion", ro.KernelVersion, "kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v'")
flags.StringVar(&ro.KernelRelease, "kernelrelease", ro.KernelRelease, "kernel release to build the module for, it can be found by executing 'uname -v'")
flags.StringVarP(&ro.Target, "target", "t", ro.Target, "the system to target the build for, one of ["+strings.Join(targets, ",")+"]")
flags.StringVar(&ro.KernelConfigData, "kernelconfigdata", ro.KernelConfigData, "base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc")
flags.StringVar(&ro.ModuleDeviceName, "moduledevicename", ro.ModuleDeviceName, "kernel module device name (the default is falco, so the device will be under /dev/falco*)")
flags.StringVar(&ro.ModuleDriverName, "moduledrivername", ro.ModuleDriverName, "kernel module driver name, i.e. the name you see when you check installed modules via lsmod")
flags.StringVar(&ro.BuilderImage, "builderimage", ro.BuilderImage, "docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.")
flags.StringSliceVar(&ro.BuilderRepos, "builderrepo", ro.BuilderRepos, "list of docker repositories or yaml file (absolute path) containing builder images index with the format 'images: [ { target:<target>, name:<image-name>, arch: <arch>, tag: <imagetag>, gcc_versions: [ <gcc-tag> ] },...]', in descending priority order. Used to search for builder images. eg: --builderrepo myorg/driverkit-builder --builderrepo falcosecurity/driverkit-builder --builderrepo '/path/to/my/index.yaml'.")
flags.StringVar(&ro.GCCVersion, "gccversion", ro.GCCVersion, "enforce a specific gcc version for the build")
flags.StringSliceVar(&ro.KernelUrls, "kernelurls", nil, "list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls \"<URL3>,<URL4>\")")
flags.StringVar(&ro.Repo.Org, "repo-org", ro.Repo.Org, "repository github organization")
flags.StringVar(&ro.Repo.Name, "repo-name", ro.Repo.Name, "repository github name")
flags.StringVar(&ro.Registry.Name, "registry-name", ro.Registry.Name, "registry name to which authenticate")
flags.StringVar(&ro.Registry.Username, "registry-user", ro.Registry.Username, "registry username")
flags.StringVar(&ro.Registry.Password, "registry-password", ro.Registry.Password, "registry password")
flags.BoolVar(&ro.Registry.PlainHTTP, "registry-plain-http", ro.Registry.PlainHTTP, "allows interacting with remote registry via plain http requests")
}
// Log emits a log line containing the receiving RootOptions for debugging purposes.
//
// Call it only after validation.
func (ro *RootOptions) Log() {
fields := logger.Fields{}
if ro.Output.Module != "" {
fields["output-module"] = ro.Output.Module
}
if ro.Output.Probe != "" {
fields["output-probe"] = ro.Output.Probe
}
if ro.DriverVersion != "" {
fields["driverversion"] = ro.DriverVersion
}
if ro.KernelRelease != "" {
fields["kernelrelease"] = ro.KernelRelease
}
if ro.KernelVersion != "" {
fields["kernelversion"] = ro.KernelVersion
}
if ro.Target != "" {
fields["target"] = ro.Target
}
fields["arch"] = ro.Architecture
if len(ro.KernelUrls) > 0 {
fields["kernelurls"] = ro.KernelUrls
}
fields["repo-org"] = ro.Repo.Org
fields["repo-name"] = ro.Repo.Name
logger.WithFields(fields).Debug("running with options")
func (ro *RootOptions) Log(printer *output.Printer) {
printer.Logger.Debug("running with options",
printer.Logger.Args(
"output-module", ro.Output.Module,
"output-probe", ro.Output.Probe,
"driverversion", ro.DriverVersion,
"kernelrelease", ro.KernelRelease,
"kernelversion", ro.KernelVersion,
"target", ro.Target,
"arch", ro.Architecture,
"kernelurls", ro.KernelUrls,
"repo-org", ro.Repo.Org,
"repo-name", ro.Repo.Name,
))
}
func (ro *RootOptions) toBuild() *builder.Build {
func (ro *RootOptions) ToBuild(printer *output.Printer) *builder.Build {
kernelConfigData := ro.KernelConfigData
if len(kernelConfigData) == 0 {
kernelConfigData = "bm8tZGF0YQ==" // no-data
}
build := &builder.Build{
TargetType: builder.Type(ro.Target),
DriverVersion: ro.DriverVersion,
KernelVersion: ro.KernelVersion,
KernelRelease: ro.KernelRelease,
Architecture: ro.Architecture,
KernelConfigData: kernelConfigData,
ModuleFilePath: ro.Output.Module,
ProbeFilePath: ro.Output.Probe,
ModuleDriverName: ro.ModuleDriverName,
ModuleDeviceName: ro.ModuleDeviceName,
GCCVersion: ro.GCCVersion,
CustomBuilderImage: ro.BuilderImage,
CustomBuilderImageBase: ro.BuilderImageBase,
KernelUrls: ro.KernelUrls,
RepoOrg: ro.Repo.Org,
RepoName: ro.Repo.Name,
TargetType: builder.Type(ro.Target),
DriverVersion: ro.DriverVersion,
KernelVersion: ro.KernelVersion,
KernelRelease: ro.KernelRelease,
Architecture: ro.Architecture,
KernelConfigData: kernelConfigData,
ModuleFilePath: ro.Output.Module,
ProbeFilePath: ro.Output.Probe,
ModuleDriverName: ro.ModuleDriverName,
ModuleDeviceName: ro.ModuleDeviceName,
GCCVersion: ro.GCCVersion,
BuilderImage: ro.BuilderImage,
BuilderRepos: ro.BuilderRepos,
KernelUrls: ro.KernelUrls,
RepoOrg: ro.Repo.Org,
RepoName: ro.Repo.Name,
Images: make(builder.ImagesMap),
RegistryName: ro.Registry.Name,
RegistryUser: ro.Registry.Username,
RegistryPassword: ro.Registry.Password,
RegistryPlainHTTP: ro.Registry.PlainHTTP,
Printer: printer,
}
// loop over BuilderRepos to build the list ImagesListers based on the value of the builderRepo:
// if it's a local path use FileImagesLister, otherwise use RepoImagesLister
var (
imageLister builder.ImagesLister
err error
)
for _, builderRepo := range build.BuilderRepos {
if _, err = os.Stat(builderRepo); err == nil {
imageLister, err = builder.NewFileImagesLister(builderRepo, build)
} else {
imageLister, err = builder.NewRepoImagesLister(builderRepo, build)
}
if err != nil {
printer.Logger.Warn("skipping repo",
printer.Logger.Args("repo", builderRepo, "err", err.Error()))
} else {
build.ImagesListers = append(build.ImagesListers, imageLister)
}
}
// attempt the build in case it comes from an invalid config
kr := build.KernelReleaseFromBuildConfig()
if len(build.ModuleFilePath) > 0 && !kr.SupportsModule() {
build.ModuleFilePath = ""
logger.Warningf("Skipping build attempt of module for unsupported kernel version %s", kr.String())
printer.Logger.Warn("skipping build attempt of module for unsupported kernel release",
printer.Logger.Args("kernelrelease", kr.String()))
}
if len(build.ProbeFilePath) > 0 && !kr.SupportsProbe() {
build.ProbeFilePath = ""
logger.Warningf("Skipping build attempt of probe for unsupported kernel version %s", kr.String())
printer.Logger.Warn("skipping build attempt of probe for unsupported kernel release",
printer.Logger.Args("kernelrelease", kr.String()))
}
return build
}

View File

@ -1,4 +1,5 @@
INFO specify a valid processor processors="[docker kubernetes kubernetes-in-cluster]"
INFO specify a valid processor
└ processors: [docker kubernetes kubernetes-in-cluster local]
{{ .Desc }}
{{ .Usage }}
@ -6,6 +7,6 @@ INFO specify a valid processor processors="[docker kubernete
{{ .Commands }}
{{ .Flags }}
-v, --version version for driverkit
-v, --version version for driverkit
{{ .Info }}

View File

@ -3,4 +3,5 @@ kernelversion: 59
target: ubuntu-aws
output:
module: /tmp/falco-ubuntu-aws.ko
probe: /tmp/falco-ubuntu-aws.o
driverversion: master

View File

@ -7,4 +7,5 @@ kernelurls: [
target: ubuntu-aws
output:
module: /tmp/falco-ubuntu-aws.ko
probe: /tmp/falco-ubuntu-aws.o
driverversion: master

View File

@ -1,3 +1,13 @@
INFO using config file file=testdata/configs/1.yaml
DEBU running with options arch={{ .CurrentArch }} driverversion=master kernelrelease=4.15.0-1057-aws kernelversion=59 output-module=/tmp/falco-ubuntu-aws.ko repo-name=libs repo-org=falcosecurity target=ubuntu
INFO driver building, it will take a few seconds processor=docker
INFO using config file file: testdata/configs/1.yaml
DEBUG running with options
├ output-module: /tmp/falco-ubuntu-aws.ko
├ output-probe: /tmp/falco-ubuntu-aws.o
├ driverversion: master
├ kernelrelease: 4.15.0-1057-aws
├ kernelversion: 59
├ target: ubuntu-aws
├ arch: {{ .CurrentArch }}
├ kernelurls: []
├ repo-org: falcosecurity
└ repo-name: libs
INFO starting build processor: docker

View File

@ -1,3 +1,13 @@
INFO using config file file=testdata/configs/1.yaml
DEBU running with options arch={{ .CurrentArch }} driverversion=master kernelrelease=4.15.0-1057-aws kernelversion=229 output-module=/tmp/override.ko repo-name=libs repo-org=falcosecurity target=ubuntu
INFO driver building, it will take a few seconds processor=docker
INFO using config file file: testdata/configs/1.yaml
DEBUG running with options
├ output-module: /tmp/override.ko
├ output-probe: /tmp/falco-ubuntu-aws.o
├ driverversion: master
├ kernelrelease: 4.15.0-1057-aws
├ kernelversion: 229
├ target: ubuntu-aws
├ arch: {{ .CurrentArch }}
├ kernelurls: []
├ repo-org: falcosecurity
└ repo-name: libs
INFO starting build processor: docker

View File

@ -1,3 +1,13 @@
INFO using config file file=testdata/configs/2.yaml
DEBU running with options arch={{ .CurrentArch }} driverversion=master kernelrelease=4.15.0-1057-aws kernelurls="[https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-aws-headers-4.15.0-1057_4.15.0-1057.59_all.deb https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-headers-4.15.0-1057-aws_4.15.0-1057.59_amd64.deb]" kernelversion=59 output-module=/tmp/falco-ubuntu-aws.ko repo-name=libs repo-org=falcosecurity target=ubuntu
INFO driver building, it will take a few seconds processor=docker
INFO using config file file: testdata/configs/2.yaml
DEBUG running with options
├ output-module: /tmp/falco-ubuntu-aws.ko
├ output-probe: /tmp/falco-ubuntu-aws.o
├ driverversion: master
├ kernelrelease: 4.15.0-1057-aws
├ kernelversion: 59
├ target: ubuntu-aws
├ arch: {{ .CurrentArch }}
├ kernelurls: [https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-aws-headers-4.15.0-1057_4.15.0-1057.59_all.deb https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-headers-4.15.0-1057-aws_4.15.0-1057.59_amd64.deb]
├ repo-org: falcosecurity
└ repo-name: libs
INFO starting build processor: docker

View File

@ -1,3 +1,13 @@
DEBU running without a configuration file
DEBU running with options arch={{ .CurrentArch }} driverversion=master kernelrelease=4.15.0-1057-azure kernelurls="[http://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-azure/linux-azure-headers-4.15.0-1057_4.15.0-1057.62_all.deb http://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-azure/linux-headers-4.15.0-1057-azure_4.15.0-1057.62_amd64.deb]" kernelversion=62 output-module=/tmp/falco-ubuntu-azure.ko repo-name=libs repo-org=falcosecurity target=ubuntu
INFO driver building, it will take a few seconds processor=docker
DEBUG running without a configuration file
DEBUG running with options
├ output-module: /tmp/falco-ubuntu-azure.ko
├ output-probe: /tmp/falco-ubuntu-aws.o
├ driverversion: master
├ kernelrelease: 4.15.0-1057-azure
├ kernelversion: 62
├ target: ubuntu-azure
├ arch: {{ .CurrentArch }}
├ kernelurls: [http://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-azure/linux-azure-headers-4.15.0-1057_4.15.0-1057.62_all.deb http://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-azure/linux-headers-4.15.0-1057-azure_4.15.0-1057.62_amd64.deb]
├ repo-org: falcosecurity
└ repo-name: libs
INFO starting build processor: docker

View File

@ -1,8 +1,4 @@
DEBU running without a configuration file
ERRO error validating build options error="builder image is a required field when target is redhat"
Error: exiting for validation errors
Usage:
driverkit docker [flags]
{{ .Flags }}
DEBUG running without a configuration file
ERROR error validating build options
└ err: builder image is a required field when target is redhat
ERROR error executing driverkit err: exiting for validation errors

View File

@ -1,3 +1,13 @@
DEBU running without a configuration file
DEBU running with options arch={{ .CurrentArch }} driverversion=master kernelrelease=4.15.0-1057-aws kernelurls="[https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-aws-headers-4.15.0-1057_4.15.0-1057.59_all.deb https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-headers-4.15.0-1057-aws_4.15.0-1057.59_amd64.deb]" kernelversion=59 output-module=/tmp/falco-ubuntu-aws.ko repo-name=libs repo-org=falcosecurity target=ubuntu
INFO driver building, it will take a few seconds processor=docker
DEBUG running without a configuration file
DEBUG running with options
├ output-module: /tmp/falco-ubuntu-aws.ko
├ output-probe: /tmp/falco-ubuntu-aws.o
├ driverversion: master
├ kernelrelease: 4.15.0-1057-aws
├ kernelversion: 59
├ target: ubuntu-aws
├ arch: {{ .CurrentArch }}
├ kernelurls: [https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-aws-headers-4.15.0-1057_4.15.0-1057.59_all.deb https://mirrors.edge.kernel.org/ubuntu/pool/main/l/linux-aws/linux-headers-4.15.0-1057-aws_4.15.0-1057.59_amd64.deb]
├ repo-org: falcosecurity
└ repo-name: libs
INFO starting build processor: docker

View File

@ -1 +1 @@
INFO driver building, it will take a few seconds processor=docker
INFO starting build processor: docker

View File

@ -1,10 +1,7 @@
ERRO error validating build options error="kernel release is a required field"
ERRO error validating build options error="target is a required field"
ERRO error validating build options error="output module path is required when probe is missing"
ERRO error validating build options error="output probe path is required when module is missing"
Error: exiting for validation errors
Usage:
driverkit docker [flags]
{{ .Flags }}
ERROR error validating build options err: kernel release is a required field
ERROR error validating build options err: target is a required field
ERROR error validating build options
└ err: output module path is required when probe is missing
ERROR error validating build options
└ err: output probe path is required when module is missing
ERROR error executing driverkit err: exiting for validation errors

View File

@ -5,6 +5,6 @@
{{ .Commands }}
{{ .Flags }}
-v, --version version for driverkit
-v, --version version for driverkit
{{ .Info }}

View File

@ -5,5 +5,6 @@
{{ .Commands }}
{{ .Flags }}
-v, --version version for driverkit
{{ .Info }}

View File

@ -1,11 +1,3 @@
ERRO error validating config options error="proxy url must start with http:// or https:// or socks5:// prefix"
Error: exiting for validation errors
{{ .Usage }}
{{ .Commands }}
{{ .Flags }}
-v, --version version for driverkit
{{ .Info }}
ERROR error validating config options
└ err: proxy url must start with http:// or https:// or socks5:// prefix
ERROR error executing driverkit err: exiting for validation errors

View File

@ -1,10 +1 @@
Error: invalid argument "abc" for "driverkit"
{{ .Usage }}
{{ .Commands }}
{{ .Flags }}
-v, --version version for driverkit
{{ .Info }}
ERROR error executing driverkit err: invalid argument "abc" for "driverkit"

View File

@ -2,5 +2,7 @@ Available Commands:
completion Generates completion scripts.
docker Build Falco kernel modules and eBPF probes against a docker daemon.
help Help about any command
images List builder images
kubernetes Build Falco kernel modules and eBPF probes against a Kubernetes cluster.
kubernetes-in-cluster Build Falco kernel modules and eBPF probes against a Kubernetes cluster inside a Kubernetes cluster.
kubernetes-in-cluster Build Falco kernel modules and eBPF probes against a Kubernetes cluster inside a Kubernetes cluster.
local Build Falco kernel modules and eBPF probes in local env with local kernel sources and gcc/clang.

View File

@ -1,23 +1,27 @@
Flags:
--architecture string target architecture for the built driver, one of {{ .Architectures }} (default "{{ .CurrentArch }}")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderimagebase string base docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
-h, --help help for {{ .Cmd }}
--kernelconfigdata string base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string log level (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
-t, --target string the system to target the build for, one of {{ .Targets }}
--timeout int timeout in seconds (default 120)
--architecture string target architecture for the built driver, one of {{ .Architectures }} (default "{{ .CurrentArch }}")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderrepo strings list of docker repositories or yaml file (absolute path) containing builder images index with the format 'images: [ { target:<target>, name:<image-name>, arch: <arch>, tag: <imagetag>, gcc_versions: [ <gcc-tag> ] },...]', in descending priority order. Used to search for builder images. eg: --builderrepo myorg/driverkit-builder --builderrepo falcosecurity/driverkit-builder --builderrepo '/path/to/my/index.yaml'. (default [docker.io/falcosecurity/driverkit-builder])
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
-h, --help help for {{ .Cmd }}
--kernelconfigdata string base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string set level for logs (info, warn, debug, trace) (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--registry-name string registry name to which authenticate
--registry-password string registry password
--registry-plain-http allows interacting with remote registry via plain http requests
--registry-user string registry username
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
-t, --target string the system to target the build for, one of {{ .Targets }}
--timeout int timeout in seconds (default 120)

View File

@ -1,16 +1,28 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
"github.com/falcosecurity/driverkit/cmd"
logger "github.com/sirupsen/logrus"
"github.com/spf13/cobra/doc"
)
@ -47,7 +59,22 @@ func main() {
flag.Parse()
// Get root command
driverkit := cmd.NewRootCmd()
configOpts, err := cmd.NewConfigOptions()
if err != nil {
// configOpts will never be nil here
if configOpts != nil {
configOpts.Printer.Logger.Fatal("error setting driverkit config options defaults",
configOpts.Printer.Logger.Args("err", err.Error()))
} else {
os.Exit(1)
}
}
rootOpts, err := cmd.NewRootOptions()
if err != nil {
configOpts.Printer.Logger.Fatal("error setting driverkit root options defaults",
configOpts.Printer.Logger.Args("err", err.Error()))
}
driverkit := cmd.NewRootCmd(configOpts, rootOpts)
root := driverkit.Command()
num := len(root.Commands()) + 1
@ -70,20 +97,20 @@ func main() {
}
// Generate markdown docs
err := doc.GenMarkdownTreeCustom(root, outputDir, prepender(num), linker)
err = doc.GenMarkdownTreeCustom(root, outputDir, prepender(num), linker)
if err != nil {
logger.WithError(err).Fatal("markdown generation")
configOpts.Printer.Logger.Fatal("markdown generation", configOpts.Printer.Logger.Args("err", err.Error()))
}
if targetWebsite {
err := os.Rename(path.Join(outputDir, "driverkit.md"), path.Join(outputDir, "_index.md"))
err = os.Rename(path.Join(outputDir, "driverkit.md"), path.Join(outputDir, "_index.md"))
if err != nil {
logger.WithError(err).Fatal("renaming main docs page")
configOpts.Printer.Logger.Fatal("renaming main docs page", configOpts.Printer.Logger.Args("err", err.Error()))
}
}
if err := stripSensitive(); err != nil {
logger.WithError(err).Fatal("error replacing sensitive data")
if err = stripSensitive(); err != nil {
configOpts.Printer.Logger.Fatal("error replacing sensitive data", configOpts.Printer.Logger.Args("err", err.Error()))
}
}
@ -100,7 +127,7 @@ func stripSensitive() error {
for _, file := range files {
filePath := path.Join(outputDir, file.Name())
file, err := ioutil.ReadFile(filePath)
file, err := os.ReadFile(filePath)
if err != nil {
return err
}
@ -110,7 +137,7 @@ func stripSensitive() error {
target := []byte(os.Getenv(s))
file = bytes.ReplaceAll(file, target, append(envMark, []byte(s)...))
}
if err = ioutil.WriteFile(filePath, file, 0666); err != nil {
if err = os.WriteFile(filePath, file, 0666); err != nil {
return err
}
}

View File

@ -0,0 +1,32 @@
FROM amazonlinux:2.0.20240529.0
LABEL maintainer="cncf-falco-dev@lists.cncf.io"
RUN yum -y install gcc10 \
clang \
llvm \
bash-completion \
bc \
ca-certificates \
curl \
gnupg2 \
libc6-dev \
elfutils-libelf-devel \
xz \
cpio \
flex \
bison \
openssl \
openssl-devel \
wget \
binutils \
which \
make \
cmake3 \
tar \
zstd \
git
# Properly create soft links
RUN ln -s /usr/bin/gcc10-cc /usr/bin/gcc-10.0.0
RUN ln -s /usr/bin/cmake3 /usr/bin/cmake

View File

@ -0,0 +1 @@
builder-any-x86_64_gcc10.0.0_gcc9.0.0.Dockerfile

View File

@ -0,0 +1 @@
builder-any-x86_64_gcc12.0.0_gcc11.0.0.Dockerfile

View File

@ -0,0 +1 @@
builder-any-x86_64_gcc13.0.0.Dockerfile

View File

@ -0,0 +1 @@
builder-any-x86_64_gcc14.0.0.Dockerfile

View File

@ -0,0 +1 @@
builder-any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0.Dockerfile

View File

@ -39,4 +39,10 @@ RUN apt-get update \
software-properties-common \
gpg \
zstd \
&& rm -rf /var/lib/apt/lists/*
cmake \
git \
&& rm -rf /var/lib/apt/lists/*
# Properly create soft link
RUN ln -s /usr/bin/gcc-9 /usr/bin/gcc-9.0.0
RUN ln -s /usr/bin/gcc-10 /usr/bin/gcc-10.0.0

View File

@ -39,4 +39,10 @@ RUN apt-get update \
software-properties-common \
gpg \
zstd \
&& rm -rf /var/lib/apt/lists/*
cmake \
git \
&& rm -rf /var/lib/apt/lists/*
# Properly create soft links
RUN ln -s /usr/bin/gcc-11 /usr/bin/gcc-11.0.0
RUN ln -s /usr/bin/gcc-12 /usr/bin/gcc-12.0.0

View File

@ -0,0 +1,40 @@
FROM fedora:39
LABEL maintainer="cncf-falco-dev@lists.cncf.io"
ARG TARGETARCH
RUN dnf install -y \
bash-completion \
bc \
clang \
llvm \
ca-certificates \
curl \
dkms \
dwarves \
gnupg2 \
gcc \
jq \
glibc-devel \
elfutils-libelf-devel \
netcat \
xz \
cpio \
flex \
bison \
openssl \
openssl-devel \
ncurses-devel \
systemd-devel \
pciutils-devel \
binutils-devel \
lsb-release \
wget \
gpg \
zstd \
cmake \
git
# Properly create soft links
RUN ln -s /usr/bin/gcc /usr/bin/gcc-13.0.0

View File

@ -0,0 +1,40 @@
FROM fedora:41
LABEL maintainer="cncf-falco-dev@lists.cncf.io"
ARG TARGETARCH
RUN dnf install -y \
bash-completion \
bc \
clang \
llvm \
ca-certificates \
curl \
dkms \
dwarves \
gnupg2 \
gcc \
jq \
glibc-devel \
elfutils-libelf-devel \
netcat \
xz \
cpio \
flex \
bison \
openssl \
openssl-devel \
ncurses-devel \
systemd-devel \
pciutils-devel \
binutils-devel \
lsb-release \
wget \
gpg \
zstd \
cmake \
git
# Properly create soft links
RUN ln -s /usr/bin/gcc /usr/bin/gcc-14.0.0

View File

@ -5,18 +5,24 @@ LABEL maintainer="cncf-falco-dev@lists.cncf.io"
ARG TARGETARCH
RUN cp /etc/skel/.bashrc /root && cp /etc/skel/.profile /root
RUN echo 'deb http://deb.debian.org/debian buster-backports main' >>/etc/apt/sources.list
# Use 20250630T203427Z debian apt snapshot as it still contains support for buster.
RUN cat <<EOF > /etc/apt/sources.list
deb http://snapshot.debian.org/archive/debian/20250630T203427Z buster main
deb http://snapshot.debian.org/archive/debian-security/20250630T203427Z buster/updates main
deb http://snapshot.debian.org/archive/debian/20250630T203427Z buster-updates main
EOF
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash-completion \
bc \
clang \
llvm \
llvm \
ca-certificates \
curl \
dkms \
dwarves/buster-backports \
dwarves \
gnupg2 \
gcc \
jq \
@ -39,14 +45,18 @@ RUN apt-get update \
software-properties-common \
gpg \
zstd \
&& rm -rf /var/lib/apt/lists/*
gawk \
mawk \
git \
&& rm -rf /var/lib/apt/lists/*
RUN if [ "$TARGETARCH" = "amd64" ] ; then apt-get install -y --no-install-recommends libmpx2; fi
# gcc 4.9 is required on x86 to build some 3.10+ kernels
# note: on arm gcc 4.9 could not be found.
RUN echo 'deb http://deb.debian.org/debian jessie main' >>/etc/apt/sources.list # gcc 4.9 on x86_64
# jessie repo is unsigned therefore the APT options
RUN echo 'deb http://dk.archive.ubuntu.com/ubuntu/ xenial main' >> /etc/apt/sources.list && \
echo 'deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe' >> /etc/apt/sources.list
# repo is unsigned therefore the APT options
RUN if [ "$TARGETARCH" = "amd64" ] ; then apt-get -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true update && apt-get -o APT::Get::AllowUnauthenticated=true install -y --no-install-recommends gcc-4.9; fi
# gcc 6 is no longer included in debian stable, but we need it to
@ -120,3 +130,17 @@ RUN curl -L -o binutils_2.30-22_${TARGETARCH}.deb https://download.falco.org/dep
&& curl -L -o binutils-common_2.30-22_${TARGETARCH}.deb https://download.falco.org/dependencies/binutils-common_2.30-22_${TARGETARCH}.deb \
&& dpkg -i *binutils*.deb \
&& rm -f *binutils*.deb
# Install a recent version of cmake (debian buster has at most 3.13)
RUN curl -L -o /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.22.5/cmake-3.22.5-linux-$(uname -m).tar.gz; \
gzip -d /tmp/cmake.tar.gz; \
tar -xpf /tmp/cmake.tar --directory=/tmp; \
cp -R /tmp/cmake-3.22.5-linux-$(uname -m)/* /usr; \
rm -rf /tmp/cmake-3.22.5-linux-$(uname -m)/
# Properly create soft link
RUN ln -s /usr/bin/gcc-4.8 /usr/bin/gcc-4.8.0
RUN if [ "$TARGETARCH" = "amd64" ] ; then ln -s /usr/bin/gcc-4.9 /usr/bin/gcc-4.9.0; fi;
RUN ln -s /usr/bin/gcc-5 /usr/bin/gcc-5.0.0
RUN ln -s /usr/bin/gcc-6 /usr/bin/gcc-6.0.0
RUN ln -s /usr/bin/gcc-8 /usr/bin/gcc-8.0.0

View File

@ -0,0 +1,50 @@
FROM centos:7
LABEL maintainer="cncf-falco-dev@lists.cncf.io"
# Fix broken mirrors - centos:7 eol
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo; \
sed -i s/^#.*baseurl=http/baseurl=https/g /etc/yum.repos.d/*.repo; \
sed -i s/^mirrorlist=http/#mirrorlist=https/g /etc/yum.repos.d/*.repo
RUN yum -y install centos-release-scl
# fix broken mirrors (again)
RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo; \
sed -i s/^#.*baseurl=http/baseurl=https/g /etc/yum.repos.d/*.repo; \
sed -i s/^mirrorlist=http/#mirrorlist=https/g /etc/yum.repos.d/*.repo
RUN yum -y install gcc \
llvm-toolset-7.0 \
bash-completion \
bc \
ca-certificates \
curl \
gnupg2 \
libc6-dev \
elfutils-libelf-devel \
xz \
cpio \
flex \
bison \
openssl \
openssl-devel \
wget \
binutils \
which \
make \
git
# Install cmake3.x (on centos7 `cmake` package installs cmake2.x)
RUN curl -L -o /tmp/cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.22.5/cmake-3.22.5-linux-$(uname -m).tar.gz; \
gzip -d /tmp/cmake.tar.gz; \
tar -xpf /tmp/cmake.tar --directory=/tmp; \
cp -R /tmp/cmake-3.22.5-linux-$(uname -m)/* /usr; \
rm -rf /tmp/cmake-3.22.5-linux-$(uname -m)/
# Properly create soft link
RUN ln -s /usr/bin/gcc /usr/bin/gcc-4.8.5
RUN source scl_source enable llvm-toolset-7.0
RUN echo "source scl_source enable llvm-toolset-7.0" >> /etc/bashrc
RUN source /etc/bashrc

View File

@ -13,7 +13,8 @@ If that distribution is not yet supported by driverkit, the Falco Drivers Build
Adding support for a new distro is a multiple-step work:
* first of all, a new builder on driverkit must be created
* secondly, [kernel-crawler](https://github.com/falcosecurity/kernel-crawler) must also be updated to support the new distro; see [below](#5-kernel-crawler) section
* lastly, [test-infra](https://github.com/falcosecurity/test-infra) must be updated to add the new [prow config](https://github.com/falcosecurity/test-infra/tree/master/config/jobs/build-drivers) for new distro related jobs
* third, [dbg-go](https://github.com/falcosecurity/dbg-go) must [bump driverkit](https://github.com/falcosecurity/dbg-go?tab=readme-ov-file#bumping-driverkit) and enable support to generate configs for the new distro: https://github.com/falcosecurity/dbg-go/blob/main/pkg/root/distro.go#L30.
* lastly, [test-infra](https://github.com/falcosecurity/test-infra) must be updated to add the new [prow config](https://github.com/falcosecurity/test-infra/tree/master/config/jobs/build-drivers) for new distro related jobs and `dbg-go` images must be bumped, see https://github.com/falcosecurity/test-infra/tree/master/images/build-drivers and https://github.com/falcosecurity/test-infra/tree/master/images/update-dbg.
Here, we will only focus about driverkit part.
@ -37,7 +38,7 @@ Your builder will need a constant for the target it implements. Usually that con
can just be the ID of the distribution you are implementing, as taken reading `/etc/os-release` file.
A builder can implement more than one target at time. For example, the minikube builder is just a vanilla one.
Once you have the constant, you will need to add it to the `BuilderByTarget` map.
Once you have the constant, you will need to add it to the [byTarget](https://github.com/falcosecurity/driverkit/blob/master/pkg/driverbuilder/builder/target.go) map.
Open your file and you will need to add something like this:
```go
@ -48,7 +49,7 @@ type archLinux struct {
}
func init() {
BuilderByTarget[TargetTypeArchLinux] = &archLinux{}
byTarget[TargetTypeArchLinux] = &archLinux{}
}
```
@ -58,15 +59,19 @@ you just registered.
Here's a very minimalistic example:
```go
func (c archlinux) Name() string {
func (c *archlinux) Name() string {
return TargetTypeArchlinux.String()
}
func (c archlinux) TemplateScript() string {
return archlinuxTemplate
func (c *archlinux) TemplateKernelUrlsScript() string {
return archlinuxKernelTemplate
}
func (c archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (c *archlinux) TemplateScript() string {
return archlinuxTemplate
}
func (c archlinux) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
urls := []string{}
if kr.Architecture == kernelrelease.ArchitectureAmd64 {
urls = append(urls, fmt.Sprintf("https://archive.archlinux.org/packages/l/linux-headers/linux-headers-%s.%s-%d-%s.pkg.tar.xz",
@ -75,7 +80,7 @@ func (c archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string, e
cfg.KernelVersion,
kr.Architecture.ToNonDeb()))
} else {
urls = append(urls, fmt.Sprintf("http://tardis.tiny-vps.com/aarm/packages/l/linux-%s-headers/linux-%s-headers-%s-%d-%s.pkg.tar.xz",
urls = append(urls, fmt.Sprintf("https://alaa.ad24.cz/packages/l/linux-%s-headers/linux-%s-headers-%s-%d-%s.pkg.tar.xz",
kr.Architecture.ToNonDeb(),
kr.Architecture.ToNonDeb(),
kr.Fullversion,
@ -85,17 +90,17 @@ func (c archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string, e
return urls, nil
}
func (c archlinux) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (c *archlinux) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return archlinuxTemplateData{
commonTemplateData: cfg.toTemplateData(),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}
```
Essentially, the various methods that you are implementing are needed to:
* fill the script template (see below), that is a `bash` script that will be executed by driverkit at build time
* fetch kernel headers urls that will later be downloaded inside the builder container, and used for the driver build
* fill the kernel download/extract script template, a `bash` script responsible to fetch and extract the kernel headers for the distro
* fill the build script template (see below), that is a `bash` script that will be executed by driverkit at build time
* return a list of possible kernel headers urls that will later be downloaded by the kernel download script, and then used for the driver build
Under `pkg/driverbuilder/builder/templates` folder, you can find all the template scripts for the supported builders.
Adding a new template there and using `go:embed` to include it in your builder, allows leaner code
@ -103,14 +108,57 @@ without mixing up templates and builder logic.
For example:
```go
//go:embed templates/archlinux_kernel.sh
var archlinuxKernelTemplate string
//go:embed templates/archlinux.sh
var archlinuxTemplate string
```
Depending on how the distro works, the script will need to fetch the kernel headers for it at the specific kernel version specified
in the `Config` struct at `c.Build.KernelVersion`.
Depending on how the distro works, the "kernel" template script will fetch the kernel headers for it at the specific kernel version specified
in the `Config` struct at `c.Build.KernelVersion`, and then extracting them.
Finally, the script will also `export` the `KERNELDIR` variable to be consumed by the actual build script.
Example kernel download template for archlinux:
```bash
set -xeuo pipefail
# Fetch the kernel
mkdir /tmp/kernel-download
cd /tmp/kernel-download
curl --silent -o kernel-devel.pkg.tar.xz -SL {{ .KernelDownloadURL }}
tar -xf kernel-devel.pkg.tar.xz
rm -Rf /tmp/kernel
mkdir -p /tmp/kernel
mv usr/lib/modules/*/build/* /tmp/kernel
# exit value
export KERNELDIR=/tmp/kernel
```
Once you have those, based on what that kernel can do and based on what was configured
by the user you will need to build the kernel module driver and/or the eBPF probe driver.
by the user, the build script will build the kernel module driver and/or the eBPF probe driver.
Example build template for archlinux:
```bash
set -xeuo pipefail
cd {{ .DriverBuildDir }}
mkdir -p build && cd build
{{ .CmakeCmd }}
{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
{{ end }}
{{ if .BuildProbe }}
# Build the eBPF probe
make bpf
ls -l driver/bpf/probe.o
{{ end }}
```
How does this work?
@ -127,48 +175,16 @@ Indeed, the hardest part is fetching the kernel headers urls for each distro.
### 3. Customize GCC version
Driverkit builder images support multiple gcc versions:
A builder can enforce a GCC selection algorithm,
by implementing the `builder.GCCVersionRequestor` interface.
A sane default algorithm is provided, that selects a GCC version based on the kernel version.
The requested gcc version is then [used to find the correct builder image to be used](builder_images.md#selection-algorithm).
From **driverkit-builder_buster** image:
> **NOTE**: when implementing the `builder.GCCVersionRequestor`, returning an empty `semver.Version` means to fallback at default algorithm.
* /usr/bin/gcc-8
* /usr/bin/gcc-6 (6.3.0)
* /usr/bin/gcc-5 (5.5.0)
* /usr/bin/gcc-4.8 (4.8.4)
From **driverkit-builder_bullseye** image:
* /usr/bin/gcc-9
* /usr/bin/gcc-10
From **driverkit-builder_bookworm** image:
* /usr/bin/gcc-11
* /usr/bin/gcc-12
You can dynamically choose the one you prefer,
by letting your builder implement the `builder.GCCVersionRequestor` interface.
A sane default is provided, selecting it switching on the kernel version.
Please note that requested gcc version is used to find the correct builder image to be used.
Moreover, Driverkit builder images support multiple clang versions:
From **driverkit-builder_buster** image:
* /usr/bin/clang (clang-7)
From **driverkit-builder_bullseye** image:
* /usr/bin/clang (clang-11)
From **driverkit-builder_bookworm** image:
* /usr/bin/clang (clang-14)
Note, however, that there is no mechanism to dynamically choose a clang version,
because touching it should never be needed.
The build will use the one provided by the chosen builder image.
Any failure must be treated as a bug, and therefore an issue opened on [libs](https://github.com/falcosecurity/libs) repository.
However, there is no mechanism to dynamically choose a clang version, because there should never be any need of touching it.
The build will use the one provided by the chosen builder image.
Any failure must be treated as a bug, and reported on [libs](https://github.com/falcosecurity/libs) repository.
### 5. kernel-crawler
@ -176,6 +192,5 @@ When creating a new builder, it is recommended to check that [kernel-crawler](ht
can also support collecting the new builders kernel versions and header package URLs. This will make sure that the latest drivers
for the new builder are automatically built by [test-infra](https://github.com/falcosecurity/test-infra). If required, add a feature request
for support for the new builder on the kernel-crawler repository.
Note: be sure that the crawler you wants to add is interesting for the community as a whole.
For example, an archlinux crawler doesn't make much sense, because Arch is a rolling release and we should not support
any past Arch kernel for Falco.
> **NOTE**: be sure that the crawler you are going to add is interesting for the community as a whole.

View File

@ -5,36 +5,64 @@ A builder image is the docker image used to build the drivers.
## Adding a builder image
Adding a builder image is just a matter of adding a new dockerfile under the [build](../build) folder,
with a name matching: `builder_$osname.Dockerfile` (like: `builder_stretch.Dockerfile`).
Adding a builder image is just a matter of adding a new dockerfile under the [docker/builders](../docker/builders) folder,
with a name matching the following regex: `builder-(?P<target>[a-z0-9]+)-(?P<arch>x86_64|aarch64)(?P<gccVers>(_gcc[0-9]+.[0-9]+.[0-9]+)+).Dockerfile$`.
For example: `builder-centos-x86_64_gcc5.8.0_gcc6.0.0.Dockerfile`.
> **NOTE:** `any` is also a valid target, and means "apply as fallback for any target"
The image **MUST** symlink all of its provided GCC versions to their full semver name, like:
* `/usr/bin/gcc5` must be linked to `/usr/bin/gcc-5.0.0`
* `/usr/bin/gcc-4.8` must be linked to `/usr/bin/gcc-4.8.0`
This is needed because driverkit logic must be able to differentiate eg: between
an image that provides gcc4 and one that provides 4.8, in a reliable manner.
The makefile will be then automatically able to collect the new docker images and pushing it as part of the CI.
Note: the images will be pushed under the `falcosecurity/driverkit-builder` repository, each with a tag reflecting its name, eg:
* `falcosecurity/driverkit-builder:centos-x86_64_gcc5.8.0_gcc6.0.0-latest`
* `falcosecurity/driverkit-builder:any-x86_64_gcc12.0.0-454eff8fcc7d9abc615d312e9eccbd41abffb810`
Moreover, the new image $osname must also be added to the static map of images, kept in [builders.go source file](../pkg/driverbuilder/builder/builders.go):
```go
var images = map[string]Image{
"buster": {
GCCVersion: map[kernelrelease.Architecture][]string{
kernelrelease.ArchitectureAmd64: {"4.8", "4.9", "5", "6", "8"},
kernelrelease.ArchitectureArm64: {"4.8", "5", "6", "8"}, // 4.9 is not present on arm64
},
},
"bullseye": {
GCCVersion: map[kernelrelease.Architecture][]string{
kernelrelease.ArchitectureAmd64: {"9", "10"},
kernelrelease.ArchitectureArm64: {"9", "10"},
},
},
"bookworm": {
GCCVersion: map[kernelrelease.Architecture][]string{
kernelrelease.ArchitectureAmd64: {"11", "12"},
kernelrelease.ArchitectureArm64: {"11", "12"},
},
},
}
```
As you can see, the last part of the image tag is the real versioned tag (ie: `-latest` or `-$commithash`).
Then, the new image's shipped gcc is now available to various builder using the `defaultGCC` method's algorithm,
or chosen by each builder by implementing the `builder.GCCVersionRequestor` interface.
## Selection algorithm
Finally, the [builder](builder.md) doc file should be updated with the new available GCC (section 3.).
Once pushed, driverkit will be able to correctly load the image during startup, using [falcoctl](https://github.com/falcosecurity/falcoctl/) OCI utilities.
Then, it will map images whose target and architecture are correct for the current build, storing the provided GCCs list.
Moreover, it will also take care of only using images with correct tag (ie: `latest` or `commithash`), as requested by user or automatically set by Makefile.
The algorithm goes as follows:
* load any image for the build arch, tag and target
* load any image for the build arch, tag and "any" target
* if any of the target-specific image provides the targetGCC for the build, we are over
* if any of the "any" fallback image provides the targetGCC for the build, we are over
* else, find the image between target-specific and fallback ones, that provides nearest GCC.
In this latest step, there is no distinction between/different priority given to target specific or fallback images.
## Customize builder images repos
Moreover, users can also ship their own builder images in their own docker repositories, by using `--builderrepo` CLI option.
Instead of passing a docker repo, one can also pass the full path to a so-called builder images index yaml file.
It is mostly convenient in "static" scenarios, but it also gives the ability to freely define images name since all required infos are explicitly stated in the index file.
For an example of such a file, see [index.yaml](./index.yaml).
One can use this option multiple times; builder repos are a priority first list of docker repositories or builder images indexes (they can be mixed too!).
## Force use a builder image
Users can also force-specify the builder image to be used for the current build,
instead of relying on the internal algorithm, by using `--builderimage` CLI option.
> **NOTE**: builderimage MUST provide the selected gcc for the build
A special value for builder image is available:
* `auto:$tag`, that is used to tell driverkit to use the automatic algorithm, but forcing a certain image tag
## Force use a gcc version
Users can specify the target gcc version of the build, using `--gccversion` option.
As seen above, this needs to be a fully expanded gcc version, like `4.8.0`, or `8.0.0`.
When set, the image selection algorithm will pick the best builder image,
ie: the one that provides the nearest gcc version.
One can also play with both `--gccversion` and `--builderimage` options to enforce the
usage of a specific builder image that ships a specific gcc version.

View File

@ -9,34 +9,40 @@ driverkit
### Options
```
--architecture string target architecture for the built driver, one of [amd64,arm64] (default "amd64")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderimagebase string base docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
-h, --help help for driverkit
--kernelconfigdata string base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string log level (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
-t, --target string the system to target the build for, one of [almalinux,amazonlinux,amazonlinux2,amazonlinux2022,arch,centos,debian,fedora,flatcar,minikube,opensuse,photon,redhat,rocky,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
--architecture string target architecture for the built driver, one of [amd64,arm64] (default "amd64")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderrepo strings list of docker repositories or yaml file (absolute path) containing builder images index with the format 'images: [ { target:<target>, name:<image-name>, arch: <arch>, tag: <imagetag>, gcc_versions: [ <gcc-tag> ] },...]', in descending priority order. Used to search for builder images. eg: --builderrepo myorg/driverkit-builder --builderrepo falcosecurity/driverkit-builder --builderrepo '/path/to/my/index.yaml'. (default [docker.io/falcosecurity/driverkit-builder])
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
-h, --help help for driverkit
--kernelconfigdata string base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string set level for logs (info, warn, debug, trace) (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--registry-name string registry name to which authenticate
--registry-password string registry password
--registry-plain-http allows interacting with remote registry via plain http requests
--registry-user string registry username
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
-t, --target string the system to target the build for, one of [alinux,almalinux,amazonlinux,amazonlinux2,amazonlinux2022,amazonlinux2023,arch,bottlerocket,centos,debian,fedora,flatcar,minikube,ol,opensuse,photon,redhat,rocky,sles,talos,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
```
### SEE ALSO
* [driverkit completion](driverkit_completion.md) - Generates completion scripts.
* [driverkit docker](driverkit_docker.md) - Build Falco kernel modules and eBPF probes against a docker daemon.
* [driverkit images](driverkit_images.md) - List builder images
* [driverkit kubernetes](driverkit_kubernetes.md) - Build Falco kernel modules and eBPF probes against a Kubernetes cluster.
* [driverkit kubernetes-in-cluster](driverkit_kubernetes-in-cluster.md) - Build Falco kernel modules and eBPF probes against a Kubernetes cluster inside a Kubernetes cluster.
* [driverkit local](driverkit_local.md) - Build Falco kernel modules and eBPF probes in local env with local kernel sources and gcc/clang.

View File

@ -9,28 +9,32 @@ driverkit docker [flags]
### Options
```
--architecture string target architecture for the built driver, one of [amd64,arm64] (default "amd64")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderimagebase string base docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
-h, --help help for docker
--kernelconfigdata string base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string log level (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
-t, --target string the system to target the build for, one of [almalinux,amazonlinux,amazonlinux2,amazonlinux2022,arch,centos,debian,fedora,flatcar,minikube,opensuse,photon,redhat,rocky,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
--architecture string target architecture for the built driver, one of [amd64,arm64] (default "amd64")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderrepo strings list of docker repositories or yaml file (absolute path) containing builder images index with the format 'images: [ { target:<target>, name:<image-name>, arch: <arch>, tag: <imagetag>, gcc_versions: [ <gcc-tag> ] },...]', in descending priority order. Used to search for builder images. eg: --builderrepo myorg/driverkit-builder --builderrepo falcosecurity/driverkit-builder --builderrepo '/path/to/my/index.yaml'. (default [docker.io/falcosecurity/driverkit-builder])
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
-h, --help help for docker
--kernelconfigdata string base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string set level for logs (info, warn, debug, trace) (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--registry-name string registry name to which authenticate
--registry-password string registry password
--registry-plain-http allows interacting with remote registry via plain http requests
--registry-user string registry username
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
-t, --target string the system to target the build for, one of [alinux,almalinux,amazonlinux,amazonlinux2,amazonlinux2022,amazonlinux2023,arch,bottlerocket,centos,debian,fedora,flatcar,minikube,ol,opensuse,photon,redhat,rocky,sles,talos,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
```
### SEE ALSO

43
docs/driverkit_images.md Normal file
View File

@ -0,0 +1,43 @@
## driverkit images
List builder images
```
driverkit images [flags]
```
### Options
```
--architecture string target architecture for the built driver, one of [amd64,arm64] (default "amd64")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderrepo strings list of docker repositories or yaml file (absolute path) containing builder images index with the format 'images: [ { target:<target>, name:<image-name>, arch: <arch>, tag: <imagetag>, gcc_versions: [ <gcc-tag> ] },...]', in descending priority order. Used to search for builder images. eg: --builderrepo myorg/driverkit-builder --builderrepo falcosecurity/driverkit-builder --builderrepo '/path/to/my/index.yaml'. (default [docker.io/falcosecurity/driverkit-builder])
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
-h, --help help for images
--kernelconfigdata string base64 encoded kernel config data: in some systems it can be found under the /boot directory, in other it is gzip compressed under /proc
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string set level for logs (info, warn, debug, trace) (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--registry-name string registry name to which authenticate
--registry-password string registry password
--registry-plain-http allows interacting with remote registry via plain http requests
--registry-user string registry username
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
-t, --target string the system to target the build for, one of [alinux,almalinux,amazonlinux,amazonlinux2,amazonlinux2022,amazonlinux2023,arch,bottlerocket,centos,debian,fedora,flatcar,minikube,ol,opensuse,photon,redhat,rocky,sles,talos,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
```
### SEE ALSO
* [driverkit](driverkit.md) - A command line tool to build Falco kernel modules and eBPF probes.

View File

@ -11,7 +11,7 @@ driverkit kubernetes-in-cluster [flags]
```
--architecture string target architecture for the built driver, one of [amd64,arm64] (default "amd64")
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderimagebase string base docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderrepo strings list of docker repositories or yaml file (absolute path) containing builder images index with the format 'images: [ { target:<target>, name:<image-name>, arch: <arch>, tag: <imagetag>, gcc_versions: [ <gcc-tag> ] },...]', in descending priority order. Used to search for builder images. eg: --builderrepo myorg/driverkit-builder --builderrepo falcosecurity/driverkit-builder --builderrepo '/path/to/my/index.yaml'. (default [docker.io/falcosecurity/driverkit-builder])
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
@ -22,17 +22,21 @@ driverkit kubernetes-in-cluster [flags]
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string log level (default "info")
-l, --loglevel string set level for logs (info, warn, debug, trace) (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
-n, --namespace string If present, the namespace scope for the pods and its config (default "default")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--registry-name string registry name to which authenticate
--registry-password string registry password
--registry-plain-http allows interacting with remote registry via plain http requests
--registry-user string registry username
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
--run-as-user int Pods runner user
-t, --target string the system to target the build for, one of [almalinux,amazonlinux,amazonlinux2,amazonlinux2022,arch,centos,debian,fedora,flatcar,minikube,opensuse,photon,redhat,rocky,ubuntu,vanilla]
-t, --target string the system to target the build for, one of [alinux,almalinux,amazonlinux,amazonlinux2,amazonlinux2022,amazonlinux2023,arch,bottlerocket,centos,debian,fedora,flatcar,minikube,ol,opensuse,photon,redhat,rocky,sles,talos,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
```

View File

@ -14,7 +14,7 @@ driverkit kubernetes [flags]
--as-group stringArray group to impersonate for the operation, this flag can be repeated to specify multiple groups
--as-uid string uID to impersonate for the operation
--builderimage string docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderimagebase string base docker image to be used to build the kernel module and eBPF probe. If not provided, an automatically selected image will be used.
--builderrepo strings list of docker repositories or yaml file (absolute path) containing builder images index with the format 'images: [ { target:<target>, name:<image-name>, arch: <arch>, tag: <imagetag>, gcc_versions: [ <gcc-tag> ] },...]', in descending priority order. Used to search for builder images. eg: --builderrepo myorg/driverkit-builder --builderrepo falcosecurity/driverkit-builder --builderrepo '/path/to/my/index.yaml'. (default [docker.io/falcosecurity/driverkit-builder])
--cache-dir string default cache directory (default "$HOME/.kube/cache")
--certificate-authority string path to a cert file for the certificate authority
--client-certificate string path to a client certificate file for TLS
@ -22,6 +22,7 @@ driverkit kubernetes [flags]
--cluster string the name of the kubeconfig cluster to use
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--context string the name of the kubeconfig context to use
--disable-compression if true, opt-out of response compression for all requests to the server
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--gccversion string enforce a specific gcc version for the build
@ -33,19 +34,23 @@ driverkit kubernetes [flags]
--kernelurls strings list of kernel header urls (e.g. --kernelurls <URL1> --kernelurls <URL2> --kernelurls "<URL3>,<URL4>")
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
--kubeconfig string path to the kubeconfig file to use for CLI requests
-l, --loglevel string log level (default "info")
-l, --loglevel string set level for logs (info, warn, debug, trace) (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
-n, --namespace string If present, the namespace scope for the pods and its config (default "default")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--proxy string the proxy to use to download data
--registry-name string registry name to which authenticate
--registry-password string registry password
--registry-plain-http allows interacting with remote registry via plain http requests
--registry-user string registry username
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
--request-timeout string the length of time to wait before giving up on a single server request, non-zero values should contain a corresponding time unit (e.g, 1s, 2m, 3h), a value of zero means don't timeout requests (default "0")
--run-as-user int Pods runner user
-s, --server string the address and port of the Kubernetes API server
-t, --target string the system to target the build for, one of [almalinux,amazonlinux,amazonlinux2,amazonlinux2022,arch,centos,debian,fedora,flatcar,minikube,opensuse,photon,redhat,rocky,ubuntu,vanilla]
-t, --target string the system to target the build for, one of [alinux,almalinux,amazonlinux,amazonlinux2,amazonlinux2022,amazonlinux2023,arch,bottlerocket,centos,debian,fedora,flatcar,minikube,ol,opensuse,photon,redhat,rocky,sles,talos,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
--tls-server-name string server name to use for server certificate validation, if it is not provided, the hostname used to contact the server is used
--token string bearer token for authentication to the API server

36
docs/driverkit_local.md Normal file
View File

@ -0,0 +1,36 @@
## driverkit local
Build Falco kernel modules and eBPF probes in local env with local kernel sources and gcc/clang.
```
driverkit local [flags]
```
### Options
```
-c, --config string config file path (default $HOME/.driverkit.yaml if exists)
--dkms Enforce usage of DKMS to build the kernel module.
--download-headers Try to automatically download kernel headers.
--driverversion string driver version as a git commit hash or as a git tag (default "master")
--dryrun do not actually perform the action
--env stringToString Env variables to be enforced during the driver build. (default [])
-h, --help help for local
--kernelrelease string kernel release to build the module for, it can be found by executing 'uname -v'
--kernelversion string kernel version to build the module for, it's the numeric value after the hash when you execute 'uname -v' (default "1")
-l, --loglevel string set level for logs (info, warn, debug, trace) (default "info")
--moduledevicename string kernel module device name (the default is falco, so the device will be under /dev/falco*) (default "falco")
--moduledrivername string kernel module driver name, i.e. the name you see when you check installed modules via lsmod (default "falco")
--output-module string filepath where to save the resulting kernel module
--output-probe string filepath where to save the resulting eBPF probe
--repo-name string repository github name (default "libs")
--repo-org string repository github organization (default "falcosecurity")
--src-dir string Enforce usage of local source dir to build drivers.
-t, --target string the system to target the build for, one of [alinux,almalinux,amazonlinux,amazonlinux2,amazonlinux2022,amazonlinux2023,arch,bottlerocket,centos,debian,fedora,flatcar,minikube,ol,opensuse,photon,redhat,rocky,sles,talos,ubuntu,vanilla]
--timeout int timeout in seconds (default 120)
```
### SEE ALSO
* [driverkit](driverkit.md) - A command line tool to build Falco kernel modules and eBPF probes.

31
docs/index.yaml Normal file
View File

@ -0,0 +1,31 @@
images:
- name: docker.io/falcosecurity/driverkit-builder:any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest
target: any
arch: x86_64
tag: latest
gcc_versions:
- 8.0.0
- 6.0.0
- 5.0.0
- 4.9.0
- 4.8.0
# Name is just the image name that will be used to download the image.
# Contrarily to normal repo lister there is no constraint on it,
# since all fields are already explicitly available
- name: docker.io/foo/bar:mytag
target: arch
arch: x86_64
tag: mytag
gcc_versions:
- 13.1.1
# Image name tag ("mytag" in this case)
# is not even required to match "tag" property below,
# since the latter is used to match against the desired builder image tag for the build,
# while the former is the real image tag that will be used.
- name: docker.io/foo/baz:mytag
target: arch
arch: x86_64
tag: latest
gcc_versions:
- 13.1.1

246
go.mod
View File

@ -1,138 +1,162 @@
module github.com/falcosecurity/driverkit
go 1.18
go 1.24.1
toolchain go1.24.2
require (
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/blang/semver v3.5.1+incompatible
github.com/containerd/containerd v1.6.6 // indirect
github.com/creasty/defaults v1.6.0
github.com/docker/docker v20.10.14+incompatible
github.com/go-playground/locales v0.14.0
github.com/go-playground/universal-translator v0.18.0
github.com/go-playground/validator/v10 v10.10.1
github.com/blang/semver/v4 v4.0.0
github.com/creasty/defaults v1.7.0
github.com/docker/docker v28.3.3+incompatible
github.com/falcosecurity/falcoctl v0.11.1
github.com/go-playground/locales v0.14.1
github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.24.0
github.com/mitchellh/go-homedir v1.1.0
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.11.0
github.com/olekukonko/tablewriter v0.0.5
github.com/opencontainers/image-spec v1.1.1
github.com/pterm/pterm v0.12.80
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
github.com/spf13/viper v1.20.0
gopkg.in/yaml.v3 v3.0.1
gotest.tools v2.2.0+incompatible
k8s.io/api v0.23.6
k8s.io/apimachinery v0.23.6
k8s.io/cli-runtime v0.23.6
k8s.io/client-go v0.23.6
k8s.io/kubectl v0.23.6
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
modernc.org/sqlite v1.17.3
k8s.io/api v0.32.3
k8s.io/apimachinery v0.32.3
k8s.io/cli-runtime v0.30.0
k8s.io/client-go v0.32.3
k8s.io/kubectl v0.30.0
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
modernc.org/sqlite v1.29.9
oras.land/oras-go/v2 v2.5.0
)
require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/Microsoft/hcsshim v0.9.3 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect
github.com/containerd/cgroups v1.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/chai2010/gettext-go v1.0.3 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fvbommel/sortorder v1.0.1 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.3 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/go-archive v0.1.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/spdystream v0.5.0 // indirect
github.com/moby/sys/atomicwriter v0.1.0 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/moby/sys/user v0.4.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runc v1.1.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/russross/blackfriday v1.5.2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stretchr/testify v1.7.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
go.opencensus.io v0.23.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect
google.golang.org/grpc v1.46.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.starlark.net v0.0.0-20240507195648-35fe9f26b4bc // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.36.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/oauth2 v0.28.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/time v0.11.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gotest.tools/v3 v3.2.0 // indirect
k8s.io/component-base v0.23.6 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
lukechampine.com/uint128 v1.1.1 // indirect
modernc.org/cc/v3 v3.36.0 // indirect
modernc.org/ccgo/v3 v3.16.6 // indirect
modernc.org/libc v1.16.7 // indirect
modernc.org/mathutil v1.4.1 // indirect
modernc.org/memory v1.1.1 // indirect
modernc.org/opt v0.1.1 // indirect
modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/kustomize/api v0.10.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
gotest.tools/v3 v3.5.2 // indirect
k8s.io/component-base v0.30.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect
modernc.org/libc v1.50.5 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/kustomize/api v0.17.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.17.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

1841
go.sum

File diff suppressed because it is too large Load Diff

14
main.go
View File

@ -1,3 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (

View File

@ -0,0 +1,84 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/alinux_kernel.sh
var alinuxKernelTemplate string
//go:embed templates/alinux.sh
var alinuxTemplate string
// TargetTypeAlinux identifies the AliyunLinux 2 and 3 target.
const TargetTypeAlinux Type = "alinux"
func init() {
byTarget[TargetTypeAlinux] = &alinux{}
}
type alinuxTemplateData struct {
KernelDownloadURL string
}
type alinux struct {
}
func (c *alinux) Name() string {
return TargetTypeAlinux.String()
}
func (c *alinux) TemplateKernelUrlsScript() string {
return alinuxKernelTemplate
}
func (c *alinux) TemplateScript() string {
return alinuxTemplate
}
func (c *alinux) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchAlinuxKernelURLS(kr), nil
}
func (c *alinux) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return alinuxTemplateData{
KernelDownloadURL: urls[0],
}
}
func fetchAlinuxKernelURLS(kr kernelrelease.KernelRelease) []string {
alinuxReleases := []string{
"2",
"2.1903",
"3",
}
urls := []string{}
for _, r := range alinuxReleases {
urls = append(urls, fmt.Sprintf(
"http://mirrors.aliyun.com/alinux/%s/os/%s/Packages/kernel-devel-%s%s.rpm",
r,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
))
}
return urls
}

View File

@ -1,11 +1,29 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/almalinux_kernel.sh
var almaKernelTemplate string
//go:embed templates/almalinux.sh
var almaTemplate string
@ -13,11 +31,10 @@ var almaTemplate string
const TargetTypeAlma Type = "almalinux"
func init() {
BuilderByTarget[TargetTypeAlma] = &alma{}
byTarget[TargetTypeAlma] = &alma{}
}
type almaTemplateData struct {
commonTemplateData
KernelDownloadURL string
}
@ -29,18 +46,21 @@ func (c *alma) Name() string {
return TargetTypeAlma.String()
}
func (c *alma) TemplateKernelUrlsScript() string {
return almaKernelTemplate
}
func (c *alma) TemplateScript() string {
return almaTemplate
}
func (c *alma) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (c *alma) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchAlmaKernelURLS(kr), nil
}
func (c *alma) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (c *alma) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return almaTemplateData{
commonTemplateData: cfg.toTemplateData(c, kr),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}
@ -62,7 +82,7 @@ func fetchAlmaKernelURLS(kr kernelrelease.KernelRelease) []string {
kr.Fullversion,
kr.FullExtraversion,
))
}else{
} else {
urls = append(urls, fmt.Sprintf(
"https://repo.almalinux.org/almalinux/%s/BaseOS/%s/os/Packages/kernel-devel-%s%s.rpm",
r,

View File

@ -1,3 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
@ -8,8 +22,8 @@ import (
"database/sql"
_ "embed"
"fmt"
"github.com/blang/semver/v4"
"io"
"io/ioutil"
"log"
"net/http"
"os"
@ -18,9 +32,11 @@ import (
_ "modernc.org/sqlite"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
logger "github.com/sirupsen/logrus"
)
//go:embed templates/amazonlinux_kernel.sh
var amazonlinuxKernelTemplate string
//go:embed templates/amazonlinux.sh
var amazonlinuxTemplate string
@ -42,6 +58,13 @@ type amazonlinux2022 struct {
amazonlinux
}
type amazonlinux2023 struct {
amazonlinux
}
// TargetTypeAmazonLinux2023 identifies the AmazonLinux2023 target.
const TargetTypeAmazonLinux2023 Type = "amazonlinux2023"
// TargetTypeAmazonLinux2022 identifies the AmazonLinux2022 target.
const TargetTypeAmazonLinux2022 Type = "amazonlinux2022"
@ -52,13 +75,13 @@ const TargetTypeAmazonLinux2 Type = "amazonlinux2"
const TargetTypeAmazonLinux Type = "amazonlinux"
func init() {
BuilderByTarget[TargetTypeAmazonLinux2022] = &amazonlinux2022{}
BuilderByTarget[TargetTypeAmazonLinux2] = &amazonlinux2{}
BuilderByTarget[TargetTypeAmazonLinux] = &amazonlinux{}
byTarget[TargetTypeAmazonLinux2023] = &amazonlinux2023{}
byTarget[TargetTypeAmazonLinux2022] = &amazonlinux2022{}
byTarget[TargetTypeAmazonLinux2] = &amazonlinux2{}
byTarget[TargetTypeAmazonLinux] = &amazonlinux{}
}
type amazonlinuxTemplateData struct {
commonTemplateData
KernelDownloadURLs []string
}
@ -66,17 +89,18 @@ func (a *amazonlinux) Name() string {
return TargetTypeAmazonLinux.String()
}
func (a *amazonlinux) TemplateKernelUrlsScript() string { return amazonlinuxKernelTemplate }
func (a *amazonlinux) TemplateScript() string {
return amazonlinuxTemplate
}
func (a *amazonlinux) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (a *amazonlinux) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchAmazonLinuxPackagesURLs(a, kr)
}
func (a *amazonlinux) TemplateData(c Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (a *amazonlinux) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return amazonlinuxTemplateData{
commonTemplateData: c.toTemplateData(a, kr),
KernelDownloadURLs: urls,
}
}
@ -106,7 +130,7 @@ func (a *amazonlinux2022) Name() string {
return TargetTypeAmazonLinux2022.String()
}
func (a *amazonlinux2022) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (a *amazonlinux2022) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchAmazonLinuxPackagesURLs(a, kr)
}
@ -125,20 +149,51 @@ func (a *amazonlinux2022) ext() string {
return "gz"
}
func (a *amazonlinux2023) Name() string {
return TargetTypeAmazonLinux2023.String()
}
func (a *amazonlinux2023) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchAmazonLinuxPackagesURLs(a, kr)
}
func (a *amazonlinux2023) repos() []string {
return []string{
"latest",
}
}
func (a *amazonlinux2023) baseUrl() string {
return "https://cdn.amazonlinux.com/al2023/core/mirrors"
}
func (a *amazonlinux2023) ext() string {
return "gz"
}
func (a *amazonlinux2) Name() string {
return TargetTypeAmazonLinux2.String()
}
func (a *amazonlinux2) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (a *amazonlinux2) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchAmazonLinuxPackagesURLs(a, kr)
}
func (a *amazonlinux2) GCCVersion(kr kernelrelease.KernelRelease) semver.Version {
// 5.10 amazonlinux2 kernels need gcc 10
if kr.Major == 5 && kr.Minor == 10 {
return semver.Version{Major: 10}
}
return semver.Version{}
}
func (a *amazonlinux2) repos() []string {
return []string{
"core/2.0",
"core/latest",
"extras/kernel-5.4/latest",
"extras/kernel-5.10/latest",
"extras/kernel-5.15/latest",
}
}
@ -155,16 +210,13 @@ func buildMirror(a amazonBuilder, r string, kv kernelrelease.KernelRelease) (str
switch a.(type) {
case *amazonlinux:
baseURL = fmt.Sprintf("%s/%s", a.baseUrl(), r)
case *amazonlinux2:
baseURL = fmt.Sprintf("%s/%s/%s", a.baseUrl(), r, kv.Architecture.ToNonDeb())
case *amazonlinux2022:
case *amazonlinux2, *amazonlinux2022, *amazonlinux2023:
baseURL = fmt.Sprintf("%s/%s/%s", a.baseUrl(), r, kv.Architecture.ToNonDeb())
default:
return "", fmt.Errorf("unsupported target")
}
mirror := fmt.Sprintf("%s/%s", baseURL, "mirror.list")
logger.WithField("url", mirror).WithField("version", r).Debug("looking for repo...")
return mirror, nil
}
@ -185,89 +237,89 @@ func fetchAmazonLinuxPackagesURLs(a amazonBuilder, kv kernelrelease.KernelReleas
visited := make(map[string]struct{})
for _, v := range a.repos() {
mirror, err := buildMirror(a, v, kv)
if err != nil {
return nil, err
}
// Obtain the repo URL by getting mirror URL content
mirrorRes, err := http.Get(mirror)
if err != nil {
return nil, err
}
defer mirrorRes.Body.Close()
var repo string
scanner := bufio.NewScanner(mirrorRes.Body)
if scanner.Scan() {
repo = scanner.Text()
}
if repo == "" {
return nil, fmt.Errorf("repository not found")
}
repo = strings.ReplaceAll(strings.TrimSuffix(repo, "\n"), "$basearch", kv.Architecture.ToNonDeb())
repo = strings.TrimSuffix(repo, "/")
repoDatabaseURL := fmt.Sprintf("%s/repodata/primary.sqlite.%s", repo, a.ext())
if _, ok := visited[repoDatabaseURL]; ok {
continue
}
// Download the repo database
repoRes, err := http.Get(repoDatabaseURL)
logger.WithField("url", repoDatabaseURL).Debug("downloading...")
if err != nil {
return nil, err
}
defer repoRes.Body.Close()
visited[repoDatabaseURL] = struct{}{}
unzip, err := unzipFuncFromBuilder(a)
if err != nil {
return nil, err
}
dbBytes, err := unzip(repoRes.Body)
if err != nil {
return nil, err
}
// Create the temporary database file
dbFile, err := ioutil.TempFile(os.TempDir(), fmt.Sprintf("%s-*.sqlite", a.Name()))
if err != nil {
return nil, err
}
defer os.Remove(dbFile.Name())
if _, err := dbFile.Write(dbBytes); err != nil {
return nil, err
}
// Open the database
db, err := sql.Open("sqlite", dbFile.Name())
if err != nil {
return nil, err
}
defer db.Close()
logger.WithField("db", dbFile.Name()).Debug("connecting to database...")
// Query the database
rel := strings.TrimPrefix(strings.TrimSuffix(kv.FullExtraversion, fmt.Sprintf(".%s", kv.Architecture.ToNonDeb())), "-")
q := fmt.Sprintf("SELECT location_href FROM packages WHERE name LIKE 'kernel-devel%%' AND version='%s' AND release='%s'", kv.Fullversion, rel)
stmt, err := db.Prepare(q)
if err != nil {
return nil, err
}
defer stmt.Close()
rows, err := stmt.Query()
if err != nil {
return nil, err
}
defer rows.Close()
for rows.Next() {
var href string
err = rows.Scan(&href)
err := func() error {
mirror, err := buildMirror(a, v, kv)
if err != nil {
log.Fatal(err)
return err
}
urls = append(urls, fmt.Sprintf("%s/%s", repo, href))
}
if err := dbFile.Close(); err != nil {
// Obtain the repo URL by getting mirror URL content
mirrorRes, err := http.Get(mirror)
if err != nil {
return err
}
defer mirrorRes.Body.Close()
var repo string
scanner := bufio.NewScanner(mirrorRes.Body)
if scanner.Scan() {
repo = scanner.Text()
}
if repo == "" {
return fmt.Errorf("repository not found")
}
repo = strings.ReplaceAll(strings.TrimSuffix(repo, "\n"), "$basearch", kv.Architecture.ToNonDeb())
repo = strings.TrimSuffix(repo, "/")
repoDatabaseURL := fmt.Sprintf("%s/repodata/primary.sqlite.%s", repo, a.ext())
if _, ok := visited[repoDatabaseURL]; ok {
return nil
}
// Download the repo database
repoRes, err := http.Get(repoDatabaseURL)
if err != nil {
return err
}
defer repoRes.Body.Close()
visited[repoDatabaseURL] = struct{}{}
unzip, err := unzipFuncFromBuilder(a)
if err != nil {
return err
}
dbBytes, err := unzip(repoRes.Body)
if err != nil {
return err
}
// Create the temporary database file
dbFile, err := os.CreateTemp(os.TempDir(), fmt.Sprintf("%s-*.sqlite", a.Name()))
if err != nil {
return err
}
defer os.Remove(dbFile.Name())
if _, err := dbFile.Write(dbBytes); err != nil {
return err
}
// Open the database
db, err := sql.Open("sqlite", dbFile.Name())
if err != nil {
return err
}
defer db.Close()
// Query the database
rel := strings.TrimPrefix(strings.TrimSuffix(kv.FullExtraversion, fmt.Sprintf(".%s", kv.Architecture.ToNonDeb())), "-")
q := fmt.Sprintf("SELECT location_href FROM packages WHERE name LIKE 'kernel-devel%%' AND version='%s' AND release='%s'", kv.Fullversion, rel)
stmt, err := db.Prepare(q)
if err != nil {
return err
}
defer stmt.Close()
rows, err := stmt.Query()
if err != nil {
return err
}
defer rows.Close()
for rows.Next() {
var href string
err = rows.Scan(&href)
if err != nil {
log.Fatal(err)
}
urls = append(urls, fmt.Sprintf("%s/%s", repo, href))
}
return dbFile.Close()
}()
if err != nil {
return nil, err
}

View File

@ -1,3 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
@ -8,6 +22,9 @@ import (
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/archlinux_kernel.sh
var archlinuxKernelTemplate string
//go:embed templates/archlinux.sh
var archlinuxTemplate string
@ -15,7 +32,7 @@ var archlinuxTemplate string
const TargetTypeArchlinux Type = "arch"
func init() {
BuilderByTarget[TargetTypeArchlinux] = &archlinux{}
byTarget[TargetTypeArchlinux] = &archlinux{}
}
// archlinux is a driverkit target.
@ -23,7 +40,6 @@ type archlinux struct {
}
type archlinuxTemplateData struct {
commonTemplateData
KernelDownloadURL string
}
@ -31,11 +47,19 @@ func (c *archlinux) Name() string {
return TargetTypeArchlinux.String()
}
func (c *archlinux) TemplateKernelUrlsScript() string { return archlinuxKernelTemplate }
func (c *archlinux) TemplateScript() string {
return archlinuxTemplate
}
func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (c *archlinux) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
// uname -r returns "6.8.1-arch1-1" but headers URL is "6.8.1.arch1-1"
// Also, for 0-patch releases, like: "6.8.0-arch1-1", headers url is "6.8.arch1-1"
kr.FullExtraversion = strings.Replace(kr.FullExtraversion, "-arch", ".arch", 1)
if kr.Patch == 0 {
kr.Fullversion = strings.TrimSuffix(kr.Fullversion, ".0")
}
urls := []string{}
possibleCompressionSuffixes := []string{
@ -51,10 +75,10 @@ func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string,
urls = append(
urls,
fmt.Sprintf(
"%s/linux-headers-%s%s-%s.pkg.tar.%s",
"%s/linux-headers-%s-%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.String(),
kr.KernelVersion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
@ -66,10 +90,10 @@ func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string,
urls = append(
urls,
fmt.Sprintf(
"%s/linux-hardened-headers-%s%s-%s.pkg.tar.%s",
"%s/linux-hardened-headers-%s-%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.String(),
kr.KernelVersion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
@ -81,10 +105,10 @@ func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string,
urls = append(
urls,
fmt.Sprintf(
"%s/linux-zen-headers-%s%s-%s.pkg.tar.%s",
"%s/linux-zen-headers-%s-%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.String(),
kr.KernelVersion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
@ -96,10 +120,10 @@ func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string,
urls = append(
urls,
fmt.Sprintf(
"%s/linux-lts-headers-%s%s-%s.pkg.tar.%s",
"%s/linux-lts-headers-%s-%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.String(),
kr.KernelVersion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
@ -107,15 +131,15 @@ func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string,
}
}
} else if kr.Architecture.ToNonDeb() == "aarch64" {
baseURL := "http://tardis.tiny-vps.com/aarm/packages/l/linux-aarch64-headers/"
baseURL := "https://alaa.ad24.cz/packages/l/linux-aarch64-headers/"
for _, compressionAlgo := range possibleCompressionSuffixes {
urls = append(
urls,
fmt.Sprintf(
"%s/linux-aarch64-headers-%s%s-%s.pkg.tar.%s",
"%s/linux-aarch64-headers-%s-%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.String(),
kr.KernelVersion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
@ -126,9 +150,8 @@ func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string,
return urls, nil
}
func (c *archlinux) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (c *archlinux) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return archlinuxTemplateData{
commonTemplateData: cfg.toTemplateData(c, kr),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}

View File

@ -1,3 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
@ -8,7 +22,7 @@ import (
const TargetTypeBottlerocket Type = "bottlerocket"
func init() {
BuilderByTarget[TargetTypeBottlerocket] = &bottlerocket{
byTarget[TargetTypeBottlerocket] = &bottlerocket{
vanilla{},
}
}
@ -21,9 +35,8 @@ func (b *bottlerocket) Name() string {
return TargetTypeBottlerocket.String()
}
func (b *bottlerocket) TemplateData(c Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (b *bottlerocket) KernelTemplateData(kr kernelrelease.KernelRelease, urls []string) interface{} {
return vanillaTemplateData{
commonTemplateData: c.toTemplateData(b, kr),
KernelDownloadURL: urls[0],
KernelLocalVersion: kr.FullExtraversion,
}

View File

@ -1,33 +1,63 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"context"
"fmt"
"github.com/falcosecurity/falcoctl/pkg/output"
"strings"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"oras.land/oras-go/v2/registry/remote/auth"
)
var defaultImageTag = "latest" // This is overwritten when using the Makefile to build
// Build contains the info about the on-going build.
type Build struct {
TargetType Type
KernelConfigData string
KernelRelease string
KernelVersion string
DriverVersion string
Architecture string
ModuleFilePath string
ProbeFilePath string
ModuleDriverName string
ModuleDeviceName string
CustomBuilderImage string
CustomBuilderImageBase string
KernelUrls []string
GCCVersion string
RepoOrg string
RepoName string
TargetType Type
KernelConfigData string
KernelRelease string
KernelVersion string
DriverVersion string
Architecture string
ModuleFilePath string
ProbeFilePath string
ModuleDriverName string
ModuleDeviceName string
BuilderImage string
BuilderRepos []string
ImagesListers []ImagesLister
KernelUrls []string
GCCVersion string
RepoOrg string
RepoName string
Images ImagesMap
RegistryName string
RegistryUser string
RegistryPassword string
RegistryPlainHTTP bool
*output.Printer
}
func (b *Build) KernelReleaseFromBuildConfig() kernelrelease.KernelRelease {
kv := kernelrelease.FromString(b.KernelRelease)
kv.Architecture = kernelrelease.Architecture(b.Architecture)
kv.KernelVersion = b.KernelVersion
return kv
}
@ -43,3 +73,41 @@ func (b *Build) ToConfig() Config {
Build: b,
}
}
// hasCustomBuilderImage return true if a custom builder image has been set by the user.
func (b *Build) hasCustomBuilderImage() bool {
if len(b.BuilderImage) > 0 {
customNames := strings.Split(b.BuilderImage, ":")
return customNames[0] != "auto"
}
return false
}
// builderImageTag returns the tag(latest, master or hash) to be used for the builder image.
func (b *Build) builderImageTag() string {
if len(b.BuilderImage) > 0 {
customNames := strings.Split(b.BuilderImage, ":")
// Updated image tag if "auto:tag" is passed
if len(customNames) > 1 {
return customNames[1]
}
}
return defaultImageTag
}
func (b *Build) ClientForRegistry(registry string) *auth.Client {
client := auth.DefaultClient
client.SetUserAgent("driverkit")
client.Credential = func(ctx context.Context, reg string) (auth.Credential, error) {
if b.RegistryName == registry {
return auth.Credential{
Username: b.RegistryUser,
Password: b.RegistryPassword,
}, nil
}
return auth.EmptyCredential, nil
}
return client
}

View File

@ -1,37 +1,58 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"bytes"
_ "embed"
"errors"
"fmt"
"github.com/blang/semver"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"log"
"github.com/falcosecurity/falcoctl/pkg/output"
"net/http"
"net/url"
"path"
"strings"
"text/template"
logger "github.com/sirupsen/logrus"
"github.com/blang/semver/v4"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
var BaseImage = "placeholder" // This is overwritten when using the Makefile to build
// DriverDirectory is the directory the processor uses to store the driver.
const DriverDirectory = "/tmp/driver"
const (
DriverDirectory = "/tmp/driver"
cmakeCmdFmt = `cmake -Wno-dev \
-DUSE_BUNDLED_DEPS=On \
-DCREATE_TEST_TARGETS=Off \
-DBUILD_LIBSCAP_GVISOR=Off \
-DBUILD_LIBSCAP_MODERN_BPF=Off \
-DENABLE_DRIVERS_TESTS=Off \
-DDRIVER_NAME=%s \
-DPROBE_NAME=%s \
-DBUILD_BPF=On \
-DDRIVER_VERSION=%s \
-DPROBE_VERSION=%s \
-DGIT_COMMIT=%s \
-DDRIVER_DEVICE_NAME=%s \
-DPROBE_DEVICE_NAME=%s \
.. && \
sed -i s/'DRIVER_COMMIT ""'/'DRIVER_COMMIT "%s"'/g driver/src/driver_config.h`
)
// ModuleFileName is the standard file name for the kernel module.
const ModuleFileName = "module.ko"
// ProbeFileName is the standard file name for the eBPF probe.
const ProbeFileName = "probe.o"
// ModuleFullPath is the standard path for the kernel module. Builders must place the compiled module at this location.
var ModuleFullPath = path.Join(DriverDirectory, ModuleFileName)
// ProbeFullPath is the standard path for the eBPF probe. Builders must place the compiled probe at this location.
var ProbeFullPath = path.Join(DriverDirectory, "bpf", ProbeFileName)
//go:embed templates/libs_download.sh
var libsDownloadTemplate string
var HeadersNotFoundErr = errors.New("kernel headers not found")
@ -43,45 +64,92 @@ type Config struct {
*Build
}
func (c Config) ToDriverFullPath() string {
return path.Join(DriverDirectory, "build", "driver", fmt.Sprintf("%s.ko", c.DriverName))
}
func (c Config) ToProbeFullPath() string {
return path.Join(DriverDirectory, "build", "driver", "bpf", "probe.o")
}
type commonTemplateData struct {
DriverBuildDir string
ModuleDownloadURL string
ModuleDriverName string
ModuleFullPath string
BuildModule bool
BuildProbe bool
GCCVersion string
DriverBuildDir string
ModuleDriverName string
ModuleFullPath string
BuildModule bool
BuildProbe bool
GCCVersion string
CmakeCmd string
}
// Builder represents a builder capable of generating a script for a driverkit target.
type Builder interface {
Name() string
TemplateKernelUrlsScript() string
TemplateScript() string
URLs(c Config, kr kernelrelease.KernelRelease) ([]string, error)
TemplateData(c Config, kr kernelrelease.KernelRelease, urls []string) interface{} // error return type is managed
URLs(kr kernelrelease.KernelRelease) ([]string, error)
KernelTemplateData(kr kernelrelease.KernelRelease, urls []string) interface{} // error return type is managed
}
// MinimumURLsBuilder is an optional interface
// MinimumURLsBuilder is an optional interface implemented by builders
// to specify minimum number of requested headers urls
type MinimumURLsBuilder interface {
MinimumURLs() int
}
func Script(b Builder, c Config, kr kernelrelease.KernelRelease) (string, error) {
t := template.New(b.Name())
parsed, err := t.Parse(b.TemplateScript())
// TemplateDataSpecifier is an optional interface implemented by builders
// to specify a custom template data instead of the default one.
type TemplateDataSpecifier interface {
TemplateData(c Config, kr kernelrelease.KernelRelease) interface{}
}
type libsDownloadTemplateData struct {
DriverBuildDir string
ModuleDownloadURL string
}
// LibsDownloadScript returns the script that downloads and configures libs repo at requested commit/tag
func LibsDownloadScript(c Config) (string, error) {
t := template.New("download-libs")
parsed, err := t.Parse(libsDownloadTemplate)
if err != nil {
return "", err
}
td := libsDownloadTemplateData{
DriverBuildDir: DriverDirectory,
ModuleDownloadURL: fmt.Sprintf("%s/%s.tar.gz", c.DownloadBaseURL, c.DriverVersion),
}
buf := bytes.NewBuffer(nil)
err = parsed.Execute(buf, td)
if err != nil {
return "", err
}
return buf.String(), nil
}
// KernelDownloadScript returns the script that will download and extract kernel headers
func KernelDownloadScript(b Builder,
kernelurls []string,
kr kernelrelease.KernelRelease,
printer *output.Printer,
) (string, error) {
t := template.New("download-kernel")
parsed, err := t.Parse(b.TemplateKernelUrlsScript())
if err != nil {
return "", err
}
var urls []string
minimumURLs := 1
if bb, ok := b.(MinimumURLsBuilder); ok {
minimumURLs = bb.MinimumURLs()
}
var urls []string
if c.KernelUrls == nil {
urls, err = b.URLs(c, kr)
if kernelurls == nil {
urls, err = b.URLs(kr)
if err != nil {
return "", err
}
@ -89,10 +157,10 @@ func Script(b Builder, c Config, kr kernelrelease.KernelRelease) (string, error)
// Otherwise, it is up to the builder to return an error
if len(urls) > 0 {
// Check (and filter) existing kernels before continuing
urls, err = getResolvingURLs(urls)
urls, err = GetResolvingURLs(urls)
}
} else {
urls, err = getResolvingURLs(c.KernelUrls)
urls, err = GetResolvingURLs(kernelurls)
}
if err != nil {
return "", err
@ -102,7 +170,10 @@ func Script(b Builder, c Config, kr kernelrelease.KernelRelease) (string, error)
return "", fmt.Errorf("not enough headers packages found; expected %d, found %d", minimumURLs, len(urls))
}
td := b.TemplateData(c, kr, urls)
printer.Logger.Debug("kernel headers found",
printer.Logger.Args("urls", urls))
td := b.KernelTemplateData(kr, urls)
if tdErr, ok := td.(error); ok {
return "", tdErr
}
@ -112,47 +183,52 @@ func Script(b Builder, c Config, kr kernelrelease.KernelRelease) (string, error)
if err != nil {
return "", err
}
return buf.String(), nil
}
// Script retrieves the actually drivers building script
func Script(b Builder, c Config, kr kernelrelease.KernelRelease) (string, error) {
t := template.New(b.Name())
parsed, err := t.Parse(b.TemplateScript())
if err != nil {
return "", err
}
var td interface{}
if bb, ok := b.(TemplateDataSpecifier); ok {
td = bb.TemplateData(c, kr)
} else {
td = c.toTemplateData(b, kr)
}
buf := bytes.NewBuffer(nil)
err = parsed.Execute(buf, td)
if err != nil {
return "", err
}
return buf.String(), nil
}
type GCCVersionRequestor interface {
// GCCVersion returns the GCC version to be used.
// If the returned value is empty, the default algorithm will be enforced.
GCCVersion(kr kernelrelease.KernelRelease) semver.Version
}
type Image struct {
GCCVersion map[kernelrelease.Architecture][]string
}
// We cannot use semver.Version here, because we need to know the
// actual gcc-$version string that will be used by template scripts,
// like: make CC=/usr/bin/gcc-{{ .GCCVersion }}
// When using semver.Version, gcc like semver.Version { Major: 5 }.String() -> "5.0.0"
// and that would break our scripts, because the real name is just "5"
var images = map[string]Image{
"buster": {
GCCVersion: map[kernelrelease.Architecture][]string{
kernelrelease.ArchitectureAmd64: {"4.8", "4.9", "5", "6", "8"},
kernelrelease.ArchitectureArm64: {"4.8", "5", "6", "8"}, // 4.9 is not present on arm64
},
},
"bullseye": {
GCCVersion: map[kernelrelease.Architecture][]string{
kernelrelease.ArchitectureAmd64: {"9", "10"},
kernelrelease.ArchitectureArm64: {"9", "10"},
},
},
"bookworm": {
GCCVersion: map[kernelrelease.Architecture][]string{
kernelrelease.ArchitectureAmd64: {"11", "12"},
kernelrelease.ArchitectureArm64: {"11", "12"},
},
},
}
func defaultGCC(kr kernelrelease.KernelRelease) semver.Version {
switch kr.Major {
case 6:
if kr.Minor >= 9 {
return semver.Version{Major: 14}
}
if kr.Minor >= 5 {
return semver.Version{Major: 13}
}
return semver.Version{Major: 12}
case 5:
if kr.Minor >= 18 {
if kr.Minor >= 15 {
return semver.Version{Major: 12}
}
return semver.Version{Major: 11}
@ -166,7 +242,7 @@ func defaultGCC(kr kernelrelease.KernelRelease) semver.Version {
case 2:
return semver.Version{Major: 4, Minor: 8}
default:
return semver.Version{Major: 12}
return semver.Version{Major: 14}
}
}
@ -178,36 +254,16 @@ func mustParseTolerant(gccStr string) semver.Version {
return g
}
// Simple algorithm:
// sort versions passed as first params,
// then, find the higher gcc version which is also lower than target.
// Moreover, try harder to keep same major gcc version.
func findNearestGCCVersion(gccs []semver.Version, target semver.Version) semver.Version {
semver.Sort(gccs)
foundGCC := gccs[0]
for _, gcc := range gccs {
if gcc.GT(target) {
// Be smarter trying to find the proper gcc version
if gcc.Major == target.Major && foundGCC.Major < target.Major {
foundGCC = gcc
}
break
}
foundGCC = gcc
}
return foundGCC
}
// Given an image, returns the list of semvers for its supported gccs
func buildGCCSemvers(img Image, arch kernelrelease.Architecture) []semver.Version {
gccs := make([]semver.Version, 0)
for _, gccStr := range img.GCCVersion[arch] {
gccs = append(gccs, mustParseTolerant(gccStr))
}
return gccs
}
// Algorithm.
// * always load images (note that it loads only images that provide gccversion, if set by user)
// * if user set a fixed gccversion, we are good to go
// * otherwise, try to fix the best-match gcc version provided by any of the loaded images;
// see below for algorithm explanation
func (b *Build) setGCCVersion(builder Builder, kr kernelrelease.KernelRelease) {
if !b.hasCustomBuilderImage() {
b.LoadImages()
}
if len(b.GCCVersion) > 0 {
// If set from user, go on
return
@ -222,127 +278,138 @@ func (b *Build) setGCCVersion(builder Builder, kr kernelrelease.KernelRelease) {
var targetGCC semver.Version
if bb, ok := builder.(GCCVersionRequestor); ok {
targetGCC = bb.GCCVersion(kr)
} else {
}
// If builder implements GCCVersionRequestor but returns an empty semver.Version
// it means that it does not want to manage this kernelrelease,
// and instead wants to fallback to default algorithm
if targetGCC.EQ(semver.Version{}) {
targetGCC = defaultGCC(kr)
}
// Build the list of "proposed" GCC versions,
// that is, the nearest-to-target GCC version
// for each builder image.
proposedGCCs := make([]semver.Version, 0)
for name, img := range images {
gccs := buildGCCSemvers(img, kr.Architecture)
foundGCC := findNearestGCCVersion(gccs, targetGCC)
proposedGCCs = append(proposedGCCs, foundGCC)
logger.WithField("image", name).
WithField("targetGCC", targetGCC.String()).
Debug("proposedGCC=", foundGCC.String())
if b.hasCustomBuilderImage() {
b.GCCVersion = targetGCC.String()
return
}
// Now, find the nearest-to-target GCC version
// from the proposed GCCs from the builder images.
foundGCC := findNearestGCCVersion(proposedGCCs, targetGCC)
// Finally, discover the right gcc version string
// for the final GCC that will be used by scripts.
for _, img := range images {
for _, gccStr := range img.GCCVersion[kr.Architecture] {
gccSemVer := mustParseTolerant(gccStr)
if gccSemVer.EQ(foundGCC) {
b.GCCVersion = gccStr
}
// Step 1:
// If we are able to either find a specific-target image,
// or "any" target image that provide desired gcc,
// we are over.
image, ok := b.Images.findImage(b.TargetType, targetGCC)
if ok {
b.GCCVersion = image.GCCVersion.String()
} else {
// Step 2:
// Build the list of "proposed" GCC versions,
// that is, the list of available gccs from images
// for each builder image
proposedGCCs := make([]semver.Version, 0)
for _, img := range b.Images {
proposedGCCs = append(proposedGCCs, img.GCCVersion)
b.Logger.Debug("proposed GCC",
b.Logger.Args("image", img.Name,
"targetGCC", targetGCC.String(),
"proposedGCC", img.GCCVersion.String()))
}
}
logger.WithField("targetGCC", targetGCC.String()).
Debug("foundGCC=", b.GCCVersion)
// Now, sort versions and fetch
// the nearest gcc, that is also < targetGCC
semver.Sort(proposedGCCs)
lastGCC := proposedGCCs[0]
for _, gcc := range proposedGCCs {
if gcc.GT(targetGCC) {
break
}
lastGCC = gcc
}
b.GCCVersion = lastGCC.String()
}
b.Logger.Debug("found GCC",
b.Logger.Args("targetGCC", targetGCC.String(), "version", b.GCCVersion))
}
type BuilderImageNetworkMode interface {
// sets the network mode of the builder image, allows individual builders to override
BuilderImageNetMode() string
}
func (b *Build) GetBuilderImage() string {
var imageTag string
// One can pass "auto:tag/latest" to choose the automatic
// image selection but forcing an imagetag
if len(b.CustomBuilderImage) > 0 {
customNames := strings.Split(b.CustomBuilderImage, ":")
if customNames[0] != "auto" {
// CustomBuilderImage MUST have requested GCC installed inside
return b.CustomBuilderImage
}
// Updated image tag if "auto:tag" is passed
if len(customNames) > 1 {
imageTag = customNames[1]
} else {
imageTag = "latest"
}
if b.hasCustomBuilderImage() {
// BuilderImage MUST have requested GCC installed inside
return b.BuilderImage
}
// A bit complicated because we must check that
// "auto:tag" custom builder image was not passed
var builderImage string
if len(b.CustomBuilderImageBase) != 0 {
builderImage = b.CustomBuilderImageBase
} else {
builderImage = BaseImage
}
names := strings.Split(builderImage, ":")
// Updated image tag if no "auto" custom builder image was passed
if imageTag == "" {
if len(names) > 1 {
imageTag = names[1]
} else {
imageTag = "latest"
}
}
for name, img := range images {
for _, gccStr := range img.GCCVersion[kernelrelease.Architecture(b.Architecture)] {
if gccStr == b.GCCVersion {
return names[0] + "_" + name + ":" + imageTag
}
}
}
return builderImage
// NOTE: here below we are already sure that we are going
// to find an image, because setGCCVersion()
// has already set an existent gcc version
// (ie: one provided by an image) for us
image, _ := b.Images.findImage(b.TargetType, mustParseTolerant(b.GCCVersion))
return image.Name
}
// Factory returns a builder for the given target.
func Factory(target Type) (Builder, error) {
b, ok := BuilderByTarget[target]
// Workaround for "local" target (that is not exposed to users,
// nor registered in byTarget map)".
if target.String() == "local" {
return &LocalBuilder{}, nil
}
// Driverkit builder is named "ubuntu"; there is no ubuntu-foo
if strings.HasPrefix(target.String(), "ubuntu") {
target = Type("ubuntu")
}
b, ok := byTarget[target]
if !ok {
return nil, fmt.Errorf("no builder found for target: %s", target)
}
return b, nil
}
// Targets returns the list of all the supported targets.
func Targets() []string {
res := []string{}
for k := range byTarget {
res = append(res, k.String())
}
return res
}
func (c Config) toTemplateData(b Builder, kr kernelrelease.KernelRelease) commonTemplateData {
c.setGCCVersion(b, kr)
return commonTemplateData{
DriverBuildDir: DriverDirectory,
ModuleDownloadURL: fmt.Sprintf("%s/%s.tar.gz", c.DownloadBaseURL, c.DriverVersion),
ModuleDriverName: c.DriverName,
ModuleFullPath: ModuleFullPath,
BuildModule: len(c.ModuleFilePath) > 0,
BuildProbe: len(c.ProbeFilePath) > 0,
GCCVersion: c.GCCVersion,
DriverBuildDir: DriverDirectory,
ModuleDriverName: c.DriverName,
ModuleFullPath: c.ToDriverFullPath(),
BuildModule: len(c.ModuleFilePath) > 0,
BuildProbe: len(c.ProbeFilePath) > 0,
GCCVersion: c.GCCVersion,
CmakeCmd: fmt.Sprintf(cmakeCmdFmt,
c.DriverName,
c.DriverName,
c.DriverVersion,
c.DriverVersion,
c.DriverVersion,
c.DeviceName,
c.DeviceName,
c.DriverVersion),
}
}
func resolveURLReference(u string) string {
uu, err := url.Parse(u)
if err != nil {
log.Fatal(err)
panic(err)
}
base, err := url.Parse(uu.Host)
if err != nil {
log.Fatal(err)
panic(err)
}
return base.ResolveReference(uu).String()
}
func getResolvingURLs(urls []string) ([]string, error) {
func GetResolvingURLs(urls []string) ([]string, error) {
var results []string
for _, u := range urls {
// in case url has some relative paths
@ -357,7 +424,6 @@ func getResolvingURLs(urls []string) ([]string, error) {
}
if res.StatusCode == http.StatusOK {
results = append(results, u)
logger.WithField("url", u).Debug("kernel header url found")
}
}
if len(results) == 0 {

View File

@ -1,9 +1,24 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"github.com/blang/semver"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"testing"
"github.com/blang/semver/v4"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
var gccTests = []struct {
@ -39,7 +54,7 @@ var gccTests = []struct {
Architecture: kernelrelease.ArchitectureAmd64,
},
expectedGCC: semver.Version{
Major: 11,
Major: 12,
},
},
{

View File

@ -1,11 +1,30 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"github.com/blang/semver/v4"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/centos_kernel.sh
var centosKernelTemplate string
//go:embed templates/centos.sh
var centosTemplate string
@ -13,7 +32,7 @@ var centosTemplate string
const TargetTypeCentos Type = "centos"
func init() {
BuilderByTarget[TargetTypeCentos] = &centos{}
byTarget[TargetTypeCentos] = &centos{}
}
// centos is a driverkit target.
@ -21,7 +40,6 @@ type centos struct {
}
type centosTemplateData struct {
commonTemplateData
KernelDownloadURL string
}
@ -29,11 +47,13 @@ func (c *centos) Name() string {
return TargetTypeCentos.String()
}
func (c *centos) TemplateKernelUrlsScript() string { return centosKernelTemplate }
func (c *centos) TemplateScript() string {
return centosTemplate
}
func (c *centos) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (c *centos) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
vaultReleases := []string{
"6.0/os",
"6.0/updates",
@ -160,9 +180,21 @@ func (c *centos) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error
return urls, nil
}
func (c *centos) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (c *centos) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return centosTemplateData{
commonTemplateData: cfg.toTemplateData(c, kr),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}
func (c *centos) GCCVersion(kr kernelrelease.KernelRelease) semver.Version {
// 4.18+ centos 8 kernels need gcc 9
if kr.Major == 4 && kr.Minor >= 18 {
return semver.Version{Major: 9}
}
// 3.10.X kernels need 4.8.5 gcc version; see:
// https://github.com/falcosecurity/driverkit/issues/236
if kr.Major == 3 && kr.Minor == 10 {
return semver.Version{Major: 4, Minor: 8, Patch: 5}
}
return semver.Version{}
}

View File

@ -1,15 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"io"
"io/ioutil"
"net/http"
"regexp"
"strings"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/debian_kernel.sh
var debianKernelTemplate string
//go:embed templates/debian.sh
var debianTemplate string
@ -23,11 +42,10 @@ const TargetTypeDebian Type = "debian"
const debianRequiredURLs = 3
func init() {
BuilderByTarget[TargetTypeDebian] = &debian{}
byTarget[TargetTypeDebian] = &debian{}
}
type debianTemplateData struct {
commonTemplateData
KernelDownloadURLS []string
KernelLocalVersion string
KernelHeadersPattern string
@ -41,24 +59,27 @@ func (v *debian) Name() string {
return TargetTypeDebian.String()
}
func (v *debian) TemplateKernelUrlsScript() string { return debianKernelTemplate }
func (v *debian) TemplateScript() string {
return debianTemplate
}
func (v *debian) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (v *debian) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchDebianKernelURLs(kr)
}
func (v *debian) TemplateData(c Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (v *debian) KernelTemplateData(kr kernelrelease.KernelRelease, urls []string) interface{} {
var KernelHeadersPattern string
if strings.HasSuffix(kr.Extraversion, "pve") {
KernelHeadersPattern = "linux-headers-*pve"
} else if strings.Contains(kr.FullExtraversion, "rpi") {
KernelHeadersPattern = "linux-headers-*-rpi-v*"
} else {
KernelHeadersPattern = "linux-headers-*" + kr.Architecture.String()
}
return debianTemplateData{
commonTemplateData: c.toTemplateData(v, kr),
KernelDownloadURLS: urls,
KernelLocalVersion: kr.FullExtraversion,
KernelHeadersPattern: KernelHeadersPattern,
@ -114,9 +135,18 @@ func fetchDebianHeadersURLFromRelease(baseURL string, kr kernelrelease.KernelRel
matchExtraGroupCommon := "common"
// match for kernel versions like 4.19.0-6-cloud-amd64
if strings.Contains(kr.FullExtraversion, "-cloud") {
extraVersionPartial = strings.TrimSuffix(extraVersionPartial, "-cloud")
matchExtraGroup = "cloud-" + matchExtraGroup
supportedExtraFlavors := []string{"cloud", "rt", "rpi"}
for _, supportedExtraFlavor := range supportedExtraFlavors {
if strings.Contains(kr.FullExtraversion, "-"+supportedExtraFlavor) {
extraVersionPartial = strings.TrimSuffix(extraVersionPartial, "-"+supportedExtraFlavor)
matchExtraGroup = supportedExtraFlavor + "-" + matchExtraGroup
// rpi and rt have a different common package, named `common-{rt,rpi}`
if supportedExtraFlavor == "rt" || supportedExtraFlavor == "rpi" {
matchExtraGroupCommon += "-" + supportedExtraFlavor
}
break
}
}
// download index
@ -125,7 +155,7 @@ func fetchDebianHeadersURLFromRelease(baseURL string, kr kernelrelease.KernelRel
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

View File

@ -1,3 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
@ -8,6 +22,9 @@ import (
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/fedora_kernel.sh
var fedoraKernelTemplate string
//go:embed templates/fedora.sh
var fedoraTemplate string
@ -15,7 +32,7 @@ var fedoraTemplate string
const TargetTypeFedora Type = "fedora"
func init() {
BuilderByTarget[TargetTypeFedora] = &fedora{}
byTarget[TargetTypeFedora] = &fedora{}
}
// fedora is a driverkit target.
@ -23,7 +40,6 @@ type fedora struct {
}
type fedoraTemplateData struct {
commonTemplateData
KernelDownloadURL string
}
@ -31,11 +47,13 @@ func (c *fedora) Name() string {
return TargetTypeFedora.String()
}
func (c *fedora) TemplateKernelUrlsScript() string { return fedoraKernelTemplate }
func (c *fedora) TemplateScript() string {
return fedoraTemplate
}
func (c *fedora) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (c *fedora) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
// fedora FullExtraversion looks like "-200.fc36.x86_64"
// need to get the "fc36" out of the middle
@ -67,15 +85,21 @@ func (c *fedora) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error
kr.Fullversion,
kr.FullExtraversion,
),
fmt.Sprintf( // updates-archive
"https://fedoraproject-updates-archive.fedoraproject.org/fedora/%s/%s/kernel-devel-%s%s.rpm",
version,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
),
}
// return out all possible urls
return urls, nil
}
func (c *fedora) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (c *fedora) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return fedoraTemplateData{
commonTemplateData: cfg.toTemplateData(c, kr),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}

View File

@ -1,15 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"github.com/blang/semver"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"io/ioutil"
"net/http"
"strings"
"github.com/blang/semver/v4"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/flatcar_kernel.sh
var flatcarKernelTemplate string
//go:embed templates/flatcar.sh
var flatcarTemplate string
@ -17,11 +35,10 @@ var flatcarTemplate string
const TargetTypeFlatcar Type = "flatcar"
func init() {
BuilderByTarget[TargetTypeFlatcar] = &flatcar{}
byTarget[TargetTypeFlatcar] = &flatcar{}
}
type flatcarTemplateData struct {
commonTemplateData
KernelDownloadURL string
}
@ -34,18 +51,22 @@ func (f *flatcar) Name() string {
return TargetTypeFlatcar.String()
}
func (f *flatcar) TemplateKernelUrlsScript() string {
return flatcarKernelTemplate
}
func (f *flatcar) TemplateScript() string {
return flatcarTemplate
}
func (f *flatcar) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (f *flatcar) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
if err := f.fillFlatcarInfos(kr); err != nil {
return nil, err
}
return fetchFlatcarKernelURLS(f.info.KernelVersion), nil
}
func (f *flatcar) TemplateData(c Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (f *flatcar) KernelTemplateData(kr kernelrelease.KernelRelease, urls []string) interface{} {
// This happens when `kernelurls` option is passed,
// therefore URLs() method is not called.
if f.info == nil {
@ -55,8 +76,7 @@ func (f *flatcar) TemplateData(c Config, kr kernelrelease.KernelRelease, urls []
}
return flatcarTemplateData{
commonTemplateData: c.toTemplateData(f, kr),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}
@ -87,7 +107,7 @@ func fetchFlatcarKernelURLS(kernelVersion string) []string {
func fetchFlatcarMetadata(kr kernelrelease.KernelRelease) (*flatcarReleaseInfo, error) {
flatcarInfo := flatcarReleaseInfo{}
flatcarVersion := kr.Fullversion
packageIndexUrl, err := getResolvingURLs(fetchFlatcarPackageListURL(kr.Architecture, flatcarVersion))
packageIndexUrl, err := GetResolvingURLs(fetchFlatcarPackageListURL(kr.Architecture, flatcarVersion))
if err != nil {
return nil, err
}

View File

@ -0,0 +1,263 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"context"
"fmt"
"github.com/falcosecurity/falcoctl/pkg/output"
"os"
"regexp"
"strings"
"github.com/blang/semver/v4"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"github.com/falcosecurity/falcoctl/pkg/oci/repository"
"gopkg.in/yaml.v3"
)
type YAMLImage struct {
Target string `yaml:"target"`
GCCVersions []string `yaml:"gcc_versions"` // we expect images to internally link eg: gcc5 to gcc5.0.0
Name string `yaml:"name"`
Arch string `yaml:"arch"`
Tag string `yaml:"tag"`
}
type YAMLImagesList struct {
Images []YAMLImage `yaml:"images"`
}
type Image struct {
Target Type
GCCVersion semver.Version // we expect images to internally link eg: gcc5 to gcc5.0.0
Name string
}
type ImagesLister interface {
LoadImages(printer *output.Printer) []Image
}
type FileImagesLister struct {
FilePath string
Arch string
Tag string
Target string
}
type RepoImagesLister struct {
*repository.Repository
}
type ImageKey string
func (i *Image) toKey() ImageKey {
return ImageKey(i.Target.String() + "_" + i.GCCVersion.String())
}
type ImagesMap map[ImageKey]Image
var tagReg *regexp.Regexp
func (im ImagesMap) findImage(target Type, gccVers semver.Version) (Image, bool) {
targetImage := Image{
Target: target,
GCCVersion: gccVers,
}
// Try to find specific image for specific target first
if img, ok := im[targetImage.toKey()]; ok {
return img, true
}
// Fallback at "any" target that offers specific gcc
targetImage.Target = "any"
if img, ok := im[targetImage.toKey()]; ok {
return img, true
}
return Image{}, false
}
func NewFileImagesLister(filePath string, build *Build) (*FileImagesLister, error) {
return &FileImagesLister{
FilePath: filePath,
Arch: kernelrelease.Architecture(build.Architecture).ToNonDeb(),
Tag: build.builderImageTag(),
Target: build.TargetType.String(),
}, nil
}
func (f *FileImagesLister) LoadImages(printer *output.Printer) []Image {
var (
res []Image
imageList YAMLImagesList
)
// loop over lines in file to print them
fileData, err := os.ReadFile(f.FilePath)
if err != nil {
printer.Logger.Warn("error opening builder repo file",
printer.Logger.Args("err", err.Error(), "filepath", f.FilePath))
return res
}
err = yaml.Unmarshal(fileData, &imageList)
if err != nil {
printer.Logger.Warn("error unmarshalling builder repo file",
printer.Logger.Args("err", err.Error(), "filepath", f.FilePath))
return res
}
for _, image := range imageList.Images {
// Values checks
if image.Arch != f.Arch {
printer.Logger.Debug("skipping wrong-arch image",
printer.Logger.Args("filepath", f.FilePath, "image", image))
continue
}
if image.Tag != f.Tag {
printer.Logger.Debug("skipping wrong-tag image",
printer.Logger.Args("filepath", f.FilePath, "image", image))
continue
}
if image.Target != "any" && image.Target != f.Target {
printer.Logger.Debug("skipping wrong-target image",
printer.Logger.Args("filepath", f.FilePath, "image", image))
continue
}
if image.Name == "" {
printer.Logger.Debug("skipping empty name image",
printer.Logger.Args("filepath", f.FilePath, "image", image))
continue
}
if len(image.GCCVersions) == 0 {
printer.Logger.Debug("expected at least 1 gcc version",
printer.Logger.Args("filepath", f.FilePath, "image", image))
continue
}
for _, gcc := range image.GCCVersions {
buildImage := Image{
Name: image.Name,
Target: Type(image.Target),
GCCVersion: mustParseTolerant(gcc),
}
res = append(res, buildImage)
}
}
return res
}
func NewRepoImagesLister(repo string, build *Build) (*RepoImagesLister, error) {
// Lazy inizialization
if tagReg == nil {
imageTag := build.builderImageTag()
// Create the proper regexes to load "any" and target-specific images for requested arch
arch := kernelrelease.Architecture(build.Architecture).ToNonDeb()
targetFmt := fmt.Sprintf("^(?P<target>%s|any)-%s(?P<gccVers>(_gcc[0-9]+.[0-9]+.[0-9]+)+)-%s$", build.TargetType.String(), arch, imageTag)
tagReg = regexp.MustCompile(targetFmt)
}
// Get the registry URL from repository.
registry, err := getRegistryFromRef(repo)
if err != nil {
return nil, err
}
repoOCI, err := repository.NewRepository(repo,
repository.WithPlainHTTP(build.RegistryPlainHTTP),
repository.WithClient(build.ClientForRegistry(registry)))
if err != nil {
return nil, err
}
return &RepoImagesLister{repoOCI}, nil
}
func (repo *RepoImagesLister) LoadImages(printer *output.Printer) []Image {
tags, err := repo.Tags(context.Background())
if err != nil {
printer.Logger.Warn("skipping repo",
printer.Logger.Args("repo", repo.Reference, "err", err.Error()))
return nil
}
var res []Image
for _, t := range tags {
img := fmt.Sprintf("%s:%s", repo.Reference, t)
match := tagReg.FindStringSubmatch(t)
if len(match) == 0 {
continue
}
var (
target string
gccVers []string
)
for i, name := range tagReg.SubexpNames() {
if i > 0 && i <= len(match) {
switch name {
case "gccVers":
gccVers = strings.Split(match[i], "_gcc")
gccVers = gccVers[1:] // remove initial whitespace
case "target":
target = match[i]
}
}
}
// Note: we store "any" target images as "any",
// instead of adding them to the target,
// because we always prefer specific target images,
// and we cannot guarantee here that any subsequent docker repos
// does not provide a target-specific image that offers same gcc version
for _, gccVer := range gccVers {
// If user set a fixed gcc version, only load images that provide it.
buildImage := Image{
GCCVersion: mustParseTolerant(gccVer),
Name: img,
Target: Type(target),
}
res = append(res, buildImage)
}
}
return res
}
func (b *Build) LoadImages() {
for _, imagesLister := range b.ImagesListers {
for _, image := range imagesLister.LoadImages(b.Printer) {
// User forced a gcc version? Only load images matching the requested gcc version.
if b.GCCVersion != "" && b.GCCVersion != image.GCCVersion.String() {
continue
}
// Skip if key already exists: we have a descending prio list of docker repos!
if _, ok := b.Images[image.toKey()]; !ok {
b.Images[image.toKey()] = image
}
}
}
if len(b.Images) == 0 {
b.Printer.Logger.Fatal("Could not load any builder image. Leaving.")
}
}
// getRegistryFromRef extracts the registry from a ref string.
func getRegistryFromRef(ref string) (string, error) {
index := strings.Index(ref, "/")
if index <= 0 {
return "", fmt.Errorf("cannot extract registry name from ref %q", ref)
}
return ref[0:index], nil
}

View File

@ -0,0 +1,311 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"github.com/falcosecurity/falcoctl/pkg/output"
"github.com/pterm/pterm"
"io"
"net/http"
"os"
"testing"
"github.com/blang/semver/v4"
"github.com/docker/docker/testutil/registry"
"gotest.tools/assert"
)
var imagesTests = []struct {
yamlData string
jsonData string
expected []Image
}{
// Test that multiple gcc versions are correctly mapped to multiple images
{
yamlData: `
images:
- name: foo/test:any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest
target: any
arch: x86_64
tag: latest
gcc_versions:
- 8.0.0
- 6.0.0
- 5.0.0
- 4.9.0
- 4.8.0
`,
jsonData: `
{
"name": "foo/test",
"tags": [
"any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest"
]
}
`,
expected: []Image{
{
Target: "any",
GCCVersion: semver.MustParse("8.0.0"),
Name: "foo/test:any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest",
},
{
Target: "any",
GCCVersion: semver.MustParse("6.0.0"),
Name: "foo/test:any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest",
},
{
Target: "any",
GCCVersion: semver.MustParse("5.0.0"),
Name: "foo/test:any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest",
},
{
Target: "any",
GCCVersion: semver.MustParse("4.9.0"),
Name: "foo/test:any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest",
},
{
Target: "any",
GCCVersion: semver.MustParse("4.8.0"),
Name: "foo/test:any-x86_64_gcc8.0.0_gcc6.0.0_gcc5.0.0_gcc4.9.0_gcc4.8.0-latest",
},
},
},
// Test that arm64 is correctly skipped on amd64 images listing
{
yamlData: `
images:
- name: foo/test:any-x86_64_gcc8.0.0-latest
target: any
arch: x86_64
tag: latest
gcc_versions:
- 8.0.0
- name: foo/test:any-aarch64_gcc8.0.0-latest
target: any
arch: aarch64
tag: latest
gcc_versions:
- 8.0.0
`,
jsonData: `
{
"name": "foo/test",
"tags": [
"any-x86_64_gcc8.0.0-latest",
"any-aarch64_gcc8.0.0-latest"
]
}
`,
expected: []Image{
{
Target: "any",
GCCVersion: semver.MustParse("8.0.0"),
Name: "foo/test:any-x86_64_gcc8.0.0-latest",
},
},
},
// Test empty gcc versions image is skipped
{
yamlData: `
images:
- name: foo/test:any-x86_64_gcc8.0.0-latest
target: any
arch: x86_64
tag: latest
gcc_versions:
- 8.0.0
- name: bar/test:any-x86_64-latest
target: any
arch: x86_64
tag: latest
`,
jsonData: `
{
"name": "foo/test",
"tags": [
"any-x86_64_gcc8.0.0-latest",
"any-x86_64-latest"
]
}
`,
expected: []Image{
{
Target: "any",
GCCVersion: semver.MustParse("8.0.0"),
Name: "foo/test:any-x86_64_gcc8.0.0-latest",
},
},
},
// Test wrong target image is skipped
{
yamlData: `
images:
- name: foo/test:centos-x86_64_gcc8.0.0-latest
target: centos
arch: x86_64
tag: latest
gcc_versions:
- 8.0.0
- name: foo/test:wrongtarget-x86_64_gcc6.0.0-latest
target: wrongtarget
arch: x86_64
tag: latest
gcc_versions:
- 6.0.0
`,
jsonData: `
{
"name": "foo/test",
"tags": [
"centos-x86_64_gcc8.0.0-latest",
"wrongtarget-x86_64_gcc8.0.0-latest"
]
}
`,
expected: []Image{
{
Target: "centos",
GCCVersion: semver.MustParse("8.0.0"),
Name: "foo/test:centos-x86_64_gcc8.0.0-latest",
},
},
},
// Test empty name image is skipped
{
yamlData: `
images:
- name: foo/test:any-x86_64_gcc8.0.0-latest
target: any
arch: x86_64
tag: latest
gcc_versions:
- 8.0.0
- target: any
arch: x86_64
tag: latest
gcc_versions:
- 6.0.0
`,
jsonData: "",
expected: []Image{
{
Target: "any",
GCCVersion: semver.MustParse("8.0.0"),
Name: "foo/test:any-x86_64_gcc8.0.0-latest",
},
},
},
// Test empty list returned for yaml/json with no images
{
yamlData: `
images:
`,
jsonData: `
{
"name": "foo/test",
"tags": [
]
}
`,
expected: nil,
},
// Test empty list returned for malformed yaml/json answer
{
yamlData: `
images:
* name: foo/test
target: any
arch: x86_64
gcc_versions:
* 8.0.0
`,
jsonData: "malformedresponse",
expected: nil,
},
}
func TestFileImagesLister(t *testing.T) {
printer := output.NewPrinter(pterm.LogLevelInfo, pterm.LogFormatterColorful, os.Stdout)
// setup images file
f, err := os.CreateTemp(t.TempDir(), "imagetest")
if err != nil {
t.Fatal(err)
}
defer os.Remove(f.Name())
lister, err := NewFileImagesLister(f.Name(), &Build{
TargetType: Type("centos"),
Architecture: "amd64",
BuilderImage: "auto:latest",
})
assert.NilError(t, err)
for _, test := range imagesTests {
if test.yamlData == "" {
t.Log("Skipping unsuitable test for FileImagesLister")
continue
}
err = f.Truncate(0)
if err != nil {
t.Fatal(err)
}
_, err = f.Seek(0, io.SeekStart)
if err != nil {
t.Fatal(err)
}
_, err = f.WriteString(test.yamlData)
if err != nil {
t.Fatal(err)
}
assert.DeepEqual(t, test.expected, lister.LoadImages(printer))
}
}
func TestRepoImagesLister(t *testing.T) {
printer := output.NewPrinter(pterm.LogLevelInfo, pterm.LogFormatterColorful, os.Stdout)
mock, err := registry.NewMock(t)
assert.NilError(t, err)
defer mock.Close()
lister, err := NewRepoImagesLister(mock.URL()+"/foo/test", &Build{
TargetType: Type("centos"),
Architecture: "amd64",
BuilderImage: "auto:latest",
RegistryPlainHTTP: true,
})
assert.NilError(t, err)
for _, test := range imagesTests {
if test.jsonData == "" {
t.Log("Skipping unsuitable test for RepoImagesLister")
continue
}
// Update expected names adding the mocked server URL as prefix
for idx, _ := range test.expected {
test.expected[idx].Name = mock.URL() + "/" + test.expected[idx].Name
}
mock.RegisterHandler("/v2/foo/test/tags/list", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(test.jsonData))
})
assert.DeepEqual(t, test.expected, lister.LoadImages(printer))
}
}

View File

@ -0,0 +1,106 @@
package builder
import (
_ "embed"
"fmt"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
"path/filepath"
)
// NOTE: since this is only used by local build,
// it is not exposed in `target` array,
// so no init() function to register it is present.
//go:embed templates/local.sh
var localTemplate string
type LocalBuilder struct {
GccPath string
UseDKMS bool
SrcDir string
}
func (l *LocalBuilder) Name() string {
return "local"
}
func (l *LocalBuilder) TemplateKernelUrlsScript() string {
panic("cannot be called on local builder")
}
func (l *LocalBuilder) TemplateScript() string {
return localTemplate
}
func (l *LocalBuilder) URLs(_ kernelrelease.KernelRelease) ([]string, error) {
return nil, nil
}
func (l *LocalBuilder) MinimumURLs() int {
// We don't need any url
return 0
}
type localTemplateData struct {
commonTemplateData
UseDKMS bool
DownloadSrc bool
DriverVersion string
KernelRelease string
}
func (l *LocalBuilder) KernelTemplateData(_ kernelrelease.KernelRelease, _ []string) interface{} {
panic("cannot be called on local builder")
}
func (l *LocalBuilder) TemplateData(c Config, kr kernelrelease.KernelRelease) interface{} {
return localTemplateData{
commonTemplateData: commonTemplateData{
DriverBuildDir: l.GetDriverBuildDir(),
ModuleDriverName: c.DriverName,
ModuleFullPath: l.GetModuleFullPath(c, kr),
BuildModule: len(c.ModuleFilePath) > 0,
BuildProbe: len(c.ProbeFilePath) > 0,
GCCVersion: l.GccPath,
CmakeCmd: fmt.Sprintf(cmakeCmdFmt,
c.DriverName,
c.DriverName,
c.DriverVersion,
c.DriverVersion,
c.DriverVersion,
c.DeviceName,
c.DeviceName,
c.DriverVersion),
},
UseDKMS: l.UseDKMS,
DownloadSrc: len(l.SrcDir) == 0, // if no srcdir is provided, download src!
DriverVersion: c.DriverVersion,
KernelRelease: c.KernelRelease,
}
}
func (l *LocalBuilder) GetModuleFullPath(c Config, kr kernelrelease.KernelRelease) string {
if l.UseDKMS {
// When using dkms, we will use a GLOB to match the pattern; ModuleFullPath won't be used in the templated script anyway.
return fmt.Sprintf("/var/lib/dkms/%s/%s/%s/%s/module/%s.*", c.DriverName, c.DriverVersion, kr.String(), kr.Architecture.ToNonDeb(), c.DriverName)
}
if l.SrcDir != "" {
return filepath.Join(l.SrcDir, fmt.Sprintf("%s.ko", c.DriverName))
}
return c.ToDriverFullPath()
}
func (l *LocalBuilder) GetProbeFullPath(c Config) string {
if l.SrcDir != "" {
return filepath.Join(l.SrcDir, "bpf", "probe.o")
}
return c.ToProbeFullPath()
}
func (l *LocalBuilder) GetDriverBuildDir() string {
driverBuildDir := DriverDirectory
if l.SrcDir != "" {
driverBuildDir = l.SrcDir
}
return driverBuildDir
}

View File

@ -1,7 +1,21 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"github.com/blang/semver"
"github.com/blang/semver/v4"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
@ -9,7 +23,7 @@ import (
const TargetTypeMinikube Type = "minikube"
func init() {
BuilderByTarget[TargetTypeMinikube] = &minikube{
byTarget[TargetTypeMinikube] = &minikube{
vanilla{},
}
}
@ -22,9 +36,8 @@ func (m *minikube) Name() string {
return TargetTypeMinikube.String()
}
func (m *minikube) TemplateData(c Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (m *minikube) KernelTemplateData(kr kernelrelease.KernelRelease, urls []string) interface{} {
return vanillaTemplateData{
commonTemplateData: c.toTemplateData(m, kr),
KernelDownloadURL: urls[0],
KernelLocalVersion: kr.FullExtraversion,
}

View File

@ -1,3 +1,17 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
@ -8,6 +22,9 @@ import (
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/opensuse_kernel.sh
var opensuseKernelTemplate string
//go:embed templates/opensuse.sh
var opensuseTemplate string
@ -30,7 +47,7 @@ var baseURLs []string = []string{
}
// all known releases - will need to expand as more are added
var releases []string = []string{
var releases = []string{
// openSUSE leap
"43.2",
"15.0",
@ -47,7 +64,7 @@ var releases []string = []string{
}
func init() {
BuilderByTarget[TargetTypeOpenSUSE] = &opensuse{}
byTarget[TargetTypeOpenSUSE] = &opensuse{}
}
// opensuse is a driverkit target.
@ -55,7 +72,6 @@ type opensuse struct {
}
type opensuseTemplateData struct {
commonTemplateData
KernelDownloadURLs []string
}
@ -67,11 +83,15 @@ func (o *opensuse) Name() string {
return TargetTypeOpenSUSE.String()
}
func (o *opensuse) TemplateKernelUrlsScript() string {
return opensuseKernelTemplate
}
func (o *opensuse) TemplateScript() string {
return opensuseTemplate
}
func (o *opensuse) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (o *opensuse) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
// SUSE requires 2 urls: a kernel-default-devel*{arch}.rpm and a kernel-devel*noarch.rpm
kernelDefaultDevelPattern := fmt.Sprintf("kernel-default-devel-%s%s.rpm", kr.Fullversion, kr.FullExtraversion)
@ -85,7 +105,7 @@ func (o *opensuse) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, err
possibleURLs := buildURLs(kr, kernelDefaultDevelPattern, kernelDevelNoArchPattern)
// trim the list to only resolving URLs
urls, err := getResolvingURLs(possibleURLs)
urls, err := GetResolvingURLs(possibleURLs)
if err != nil {
return nil, err
}
@ -245,9 +265,8 @@ func validateURLs(urls []string, kernelDefaultDevelPattern string, kernelDevelNo
}
func (o *opensuse) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (o *opensuse) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return opensuseTemplateData{
commonTemplateData: cfg.toTemplateData(o, kr),
KernelDownloadURLs: urls,
}
}

View File

@ -0,0 +1,132 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"strings"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/oracle_kernel.sh
var oracleKernelTemplate string
//go:embed templates/oracle.sh
var oracleTemplate string
// TargetTypeoracle identifies the oracle target ("ol" is the ID from /etc/os-release that Oracle uses)
const TargetTypeoracle Type = "ol"
func init() {
byTarget[TargetTypeoracle] = &oracle{}
}
// oracle is a driverkit target.
type oracle struct {
}
type oracleTemplateData struct {
KernelDownloadURL string
}
func (c *oracle) Name() string {
return TargetTypeoracle.String()
}
func (c *oracle) TemplateKernelUrlsScript() string {
return oracleKernelTemplate
}
func (c *oracle) TemplateScript() string {
return oracleTemplate
}
func (c *oracle) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
// oracle FullExtraversion looks like "-2047.510.5.5.el7uek.x86_64"
// need to get the "el7uek" out of the middle
splitVersion := strings.Split(kr.FullExtraversion, ".")
oracleVersion := splitVersion[len(splitVersion)-2] // [ "-2047", "510", "5", "5", "el7uek","x86_64" ] want -2
// trim off the "el" and "uek" from oracleVersion
version := strings.Trim(strings.Trim(oracleVersion, "el"), "uek")
// sometimes Oracle 8 does "8_x" for version, only want the "8"
if strings.Contains(version, "_") {
version = strings.Split(version, "_")[0]
}
// list of possible UEK versions, which are used in the URL - ex: "UEKR3"
// may need to evolve over time if Oracle adds more
ueks := []string{"R3", "R4", "R5", "R6", "R7"}
// template the kernel info into all possible URL strings
urls := []string{
fmt.Sprintf( // latest (Oracle 7)
"http://yum.oracle.com/repo/OracleLinux/OL%s/latest/%s/getPackage/kernel-devel-%s%s.rpm",
version,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
),
fmt.Sprintf( // latest + baseos (Oracle 8 + 9)
"http://yum.oracle.com/repo/OracleLinux/OL%s/baseos/latest/%s/getPackage/kernel-devel-%s%s.rpm",
version,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
),
fmt.Sprintf( // appstream (Oracle 8 + 9)
"http://yum.oracle.com/repo/OracleLinux/OL%s/appstream/%s/getPackage/kernel-devel-%s%s.rpm",
version,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
),
fmt.Sprintf( // MODRHCK (Oracle 7)
"http://yum.oracle.com/repo/OracleLinux/OL%s/MODRHCK/%s/getPackage/kernel-devel-%s%s.rpm",
version,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
),
}
// add in all the UEK versions
for _, uekVers := range ueks {
urls = append(
urls,
fmt.Sprintf( // UEK versions URL
"http://yum.oracle.com/repo/OracleLinux/OL%s/UEK%s/%s/getPackage/kernel-uek-devel-%s%s.rpm",
version,
uekVers,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
),
)
}
// return out all possible urls
return urls, nil
}
func (c *oracle) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return oracleTemplateData{
KernelDownloadURL: urls[0],
}
}

View File

@ -1,19 +1,37 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
// TargetTypePhoton identifies the Photon target.
const TargetTypePhoton Type = "photon"
//go:embed templates/photonos_kernel.sh
var photonKernelTemplate string
//go:embed templates/photonos.sh
var photonTemplate string
func init() {
BuilderByTarget[TargetTypePhoton] = &photon{}
byTarget[TargetTypePhoton] = &photon{}
}
// photon is a driverkit target.
@ -21,7 +39,6 @@ type photon struct {
}
type photonTemplateData struct {
commonTemplateData
KernelDownloadURL string
}
@ -29,18 +46,21 @@ func (p *photon) Name() string {
return TargetTypePhoton.String()
}
func (p *photon) TemplateKernelUrlsScript() string {
return photonKernelTemplate
}
func (p *photon) TemplateScript() string {
return photonTemplate
}
func (p *photon) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (p *photon) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchPhotonKernelURLS(kr), nil
}
func (p *photon) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (p *photon) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return photonTemplateData{
commonTemplateData: cfg.toTemplateData(p, kr),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}
@ -48,43 +68,38 @@ func fetchPhotonKernelURLS(kr kernelrelease.KernelRelease) []string {
photonReleases := []string{
"3.0",
"4.0",
"5.0",
}
urls := []string{}
var urls []string
for _, r := range photonReleases {
switch r {
case "3.0":
urls = append(urls, fmt.Sprintf(
"https://packages.vmware.com/photon/%s/photon_updates_%s_x86_64/x86_64/linux-devel-%s%s.x86_64.rpm",
r,
r,
kr.Fullversion,
kr.FullExtraversion,
))
urls = append(urls, fmt.Sprintf(
"https://packages.vmware.com/photon/%s/photon_release_%s_x86_64/x86_64/linux-devel-%s%s.x86_64.rpm",
r,
r,
kr.Fullversion,
kr.FullExtraversion,
))
case "4.0":
urls = append(urls, fmt.Sprintf(
"https://packages.vmware.com/photon/%s/photon_%s_x86_64/x86_64/linux-devel-%s%s.x86_64.rpm",
r,
r,
kr.Fullversion,
kr.FullExtraversion,
))
urls = append(urls, fmt.Sprintf(
"https://packages.vmware.com/photon/%s/photon_release_%s_x86_64/x86_64/linux-devel-%s%s.x86_64.rpm",
r,
r,
kr.Fullversion,
kr.FullExtraversion,
))
}
urls = append(urls, fmt.Sprintf(
"https://packages.vmware.com/photon/%s/photon_%s_%s/%s/linux-devel-%s%s.x86_64.rpm",
r,
r,
kr.Architecture.ToNonDeb(),
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
))
urls = append(urls, fmt.Sprintf(
"https://packages.vmware.com/photon/%s/photon_release_%s_%s/%s/linux-devel-%s%s.x86_64.rpm",
r,
r,
kr.Architecture.ToNonDeb(),
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
))
urls = append(urls, fmt.Sprintf(
"https://packages.vmware.com/photon/%s/photon_updates_%s_%s/%s/linux-devel-%s%s.x86_64.rpm",
r,
r,
kr.Architecture.ToNonDeb(),
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
))
}
return urls
}

View File

@ -1,10 +1,28 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/redhat_kernel.sh
var redhatKernelTemplate string
//go:embed templates/redhat.sh
var redhatTemplate string
@ -16,11 +34,10 @@ type redhat struct {
}
func init() {
BuilderByTarget[TargetTypeRedhat] = &redhat{}
byTarget[TargetTypeRedhat] = &redhat{}
}
type redhatTemplateData struct {
commonTemplateData
KernelPackage string
}
@ -28,11 +45,15 @@ func (v *redhat) Name() string {
return TargetTypeRedhat.String()
}
func (v *redhat) TemplateKernelUrlsScript() string {
return redhatKernelTemplate
}
func (v *redhat) TemplateScript() string {
return redhatTemplate
}
func (v *redhat) URLs(_ Config, _ kernelrelease.KernelRelease) ([]string, error) {
func (v *redhat) URLs(_ kernelrelease.KernelRelease) ([]string, error) {
return nil, nil
}
@ -41,9 +62,8 @@ func (v *redhat) MinimumURLs() int {
return 0
}
func (v *redhat) TemplateData(c Config, kr kernelrelease.KernelRelease, _ []string) interface{} {
func (v *redhat) KernelTemplateData(kr kernelrelease.KernelRelease, _ []string) interface{} {
return redhatTemplateData{
commonTemplateData: c.toTemplateData(v, kr),
KernelPackage: kr.Fullversion + kr.FullExtraversion,
KernelPackage: kr.Fullversion + kr.FullExtraversion,
}
}

View File

@ -1,11 +1,29 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"fmt"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/rocky_kernel.sh
var rockyKernelTemplate string
//go:embed templates/rocky.sh
var rockyTemplate string
@ -13,11 +31,10 @@ var rockyTemplate string
const TargetTypeRocky Type = "rocky"
func init() {
BuilderByTarget[TargetTypeRocky] = &rocky{}
byTarget[TargetTypeRocky] = &rocky{}
}
type rockyTemplateData struct {
commonTemplateData
KernelDownloadURL string
}
@ -29,28 +46,38 @@ func (c *rocky) Name() string {
return TargetTypeRocky.String()
}
func (c *rocky) TemplateKernelUrlsScript() string {
return rockyKernelTemplate
}
func (c *rocky) TemplateScript() string {
return rockyTemplate
}
func (c *rocky) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) {
func (c *rocky) URLs(kr kernelrelease.KernelRelease) ([]string, error) {
return fetchRockyKernelURLS(kr), nil
}
func (c *rocky) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} {
func (c *rocky) KernelTemplateData(_ kernelrelease.KernelRelease, urls []string) interface{} {
return rockyTemplateData{
commonTemplateData: cfg.toTemplateData(c, kr),
KernelDownloadURL: urls[0],
KernelDownloadURL: urls[0],
}
}
func fetchRockyKernelURLS(kr kernelrelease.KernelRelease) []string {
rockyReleases := []string{
"8",
"8.7",
"9",
"9.1",
}
rockyVaultReleases := []string{
"8.3",
"8.4",
"8.5",
"8.6",
"9",
"9.0",
"9.1",
}
urls := []string{}
@ -63,7 +90,7 @@ func fetchRockyKernelURLS(kr kernelrelease.KernelRelease) []string {
kr.Fullversion,
kr.FullExtraversion,
))
}else{
} else {
urls = append(urls, fmt.Sprintf(
"https://download.rockylinux.org/pub/rocky/%s/BaseOS/%s/os/Packages/k/kernel-devel-%s%s.rpm",
r,
@ -73,5 +100,24 @@ func fetchRockyKernelURLS(kr kernelrelease.KernelRelease) []string {
))
}
}
for _, r := range rockyVaultReleases {
if r >= "9" {
urls = append(urls, fmt.Sprintf(
"https://download.rockylinux.org/vault/rocky/%s/AppStream/%s/os/Packages/k/kernel-devel-%s%s.rpm",
r,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
))
} else {
urls = append(urls, fmt.Sprintf(
"https://download.rockylinux.org/vault/rocky/%s/BaseOS/%s/os/Packages/k/kernel-devel-%s%s.rpm",
r,
kr.Architecture.ToNonDeb(),
kr.Fullversion,
kr.FullExtraversion,
))
}
}
return urls
}

View File

@ -0,0 +1,75 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
_ "embed"
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
//go:embed templates/sles_kernel.sh
var slesKernelTemplate string
//go:embed templates/sles.sh
var slesTemplate string
// TargetTypeSLES identifies the sles target.
const TargetTypeSLES Type = "sles"
// sles is a driverkit target.
type sles struct {
}
func init() {
byTarget[TargetTypeSLES] = &sles{}
}
type slesTemplateData struct {
KernelPackage string
}
func (v *sles) Name() string {
return TargetTypeSLES.String()
}
func (v *sles) TemplateKernelUrlsScript() string {
return slesKernelTemplate
}
func (v *sles) TemplateScript() string {
return slesTemplate
}
func (v *sles) URLs(_ kernelrelease.KernelRelease) ([]string, error) {
return nil, nil
}
func (v *sles) MinimumURLs() int {
// We don't need any url
return 0
}
func (v *sles) KernelTemplateData(kr kernelrelease.KernelRelease, _ []string) interface{} {
return slesTemplateData{
KernelPackage: kr.Fullversion + kr.FullExtraversion,
}
}
// sles requires docker to run with `--net=host` for builder images to work
// for more info, see the suse container connect README: https://github.com/SUSE/container-suseconnect
func (v *sles) BuilderImageNetMode() string {
return "host"
}

View File

@ -0,0 +1,43 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
import (
"github.com/falcosecurity/driverkit/pkg/kernelrelease"
)
// TargetTypeTalos identifies the Talos target.
const TargetTypeTalos Type = "talos"
func init() {
byTarget[TargetTypeTalos] = &talos{
vanilla{},
}
}
type talos struct {
vanilla
}
func (b *talos) Name() string {
return TargetTypeTalos.String()
}
func (b *talos) KernelTemplateData(kr kernelrelease.KernelRelease, urls []string) interface{} {
return vanillaTemplateData{
KernelDownloadURL: urls[0],
KernelLocalVersion: kr.FullExtraversion,
}
}

View File

@ -1,7 +1,21 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package builder
// BuilderByTarget maps targets to their builder.
var BuilderByTarget = Targets{}
// byTarget maps targets to their builder.
var byTarget = map[Type]Builder{}
// Type is a type representing targets.
type Type string
@ -9,15 +23,3 @@ type Type string
func (t Type) String() string {
return string(t)
}
// Targets is a type representing the list of the supported targets.
type Targets map[Type]Builder
// Targets returns the list of all the supported targets.
func (t Targets) Targets() []string {
res := []string{}
for k := range t {
res = append(res, k.String())
}
return res
}

View File

@ -0,0 +1,41 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2023 The Falco Authors.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Simple script that desperately tries to load the kernel instrumentation by
# looking for it in a bunch of ways. Convenient when running Falco inside
# a container or in other weird environments.
#
set -xeuo pipefail
cd {{ .DriverBuildDir }}
mkdir -p build && cd build
{{ .CmakeCmd }}
{{ if .BuildModule }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
{{ end }}
{{ if .BuildProbe }}
# Build the eBPF probe
make bpf
ls -l driver/bpf/probe.o
{{ end }}

View File

@ -0,0 +1,35 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2023 The Falco Authors.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Simple script that desperately tries to load the kernel instrumentation by
# looking for it in a bunch of ways. Convenient when running Falco inside
# a container or in other weird environments.
#
set -xeuo pipefail
# Fetch the kernel
mkdir /tmp/kernel-download
cd /tmp/kernel-download
curl --silent -o kernel-devel.rpm -SL {{ .KernelDownloadURL }}
rpm2cpio kernel-devel.rpm | cpio --extract --make-directories
rm -Rf /tmp/kernel
mkdir -p /tmp/kernel
mv usr/src/kernels/*/* /tmp/kernel
# exit value
export KERNELDIR=/tmp/kernel

View File

@ -1,31 +1,34 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2023 The Falco Authors.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Simple script that desperately tries to load the kernel instrumentation by
# looking for it in a bunch of ways. Convenient when running Falco inside
# a container or in other weird environments.
#
set -xeuo pipefail
rm -Rf {{ .DriverBuildDir }}
mkdir {{ .DriverBuildDir }}
rm -Rf /tmp/module-download
mkdir -p /tmp/module-download
curl --silent -SL {{ .ModuleDownloadURL }} | tar -xzf - -C /tmp/module-download
mv /tmp/module-download/*/driver/* {{ .DriverBuildDir }}
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
bash /driverkit/fill-driver-config.sh {{ .DriverBuildDir }}
# Fetch the kernel
mkdir /tmp/kernel-download
cd /tmp/kernel-download
curl --silent -o kernel-devel.rpm -SL {{ .KernelDownloadURL }}
rpm2cpio kernel-devel.rpm | cpio --extract --make-directories
rm -Rf /tmp/kernel
mkdir -p /tmp/kernel
mv usr/src/kernels/*/* /tmp/kernel
cd {{ .DriverBuildDir }}
mkdir -p build && cd build
{{ .CmakeCmd }}
{{ if .BuildModule }}
# Build the module
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
@ -33,7 +36,6 @@ modinfo {{ .ModuleFullPath }}
{{ if .BuildProbe }}
# Build the eBPF probe
cd {{ .DriverBuildDir }}/bpf
make KERNELDIR=/tmp/kernel
ls -l probe.o
make bpf
ls -l driver/bpf/probe.o
{{ end }}

View File

@ -0,0 +1,35 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2023 The Falco Authors.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Simple script that desperately tries to load the kernel instrumentation by
# looking for it in a bunch of ways. Convenient when running Falco inside
# a container or in other weird environments.
#
set -xeuo pipefail
# Fetch the kernel
mkdir /tmp/kernel-download
cd /tmp/kernel-download
curl --silent -o kernel-devel.rpm -SL {{ .KernelDownloadURL }}
rpm2cpio kernel-devel.rpm | cpio --extract --make-directories
rm -Rf /tmp/kernel
mkdir -p /tmp/kernel
mv usr/src/kernels/*/* /tmp/kernel
# exit value
export KERNELDIR=/tmp/kernel

View File

@ -1,42 +1,41 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2023 The Falco Authors.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Simple script that desperately tries to load the kernel instrumentation by
# looking for it in a bunch of ways. Convenient when running Falco inside
# a container or in other weird environments.
#
set -xeuo pipefail
rm -Rf {{ .DriverBuildDir }}
mkdir {{ .DriverBuildDir }}
rm -Rf /tmp/module-download
mkdir -p /tmp/module-download
curl --silent -SL {{ .ModuleDownloadURL }} | tar -xzf - -C /tmp/module-download
mv /tmp/module-download/*/driver/* {{ .DriverBuildDir }}
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
bash /driverkit/fill-driver-config.sh {{ .DriverBuildDir }}
# Fetch the kernel
mkdir /tmp/kernel-download
cd /tmp/kernel-download
{{ range $url := .KernelDownloadURLs }}
curl --silent -o kernel.rpm -SL {{ $url }}
rpm2cpio kernel.rpm | cpio --extract --make-directories
rm -rf kernel.rpm
{{ end }}
rm -Rf /tmp/kernel
mkdir -p /tmp/kernel
mv usr/src/kernels/*/* /tmp/kernel
cd {{ .DriverBuildDir }}
mkdir -p build && cd build
{{ .CmakeCmd }}
{{ if .BuildModule }}
# Build the kernel module
cd {{ .DriverBuildDir }}
make KERNELDIR=/tmp/kernel CC=/usr/bin/gcc-{{ .GCCVersion }} LD=/usr/bin/ld.bfd CROSS_COMPILE=""
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
# Build the module
make CC=/usr/bin/gcc-{{ .GCCVersion }} LD=/usr/bin/ld.bfd CROSS_COMPILE="" driver
strip -g {{ .ModuleFullPath }}
# Print results
modinfo {{ .ModuleFullPath }}
{{ end }}
{{ if .BuildProbe }}
# Build the eBPF probe
cd {{ .DriverBuildDir }}/bpf
make KERNELDIR=/tmp/kernel
ls -l probe.o
make bpf
ls -l driver/bpf/probe.o
{{ end }}

View File

@ -0,0 +1,38 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2023 The Falco Authors.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Simple script that desperately tries to load the kernel instrumentation by
# looking for it in a bunch of ways. Convenient when running Falco inside
# a container or in other weird environments.
#
set -xeuo pipefail
# Fetch the kernel
mkdir /tmp/kernel-download
cd /tmp/kernel-download
{{ range $url := .KernelDownloadURLs }}
curl --silent -o kernel.rpm -SL {{ $url }}
rpm2cpio kernel.rpm | cpio --extract --make-directories
rm -rf kernel.rpm
{{ end }}
rm -Rf /tmp/kernel
mkdir -p /tmp/kernel
mv usr/src/kernels/*/* /tmp/kernel
# exit value
export KERNELDIR=/tmp/kernel

Some files were not shown because too many files have changed in this diff Show More