Fix nil pointer panics in GitHub analyzer gist/repo binding functions#4864
Open
shahzadhaider1 wants to merge 2 commits intotrufflesecurity:mainfrom
Open
Fix nil pointer panics in GitHub analyzer gist/repo binding functions#4864shahzadhaider1 wants to merge 2 commits intotrufflesecurity:mainfrom
shahzadhaider1 wants to merge 2 commits intotrufflesecurity:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
A panic was caught in the GitHub analyzer worker:
The GitHub API returns
descriptionandowneras optional nullable fields on gist objects. When a gist has no description, the API returnsnull, leavingDescriptionas a nil*string. The code dereferenced it directly (*gist.Description) without any nil guard.The same class of bug existed across several functions in the file:
*gist.Owner.Login,*gist.ID,*repo.Name,*repo.FullName,*user.Login,*user.Type; all raw dereferences of fields that the go-github library defines as optional pointers.Why safe getters alone weren't enough for
OwnerFor
Description, replacing the dereference withGetDescription()(returns""on nil) is sufficient, a gist without a description is still attributable.For
Owner, falling back to an empty string silently produces corrupt output:FullyQualifiedName: "gist.github.com//abc123": malformedParentresource with emptyNameandTypeA gist with no owner cannot be meaningfully attributed, so it is skipped rather than emitting bad data. This is consistent with how
PrintGistsincommon/github.goalready handles nil gist pointers.Checklist:
make test-community)?make lintthis requires golangci-lint)?Note
Medium Risk
Changes GitHub analyzer output generation to use safe getters and to skip repos/gists missing owners, which could reduce emitted bindings for some edge-case API responses. Logic is small and localized but affects permission attribution results.
Overview
Fixes GitHub analyzer nil-pointer panics by replacing direct pointer dereferences on
gh.User,gh.Repository, andgh.Gistfields with go-githubGet*()accessors.Updates binding generation to skip repositories and gists that have no
Owner, avoiding malformedFullyQualifiedName/parent resources, and adds a focused unit test covering nil gistDescriptionand nilOwnercases.Reviewed by Cursor Bugbot for commit d6d4d75. Bugbot is set up for automated code reviews on this repo. Configure here.