Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate and check sha256 of plugins #1072

Merged
merged 5 commits into from
May 26, 2023

Conversation

josefkarasek
Copy link

@josefkarasek josefkarasek commented May 24, 2023

Description

Changes proposed in this pull request:

  • Introduce temporary dir structure .downloading for plugins while they're being downloaded
  • Add sha256 checksum of Botkube plugins to Plugin Index
  • Check checksum when downloading plugins

Testing

  1. Rebuild your plugins make build-plugins-single and host them locally PLUGIN_SERVER_HOST=http://localhost go run test/helpers/plugin_server.go

  2. In another terminal check for plugin cache dir structure. While Botkube download plugins, you should see temp dir .downloading. This dir should disappear when plugin download succeeds.

watch -n 1 tree /tmp/plugins
  1. Run botkube
rm -rf /tmp/plugins ; go run cmd/botkube/main.go
  1. Mess up checksum of some plugin in plugin-index.yaml. Botkube now fails to start.
rm -rf /tmp/plugins ; go run cmd/botkube/main.go

Related issue(s)

#1027

@josefkarasek josefkarasek requested a review from a team May 24, 2023 12:31
@josefkarasek josefkarasek requested a review from PrasadG193 as a code owner May 24, 2023 12:31
@josefkarasek josefkarasek requested a review from mszostok May 24, 2023 12:31
@josefkarasek josefkarasek marked this pull request as draft May 24, 2023 12:31
@josefkarasek josefkarasek marked this pull request as ready for review May 24, 2023 13:32
Copy link
Collaborator

@mszostok mszostok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested e2e works well 👍 I have only one comment related to the fake plugin server 🙂

@@ -35,14 +35,11 @@ func NewPluginServer(cfg PluginConfig) (string, func() error) {

basePath := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port)
builder := plugin.NewIndexBuilder(loggerx.NewNoop())

idx, err := builder.Build(cfg.BinariesDirectory, basePath+"/static", ".*")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put that inside the handler as I wanted to rebuild it each time botkube calls the endpoint. I'm using:

env PLUGIN_SERVER_HOST=http://host.k3d.internal go run test/helpers/plugin_server.go

as a long living process. So I don't need to restart that if I rebuild the binary, as it will fail on checksum. Can we revert that?

@josefkarasek josefkarasek merged commit 0d4f918 into kubeshop:main May 26, 2023
@josefkarasek josefkarasek added the enhancement New feature or request label Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants