From f7d12bf256ea431afd2d29cf6453fd539dff8085 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 5 Sep 2024 00:25:22 +0200 Subject: [PATCH] Linter: respect tags for linting of global privileged plugins (#4083) https://ci.woodpecker-ci.org/repos/8981/pipeline/162/4 should have shown an lit error but it did not. this fix it a followup of https://github.com/woodpecker-ci/woodpecker/pull/4053 --- pipeline/frontend/yaml/linter/linter.go | 4 ++-- pipeline/frontend/yaml/linter/linter_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pipeline/frontend/yaml/linter/linter.go b/pipeline/frontend/yaml/linter/linter.go index 6e3ddde94..6b88d8e98 100644 --- a/pipeline/frontend/yaml/linter/linter.go +++ b/pipeline/frontend/yaml/linter/linter.go @@ -169,9 +169,9 @@ func (l *Linter) lintImage(config *WorkflowConfig, c *types.Container, area stri func (l *Linter) lintPrivilegedPlugins(config *WorkflowConfig, c *types.Container, area string) error { // lint for conflicts of https://github.com/woodpecker-ci/woodpecker/pull/3918 if utils.MatchImage(c.Image, "plugins/docker", "plugins/gcr", "plugins/ecr", "woodpeckerci/plugin-docker-buildx") { - msg := "Cannot use once by default privileged plugins, if needed add it too WOODPECKER_PLUGINS_PRIVILEGED" + msg := fmt.Sprintf("Cannot use once by default privileged plugin '%s', if needed add it too WOODPECKER_PLUGINS_PRIVILEGED", c.Image) // check first if user did not add them back - if l.privilegedPlugins != nil && !utils.MatchImage(c.Image, *l.privilegedPlugins...) { + if l.privilegedPlugins != nil && !utils.MatchImageDynamic(c.Image, *l.privilegedPlugins...) { return newLinterError(msg, config.File, fmt.Sprintf("%s.%s", area, c.Name), false) } else if l.privilegedPlugins == nil { // if linter has no info of current privileged plugins, it's just a warning diff --git a/pipeline/frontend/yaml/linter/linter_test.go b/pipeline/frontend/yaml/linter/linter_test.go index 354b6b4b7..3c0e73417 100644 --- a/pipeline/frontend/yaml/linter/linter_test.go +++ b/pipeline/frontend/yaml/linter/linter_test.go @@ -171,7 +171,7 @@ func TestLintErrors(t *testing.T) { }, { from: "{steps: { build: { image: plugins/docker, settings: { test: 'true' } } }, when: { branch: main, event: push } } }", - want: "Cannot use once by default privileged plugins, if needed add it too WOODPECKER_PLUGINS_PRIVILEGED", + want: "Cannot use once by default privileged plugin 'plugins/docker', if needed add it too WOODPECKER_PLUGINS_PRIVILEGED", }, { from: "{steps: { build: { image: golang, settings: { test: 'true' } } }, when: { branch: main, event: push }, clone: { git: { image: some-other/plugin-git:v1.1.0 } } }",