Skip to content

Add additional guardrails and checks against nil pointers; clean up some confusing code as well#1063

Merged
egibs merged 9 commits into
chainguard-dev:mainfrom
egibs:pointers-and-nil-checks
Jul 29, 2025
Merged

Add additional guardrails and checks against nil pointers; clean up some confusing code as well#1063
egibs merged 9 commits into
chainguard-dev:mainfrom
egibs:pointers-and-nil-checks

Conversation

@egibs

@egibs egibs commented Jul 28, 2025

Copy link
Copy Markdown
Member

This PR applies fixes to most of the nilaway findings that popped up when run against the entire project with the exception of buffer pools we initialize.

Additionally, I cleaned up some confusing strings.go code and simplified quite a bit of its functionality (for instance, we weren't really using the buffers so there wasn't any reason to keep that around).

Most of the changes involve checking for nil Reports or ensuring slices are of a certain length before we try to access any of their contents. This has historically been ~fine, but only because we have consistent naming and avoided edge cases. Otherwise, any one of these is likely to happen when using different rule names/path formats/etc.

egibs added 8 commits July 28, 2025 10:25
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
Signed-off-by: egibs <20933572+egibs@users.noreply.github.com>
@egibs egibs requested a review from stevebeattie July 28, 2025 19:10

@eslerm eslerm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cheers for sharing nilaway.

Adding linting and guardrail notes to https://eng.inky.wtf/docs/teams/product-security/best-practices/ may be helpful for future SDLC planning.

@egibs egibs enabled auto-merge (squash) July 29, 2025 15:46
@egibs egibs merged commit 37802b1 into chainguard-dev:main Jul 29, 2025
12 checks passed
@egibs egibs deleted the pointers-and-nil-checks branch August 2, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants