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

fix: prevent nil pointer dereference in health checks #394

Merged
merged 1 commit into from
Jul 27, 2021

Conversation

makkes
Copy link
Member

@makkes makkes commented Jul 26, 2021

The lastStatus map now stores event.ResourceStatus values instead
of pointers to them, preventing nil pointers being dereferenced by
accident.

refs #374

Signed-off-by: Max Jonas Werner mail@makk.es

@makkes
Copy link
Member Author

makkes commented Jul 26, 2021

@stefanprodan as promised.

@hiddeco
Copy link
Member

hiddeco commented Jul 26, 2021

Wouldn't this result in L92-100 tripping because it now deals with an initialized but empty object, and wouldn't it thus be better to keep the pointer list, but deal with nil values there?

Only non-nil values are added to the list, so this will not happen, but I still think the dereference makes little sense.

(In general I think, pointer object lists often use pointers because nil has a special meaning, and you want to maintain this information for as long as you may need it).

Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses all my (personal) previous concerns, thank you @makkes 💯

@hiddeco
Copy link
Member

hiddeco commented Jul 26, 2021

DCO signoff (and while you are at it, a smash of) commits is still required.

When checking the health status of each declared resource, kstatus
might return nil for certain resources (for whatever reason). In that
case, this information is now conveyed in the health status event.

fluxcd#374

Signed-off-by: Max Jonas Werner <mail@makk.es>
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @makkes

@stefanprodan stefanprodan added area/kstatus Health checking related issues and pull requests bug Something isn't working labels Jul 27, 2021
@stefanprodan stefanprodan merged commit 9d66fc7 into fluxcd:main Jul 27, 2021
@makkes makkes deleted the prevent-npes branch July 27, 2021 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kstatus Health checking related issues and pull requests bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants