wait_shutdown.rego 1011 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package nginx.wait_shutdown
  2. import future.keywords
  3. # Policy expects input structure of form:
  4. # values: {}
  5. # This policy tests for the modification of the wait-shutdown script as a soft constraint. We look
  6. # for Helm values of the form:
  7. #
  8. # controller:
  9. # lifecycle:
  10. # preStop:
  11. # exec:
  12. # command:
  13. # - sh
  14. # - '-c'
  15. # - sleep 120 && /wait-shutdown
  16. POLICY_ID := "nginx_wait_shutdown"
  17. POLICY_VERSION := "v0.0.1"
  18. POLICY_SEVERITY := "high"
  19. POLICY_TITLE := sprintf("NGINX ingress controller should have a modified wait-shutdown script", [])
  20. POLICY_SUCCESS_MESSAGE := sprintf("Success: NGINX ingress controller has a properly modified wait-shutdown script set", [])
  21. allow if {
  22. input.values.controller.lifecycle.preStop.exec.command
  23. count(input.values.controller.lifecycle.preStop.exec.command) != 1
  24. }
  25. FAILURE_MESSAGE contains msg if {
  26. not allow
  27. msg := sprintf("Failed: NGINX ingress controller does not have a properly modified wait-shutdown script", [])
  28. }