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

Repository Vulnerability Alert Add Missing Fields #1898

Merged
merged 6 commits into from
Jul 8, 2021

Conversation

OhZedTee
Copy link
Contributor

@OhZedTee OhZedTee commented Jun 16, 2021

Struct for repository_vulnerability_alert webhook event is missing fields that are mentioned in docs.

These fields need to be added to the struct, and tested.

The fields are:
alert.severity
alert.created_at
alert.ghsa_id
repository.watchers
repository.open_issues

The new structs should like as such (I used to show what should be added):
event_types.go

type RepositoryVulnerabilityAlertEvent struct {
	// Action is the action that was performed. Possible values are: "create", "dismiss", "resolve".
	Action *string `json:"action,omitempty"`

	//The security alert of the vulnerable dependency.
	Alert *struct {
		ID                         *int64           `json:"id,omitempty"`
		AffectedRange              *string          `json:"affected_range,omitempty"`
		AffectedPackageName        *string          `json:"affected_package_name,omitempty"`
		ExternalReference          *string          `json:"external_reference,omitempty"`
		ExternalIdentifier         *string          `json:"external_identifier,omitempty"`
                **GithubSecurityAdvisoryID *string          `json:"ghsa_id,omitempty"`**
                **Severity                 *string          `json:"severity,omitempty"`**
                **CreatedAt                *Timestamp       `json:"created_at,omitempty"`**
		FixedIn                    *string          `json:"fixed_in,omitempty"`
		Dismisser                  *User            `json:"dismisser,omitempty"`
		DismissReason              *string          `json:"dismiss_reason,omitempty"`
		DismissedAt                *Timestamp       `json:"dismissed_at,omitempty"`
	} `json:"alert,omitempty"`

	//The repository of the vulnerable dependency.
	Repository *Repository `json:"repository,omitempty"`
}

repos.go

// Repository represents a GitHub repository.
type Repository struct {
	ID                  *int64           `json:"id,omitempty"`
	NodeID              *string          `json:"node_id,omitempty"`
	Owner               *User            `json:"owner,omitempty"`
	Name                *string          `json:"name,omitempty"`
	FullName            *string          `json:"full_name,omitempty"`
	Description         *string          `json:"description,omitempty"`
	Homepage            *string          `json:"homepage,omitempty"`
	CodeOfConduct       *CodeOfConduct   `json:"code_of_conduct,omitempty"`
	DefaultBranch       *string          `json:"default_branch,omitempty"`
	MasterBranch        *string          `json:"master_branch,omitempty"`
	CreatedAt           *Timestamp       `json:"created_at,omitempty"`
	PushedAt            *Timestamp       `json:"pushed_at,omitempty"`
	UpdatedAt           *Timestamp       `json:"updated_at,omitempty"`
	HTMLURL             *string          `json:"html_url,omitempty"`
	CloneURL            *string          `json:"clone_url,omitempty"`
	GitURL              *string          `json:"git_url,omitempty"`
	MirrorURL           *string          `json:"mirror_url,omitempty"`
	SSHURL              *string          `json:"ssh_url,omitempty"`
	SVNURL              *string          `json:"svn_url,omitempty"`
	Language            *string          `json:"language,omitempty"`
	Fork                *bool            `json:"fork,omitempty"`
	ForksCount          *int             `json:"forks_count,omitempty"`
	NetworkCount        *int             `json:"network_count,omitempty"`
	OpenIssuesCount     *int             `json:"open_issues_count,omitempty"`
        **OpenIssues               *int            `json:"open_issues,omitempty"`**        
	StargazersCount     *int             `json:"stargazers_count,omitempty"`
	SubscribersCount    *int             `json:"subscribers_count,omitempty"`
	WatchersCount       *int             `json:"watchers_count,omitempty"`
        **Watchers                 *int             `json:"watchers,omitempty"`**
	Size                *int             `json:"size,omitempty"`
	AutoInit            *bool            `json:"auto_init,omitempty"`
	Parent              *Repository      `json:"parent,omitempty"`
	Source              *Repository      `json:"source,omitempty"`
	TemplateRepository  *Repository      `json:"template_repository,omitempty"`
	Organization        *Organization    `json:"organization,omitempty"`
	Permissions         *map[string]bool `json:"permissions,omitempty"`
	AllowRebaseMerge    *bool            `json:"allow_rebase_merge,omitempty"`
	AllowSquashMerge    *bool            `json:"allow_squash_merge,omitempty"`
	AllowMergeCommit    *bool            `json:"allow_merge_commit,omitempty"`
	DeleteBranchOnMerge *bool            `json:"delete_branch_on_merge,omitempty"`
	Topics              []string         `json:"topics,omitempty"`
	Archived            *bool            `json:"archived,omitempty"`
	Disabled            *bool            `json:"disabled,omitempty"`

	// Only provided when using RepositoriesService.Get while in preview
	License *License `json:"license,omitempty"`

	// Additional mutable fields when creating and editing a repository
	Private           *bool   `json:"private,omitempty"`
	HasIssues         *bool   `json:"has_issues,omitempty"`
	HasWiki           *bool   `json:"has_wiki,omitempty"`
	HasPages          *bool   `json:"has_pages,omitempty"`
	HasProjects       *bool   `json:"has_projects,omitempty"`
	HasDownloads      *bool   `json:"has_downloads,omitempty"`
	IsTemplate        *bool   `json:"is_template,omitempty"`
	LicenseTemplate   *string `json:"license_template,omitempty"`
	GitignoreTemplate *string `json:"gitignore_template,omitempty"`

	// Creating an organization repository. Required for non-owners.
	TeamID *int64 `json:"team_id,omitempty"`

	// API URLs
	URL              *string `json:"url,omitempty"`
	ArchiveURL       *string `json:"archive_url,omitempty"`
	AssigneesURL     *string `json:"assignees_url,omitempty"`
	BlobsURL         *string `json:"blobs_url,omitempty"`
	BranchesURL      *string `json:"branches_url,omitempty"`
	CollaboratorsURL *string `json:"collaborators_url,omitempty"`
	CommentsURL      *string `json:"comments_url,omitempty"`
	CommitsURL       *string `json:"commits_url,omitempty"`
	CompareURL       *string `json:"compare_url,omitempty"`
	ContentsURL      *string `json:"contents_url,omitempty"`
	ContributorsURL  *string `json:"contributors_url,omitempty"`
	DeploymentsURL   *string `json:"deployments_url,omitempty"`
	DownloadsURL     *string `json:"downloads_url,omitempty"`
	EventsURL        *string `json:"events_url,omitempty"`
	ForksURL         *string `json:"forks_url,omitempty"`
	GitCommitsURL    *string `json:"git_commits_url,omitempty"`
	GitRefsURL       *string `json:"git_refs_url,omitempty"`
	GitTagsURL       *string `json:"git_tags_url,omitempty"`
	HooksURL         *string `json:"hooks_url,omitempty"`
	IssueCommentURL  *string `json:"issue_comment_url,omitempty"`
	IssueEventsURL   *string `json:"issue_events_url,omitempty"`
	IssuesURL        *string `json:"issues_url,omitempty"`
	KeysURL          *string `json:"keys_url,omitempty"`
	LabelsURL        *string `json:"labels_url,omitempty"`
	LanguagesURL     *string `json:"languages_url,omitempty"`
	MergesURL        *string `json:"merges_url,omitempty"`
	MilestonesURL    *string `json:"milestones_url,omitempty"`
	NotificationsURL *string `json:"notifications_url,omitempty"`
	PullsURL         *string `json:"pulls_url,omitempty"`
	ReleasesURL      *string `json:"releases_url,omitempty"`
	StargazersURL    *string `json:"stargazers_url,omitempty"`
	StatusesURL      *string `json:"statuses_url,omitempty"`
	SubscribersURL   *string `json:"subscribers_url,omitempty"`
	SubscriptionURL  *string `json:"subscription_url,omitempty"`
	TagsURL          *string `json:"tags_url,omitempty"`
	TreesURL         *string `json:"trees_url,omitempty"`
	TeamsURL         *string `json:"teams_url,omitempty"`

	// TextMatches is only populated from search results that request text matches
	// See: search.go and https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#text-match-metadata
	TextMatches []*TextMatch `json:"text_matches,omitempty"`

	// Visibility is only used for Create and Edit endpoints. The visibility field
	// overrides the field parameter when both are used.
	// Can be one of public, private or internal.
	Visibility *string `json:"visibility,omitempty"`
}

I don't mind performing the code change if you could assign this issue to me.

@google-cla
Copy link

google-cla bot commented Jun 16, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Jun 16, 2021
@OhZedTee
Copy link
Contributor Author

OhZedTee commented Jun 16, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes Indication that the PR author has signed a Google Contributor License Agreement. and removed cla: no labels Jun 16, 2021
@OhZedTee OhZedTee force-pushed the repository_alert_fix branch from e7124dc to 96eb506 Compare June 16, 2021 15:52
@OhZedTee OhZedTee force-pushed the repository_alert_fix branch from 96eb506 to 4eb2a2a Compare June 16, 2021 15:53
@OhZedTee
Copy link
Contributor Author

Relates to Issue #1897

github/event_types.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 16, 2021

Codecov Report

Merging #1898 (7a85d1f) into master (75644ea) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1898   +/-   ##
=======================================
  Coverage   97.65%   97.65%           
=======================================
  Files         105      105           
  Lines        6786     6786           
=======================================
  Hits         6627     6627           
  Misses         86       86           
  Partials       73       73           
Impacted Files Coverage Δ
github/event_types.go 100.00% <ø> (ø)
github/repos.go 98.70% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 75644ea...7a85d1f. Read the comment docs.

Capitalization of GitHub rather than Github

Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@OhZedTee
Copy link
Contributor Author

OhZedTee commented Jun 16, 2021

Also sorry for the force push, made a mistake in my pushed commit message, wanted to fix it for clarity which required a rebase and a force push.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @OhZedTee !
LGTM.

Awaiting second LGTM before merging.

@gmlewis gmlewis requested a review from wesleimp June 16, 2021 16:14
@OhZedTee
Copy link
Contributor Author

Thanks for the help @gmlewis and @wesleimp

@gmlewis
Copy link
Collaborator

gmlewis commented Jun 24, 2021

Friendly ping @wesleimp

@OhZedTee
Copy link
Contributor Author

yes, please keep us posted as this is blocking us from completing our work using this library. Let us know if you have any questions @wesleimp

@gmlewis
Copy link
Collaborator

gmlewis commented Jun 28, 2021

@OhZedTee - as a contributor to this repo, please feel free to provide code reviews and LGTM/Approve as you have time to contribute.
Thank you!

Copy link

@Parker77 Parker77 left a comment

Choose a reason for hiding this comment

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

LGTM.

@gmlewis gmlewis merged commit c26abbd into google:master Jul 8, 2021
@OhZedTee
Copy link
Contributor Author

OhZedTee commented Jul 8, 2021

Amazing, thanks folks! I hope this gets pulled into a release soon so that we can delete all the wrapping code that we wrote.

@OhZedTee OhZedTee deleted the repository_alert_fix branch July 8, 2021 17:35
@OhZedTee OhZedTee restored the repository_alert_fix branch July 8, 2021 17:42
@gmlewis
Copy link
Collaborator

gmlewis commented Jul 9, 2021

Amazing, thanks folks! I hope this gets pulled into a release soon so that we can delete all the wrapping code that we wrote.

Thanks, @OhZedTee ! This should now be available in Release v37.0.0: https://github.com/google/go-github/releases/tag/v37.0.0

@OhZedTee
Copy link
Contributor Author

OhZedTee commented Jul 9, 2021

Amazing, thank you for all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants