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

Secret image filter with port invalid #2641

Closed
5 tasks done
HamburgerJungeJr opened this issue Oct 24, 2023 · 1 comment · Fixed by #2674
Closed
5 tasks done

Secret image filter with port invalid #2641

HamburgerJungeJr opened this issue Oct 24, 2023 · 1 comment · Fixed by #2674
Labels
bug Something isn't working

Comments

@HamburgerJungeJr
Copy link
Contributor

Component

server, web-ui

Describe the bug

I'm running a local registry on a custom port (:8443) . So when I'm using a local image in my pipelines I reference it by specifying the following image:

steps:
  image:
    image: myregistry.example.com:8443/myimage:mytag

Now I tried to add a global secret and restrict it to an image from my registry. So I entered the following image name in the webui: myregistry.example.com:8443/myimage:mytag

This results in the error message
Error updating global secret. Invalid Secret Image: image 'myregistry.example.com:8443/myimage:mytag' do not match regexp '^([\w\d\-_\.\/]*[\w\d\-_]+)+(:[\w\d\-_]+)?$'

I searched the code and found the following RegEx

var validDockerImageString = regexp.MustCompile(
`^([\w\d\-_\.\/]*` + // optional url prefix
`[\w\d\-_]+` + // image name
`)+` +
`(:[\w\d\-_]+)?$`, // optional image tag
)

This RegEx does not allow the port in the url part.

A RegEx like this should fix the problem

var validDockerImageString = regexp.MustCompile(
	`^([\w\d\-_\.\/]*` + // optional url prefix
        `(:\d*/)?` + // optional port prefix
	`[\w\d\-_]+` + // image name
	`)+` +
	`(:[\w\d\-_]+)?$`, // optional image tag
)

System Info

V1.0.2

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Check that this is a concrete bug. For Q&A join our Discord Chat Server or the Matrix room.
@HamburgerJungeJr HamburgerJungeJr added the bug Something isn't working label Oct 24, 2023
@HamburgerJungeJr HamburgerJungeJr changed the title Secert image filter port invalid Secret image filter port invalid Oct 24, 2023
@HamburgerJungeJr HamburgerJungeJr changed the title Secret image filter port invalid Secret image filter with port invalid Oct 24, 2023
@anbraten
Copy link
Member

Would you like to open a PR fixing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants