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

Only use approved domain names in the Ingress hostnames #60

Open
garethahealy opened this issue Jun 25, 2020 · 3 comments
Open

Only use approved domain names in the Ingress hostnames #60

garethahealy opened this issue Jun 25, 2020 · 3 comments
Labels
help wanted Extra attention is needed policy-request

Comments

@garethahealy
Copy link
Contributor

Parent: #23
Suggestion: https://learnk8s.io/production-best-practices#application-development
Solved By: TODO

@garethahealy
Copy link
Contributor Author

garethahealy commented Jun 25, 2020

@jtudelag
Copy link

jtudelag commented Jul 21, 2020

sth like this?

package kubernetes.admission

deny[msg] {
  input.request.kind.kind == “Route”
  hostname := input.request.object.spec.hostname
  not startswith(hostname, “example.com”)
  msg := sprintf(“hostname not valid BLA BLA BLA %v”, [hostname]) 
}

@garethahealy
Copy link
Contributor Author

@jtudelag ; yes, the core bits look correct, i.e.: not startswith.

But, have a look at the example, as the policies wouldn't explicitly use kubernetes.admission - there might be a use-case for that, but not seen one yet.

So your policy updated with the helpers, it would be:

violation[msg] {
  openshift.is_route

  obj := konstraint.object
  not startswith(obj.spec.hostname, “example.com”)

  msg := konstraint.format(sprintf("%s/%s: hostname is not valid", [obj.kind, obj.metadata.name, obj.spec.hostname]))
}

@garethahealy garethahealy added the help wanted Extra attention is needed label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed policy-request
Projects
None yet
Development

No branches or pull requests

2 participants