mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
plugins: Fix panic with /health and envoy plugin
If there was a nil status value it was still being added to the status map, but the server didn't check before dereferencing it. We now just check if the pointer is nil before trying to use it. Fixes: #2396 Signed-off-by: Patrick East <east.patrick@gmail.com>
This commit is contained in:
+1
-1
@@ -1008,7 +1008,7 @@ func (s *Server) unversionedGetHealth(w http.ResponseWriter, r *http.Request) {
|
||||
// Ensure that all plugins (if requested to be included in the result) have an OK status.
|
||||
hasErr := false
|
||||
for _, status := range pluginStatuses {
|
||||
if status.State != plugins.StateOK {
|
||||
if status != nil && status.State != plugins.StateOK {
|
||||
hasErr = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -326,7 +326,6 @@ func TestUnversionedGetHealthCheckDiscoveryWithPlugins(t *testing.T) {
|
||||
},
|
||||
exp: 500,
|
||||
},
|
||||
|
||||
{
|
||||
note: "all plugins ready - recovery",
|
||||
statusUpdates: map[string]*plugins.Status{
|
||||
@@ -336,6 +335,13 @@ func TestUnversionedGetHealthCheckDiscoveryWithPlugins(t *testing.T) {
|
||||
},
|
||||
exp: 200,
|
||||
},
|
||||
{
|
||||
note: "nil plugin status",
|
||||
statusUpdates: map[string]*plugins.Status{
|
||||
"p1": nil,
|
||||
},
|
||||
exp: 200,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
Reference in New Issue
Block a user