diff --git a/github/code-scanning.go b/github/code-scanning.go index 9616f3a26d..e09964ba17 100644 --- a/github/code-scanning.go +++ b/github/code-scanning.go @@ -67,22 +67,26 @@ type Tool struct { // // GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository type Alert struct { - RuleID *string `json:"rule_id,omitempty"` - RuleSeverity *string `json:"rule_severity,omitempty"` - RuleDescription *string `json:"rule_description,omitempty"` - Rule *Rule `json:"rule,omitempty"` - Tool *Tool `json:"tool,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - State *string `json:"state,omitempty"` - ClosedBy *User `json:"closed_by,omitempty"` - ClosedAt *Timestamp `json:"closed_at,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` - DismissedBy *User `json:"dismissed_by,omitempty"` - DismissedAt *Timestamp `json:"dismissed_at,omitempty"` - DismissedReason *string `json:"dismissed_reason,omitempty"` - InstancesURL *string `json:"instances_url,omitempty"` + Number *int `json:"number,omitempty"` + RuleID *string `json:"rule_id,omitempty"` + RuleSeverity *string `json:"rule_severity,omitempty"` + RuleDescription *string `json:"rule_description,omitempty"` + Rule *Rule `json:"rule,omitempty"` + Tool *Tool `json:"tool,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + FixedAt *Timestamp `json:"fixed_at,omitempty"` + State *string `json:"state,omitempty"` + ClosedBy *User `json:"closed_by,omitempty"` + ClosedAt *Timestamp `json:"closed_at,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` + Instances []*MostRecentInstance `json:"instances,omitempty"` + DismissedBy *User `json:"dismissed_by,omitempty"` + DismissedAt *Timestamp `json:"dismissed_at,omitempty"` + DismissedReason *string `json:"dismissed_reason,omitempty"` + InstancesURL *string `json:"instances_url,omitempty"` } // ID returns the ID associated with an alert. It is the number at the end of the security alert's URL. diff --git a/github/event_types.go b/github/event_types.go index c940ec8f12..de729c06c3 100644 --- a/github/event_types.go +++ b/github/event_types.go @@ -1248,3 +1248,71 @@ type WorkflowRunEvent struct { Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` } + +// SecurityAdvisory represents the advisory object in SecurityAdvisoryEvent payload. +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory +type SecurityAdvisory struct { + GHSAID *string `json:"ghsa_id,omitempty"` + Summary *string `json:"summary,omitempty"` + Description *string `json:"description,omitempty"` + Severity *string `json:"severity,omitempty"` + Identifiers []*AdvisoryIdentifier `json:"identifiers,omitempty"` + References []*AdvisoryReference `json:"references,omitempty"` + PublishedAt *Timestamp `json:"published_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + WithdrawnAt *Timestamp `json:"withdrawn_at,omitempty"` + Vulnerabilities []*AdvisoryVulnerability `json:"vulnerabilities,omitempty"` +} + +// AdvisoryIdentifier represents the identifier for a Security Advisory. +type AdvisoryIdentifier struct { + Value *string `json:"value,omitempty"` + Type *string `json:"type,omitempty"` +} + +// AdvisoryReference represents the reference url for the security advisory. +type AdvisoryReference struct { + URL *string `json:"url,omitempty"` +} + +// AdvisoryVulnerability represents the vulnerability object for a Security Advisory. +type AdvisoryVulnerability struct { + Package *VulnerabilityPackage `json:"package,omitempty"` + Severity *string `json:"severity,omitempty"` + VulnerableVersionRange *string `json:"vulnerable_version_range,omitempty"` + FirstPatchedVersion *FirstPatchedVersion `json:"first_patched_version,omitempty"` +} + +// VulnerabilityPackage represents the package object for an Advisory Vulnerability. +type VulnerabilityPackage struct { + Ecosystem *string `json:"ecosystem,omitempty"` + Name *string `json:"name,omitempty"` +} + +// FirstPatchedVersion represents the identifier for the first patched version of that vulnerability. +type FirstPatchedVersion struct { + Identifier *string `json:"identifier,omitempty"` +} + +// SecurityAdvisoryEvent is triggered when a security-related vulnerability is found in software on GitHub. +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory +type SecurityAdvisoryEvent struct { + Action *string `json:"action,omitempty"` + SecurityAdvisory *SecurityAdvisory `json:"security_advisory,omitempty"` +} + +// CodeScanningAlertEvent is triggered when a code scanning finds a potential vulnerability or error in your code. +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#code_scanning_alert +type CodeScanningAlertEvent struct { + Action *string `json:"action,omitempty"` + Alert *Alert `json:"alert,omitempty"` + Ref *string `json:"ref,omitempty"` + // CommitOID is the commit SHA of the code scanning alert + CommitOID *string `json:"commit_oid,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` +} diff --git a/github/event_types_test.go b/github/event_types_test.go index c4a79b77b9..5f9dd2583d 100644 --- a/github/event_types_test.go +++ b/github/event_types_test.go @@ -13814,3 +13814,421 @@ func TestSecretScanningAlertEvent_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestSecurityAdvisoryEvent_Marshal(t *testing.T) { + testJSONMarshal(t, &SecurityAdvisoryEvent{}, "{}") + u := &SecurityAdvisoryEvent{ + Action: String("published"), + SecurityAdvisory: &SecurityAdvisory{ + GHSAID: String("GHSA-rf4j-j272-some"), + Summary: String("Siuuuuuuuuu"), + Description: String("desc"), + Severity: String("moderate"), + Identifiers: []*AdvisoryIdentifier{ + { + Value: String("GHSA-rf4j-j272-some"), + Type: String("GHSA"), + }, + }, + References: []*AdvisoryReference{ + { + URL: String("https://some-url"), + }, + }, + PublishedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + WithdrawnAt: nil, + Vulnerabilities: []*AdvisoryVulnerability{ + { + Package: &VulnerabilityPackage{ + Ecosystem: String("ucl"), + Name: String("penaldo"), + }, + Severity: String("moderate"), + VulnerableVersionRange: String(">= 2.0.0, < 2.0.2"), + FirstPatchedVersion: &FirstPatchedVersion{ + Identifier: String("2.0.2"), + }, + }, + }, + }, + } + + want := `{ + "action": "published", + "security_advisory": { + "ghsa_id": "GHSA-rf4j-j272-some", + "summary": "Siuuuuuuuuu", + "description": "desc", + "severity": "moderate", + "identifiers": [ + { + "value": "GHSA-rf4j-j272-some", + "type": "GHSA" + } + ], + "references": [ + { + "url": "https://some-url" + } + ], + "published_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "withdrawn_at": null, + "vulnerabilities": [ + { + "package": { + "ecosystem": "ucl", + "name": "penaldo" + }, + "severity": "moderate", + "vulnerable_version_range": ">= 2.0.0, < 2.0.2", + "first_patched_version": { + "identifier": "2.0.2" + } + } + ] + } + }` + + testJSONMarshal(t, u, want) +} + +func TestCodeScanningAlertEvent_Marshal(t *testing.T) { + testJSONMarshal(t, &CodeScanningAlertEvent{}, "{}") + + u := &CodeScanningAlertEvent{ + Action: String("reopened"), + Alert: &Alert{ + Number: Int(10), + Rule: &Rule{ + ID: String("Style/FrozenStringLiteralComment"), + Severity: String("note"), + Description: String("desc"), + FullDescription: String("full desc"), + Tags: []string{"style"}, + Help: String("help"), + }, + Tool: &Tool{ + Name: String("Rubocop"), + Version: nil, + }, + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + FixedAt: nil, + State: String("open"), + URL: String("a"), + HTMLURL: String("a"), + Instances: []*MostRecentInstance{ + { + Ref: String("refs/heads/main"), + AnalysisKey: String(".github/workflows/workflow.yml:upload"), + Environment: String("{}"), + State: String("open"), + }, + }, + DismissedBy: nil, + DismissedAt: nil, + DismissedReason: nil, + }, + Ref: String("refs/heads/main"), + CommitOID: String("d6e4c75c141dbacecc279b721b8bsomeSHA"), + Repo: &Repository{ + ID: Int64(1234234535), + NodeID: String("MDEwOlJlcG9zaXRvcnkxODY4NT=="), + Owner: &User{ + Login: String("Codertocat"), + ID: Int64(21031067), + NodeID: String("MDQ6VXNlcjIxMDMxMDY3"), + AvatarURL: String("a"), + GravatarID: String(""), + URL: String("a"), + HTMLURL: String("a"), + Type: String("User"), + SiteAdmin: Bool(false), + FollowersURL: String("a"), + FollowingURL: String("a"), + EventsURL: String("a"), + GistsURL: String("a"), + OrganizationsURL: String("a"), + ReceivedEventsURL: String("a"), + ReposURL: String("a"), + StarredURL: String("a"), + SubscriptionsURL: String("a"), + }, + HTMLURL: String("a"), + Name: String("Hello-World"), + FullName: String("Codertocat/Hello-World"), + Description: nil, + Fork: Bool(false), + Homepage: nil, + DefaultBranch: String("main"), + CreatedAt: &Timestamp{referenceTime}, + PushedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + CloneURL: String("a"), + GitURL: String("a"), + MirrorURL: nil, + SSHURL: String("a"), + SVNURL: String("a"), + Language: nil, + ForksCount: Int(0), + OpenIssuesCount: Int(2), + OpenIssues: Int(2), + StargazersCount: Int(0), + WatchersCount: Int(0), + Watchers: Int(0), + Size: Int(0), + Archived: Bool(false), + Disabled: Bool(false), + License: nil, + Private: Bool(false), + HasIssues: Bool(true), + HasWiki: Bool(true), + HasPages: Bool(true), + HasProjects: Bool(true), + HasDownloads: Bool(true), + URL: String("a"), + ArchiveURL: String("a"), + AssigneesURL: String("a"), + BlobsURL: String("a"), + BranchesURL: String("a"), + CollaboratorsURL: String("a"), + CommentsURL: String("a"), + CommitsURL: String("a"), + CompareURL: String("a"), + ContentsURL: String("a"), + ContributorsURL: String("a"), + DeploymentsURL: String("a"), + DownloadsURL: String("a"), + EventsURL: String("a"), + ForksURL: String("a"), + GitCommitsURL: String("a"), + GitRefsURL: String("a"), + GitTagsURL: String("a"), + HooksURL: String("a"), + IssueCommentURL: String("a"), + IssueEventsURL: String("a"), + IssuesURL: String("a"), + KeysURL: String("a"), + LabelsURL: String("a"), + LanguagesURL: String("a"), + MergesURL: String("a"), + MilestonesURL: String("a"), + NotificationsURL: String("a"), + PullsURL: String("a"), + ReleasesURL: String("a"), + StargazersURL: String("a"), + StatusesURL: String("a"), + SubscribersURL: String("a"), + SubscriptionURL: String("a"), + TagsURL: String("a"), + TreesURL: String("a"), + TeamsURL: String("a"), + }, + Org: &Organization{ + Login: String("Octocoders"), + ID: Int64(6), + NodeID: String("MDEyOk9yZ2FuaXphdGlvbjY="), + AvatarURL: String("a"), + Description: String(""), + URL: String("a"), + EventsURL: String("a"), + HooksURL: String("a"), + IssuesURL: String("a"), + MembersURL: String("a"), + PublicMembersURL: String("a"), + ReposURL: String("a"), + }, + Sender: &User{ + Login: String("github"), + ID: Int64(9919), + NodeID: String("MDEyOk9yZ2FuaXphdGlvbjk5MTk="), + AvatarURL: String("a"), + HTMLURL: String("a"), + GravatarID: String(""), + Type: String("Organization"), + SiteAdmin: Bool(false), + URL: String("a"), + EventsURL: String("a"), + FollowingURL: String("a"), + FollowersURL: String("a"), + GistsURL: String("a"), + OrganizationsURL: String("a"), + ReceivedEventsURL: String("a"), + ReposURL: String("a"), + StarredURL: String("a"), + SubscriptionsURL: String("a"), + }, + } + + want := `{ + "action": "reopened", + "alert": { + "number": 10, + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "url": "a", + "html_url": "a", + "instances": [ + { + "ref": "refs/heads/main", + "analysis_key": ".github/workflows/workflow.yml:upload", + "environment": "{}", + "state": "open" + } + ], + "state": "open", + "fixed_at": null, + "dismissed_by": null, + "dismissed_at": null, + "dismissed_reason": null, + "rule": { + "id": "Style/FrozenStringLiteralComment", + "severity": "note", + "description": "desc", + "full_description": "full desc", + "tags": [ + "style" + ], + "help": "help" + }, + "tool": { + "name": "Rubocop", + "version": null + } + }, + "ref": "refs/heads/main", + "commit_oid": "d6e4c75c141dbacecc279b721b8bsomeSHA", + "repository": { + "id": 1234234535, + "node_id": "MDEwOlJlcG9zaXRvcnkxODY4NT==", + "name": "Hello-World", + "full_name": "Codertocat/Hello-World", + "private": false, + "owner": { + "login": "Codertocat", + "id": 21031067, + "node_id": "MDQ6VXNlcjIxMDMxMDY3", + "avatar_url": "a", + "gravatar_id": "", + "url": "a", + "html_url": "a", + "followers_url": "a", + "following_url": "a", + "gists_url": "a", + "starred_url": "a", + "subscriptions_url": "a", + "organizations_url": "a", + "repos_url": "a", + "events_url": "a", + "received_events_url": "a", + "type": "User", + "site_admin": false + }, + "html_url": "a", + "description": null, + "fork": false, + "url": "a", + "forks_url": "a", + "keys_url": "a", + "collaborators_url": "a", + "teams_url": "a", + "hooks_url": "a", + "issue_events_url": "a", + "events_url": "a", + "assignees_url": "a", + "branches_url": "a", + "tags_url": "a", + "blobs_url": "a", + "git_tags_url": "a", + "git_refs_url": "a", + "trees_url": "a", + "statuses_url": "a", + "languages_url": "a", + "stargazers_url": "a", + "contributors_url": "a", + "subscribers_url": "a", + "subscription_url": "a", + "commits_url": "a", + "git_commits_url": "a", + "comments_url": "a", + "issue_comment_url": "a", + "contents_url": "a", + "compare_url": "a", + "merges_url": "a", + "archive_url": "a", + "downloads_url": "a", + "issues_url": "a", + "pulls_url": "a", + "milestones_url": "a", + "notifications_url": "a", + "labels_url": "a", + "releases_url": "a", + "deployments_url": "a", + "created_at": ` + referenceTimeStr + `, + "updated_at": ` + referenceTimeStr + `, + "pushed_at": ` + referenceTimeStr + `, + "git_url": "a", + "ssh_url": "a", + "clone_url": "a", + "svn_url": "a", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 2, + "license": null, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "main" + }, + "organization": { + "login": "Octocoders", + "id": 6, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjY=", + "url": "a", + "repos_url": "a", + "events_url": "a", + "hooks_url": "a", + "issues_url": "a", + "members_url": "a", + "public_members_url": "a", + "avatar_url": "a", + "description": "" + }, + "sender": { + "login": "github", + "id": 9919, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=", + "avatar_url": "a", + "gravatar_id": "", + "url": "a", + "html_url": "a", + "followers_url": "a", + "following_url": "a", + "gists_url": "a", + "starred_url": "a", + "subscriptions_url": "a", + "organizations_url": "a", + "repos_url": "a", + "events_url": "a", + "received_events_url": "a", + "type": "Organization", + "site_admin": false + } + }` + + testJSONMarshal(t, u, want) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index 6c13f545cd..c87c251f7b 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -172,6 +172,62 @@ func (a *AdvancedSecurityCommittersBreakdown) GetUserLogin() string { return *a.UserLogin } +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (a *AdvisoryIdentifier) GetType() string { + if a == nil || a.Type == nil { + return "" + } + return *a.Type +} + +// GetValue returns the Value field if it's non-nil, zero value otherwise. +func (a *AdvisoryIdentifier) GetValue() string { + if a == nil || a.Value == nil { + return "" + } + return *a.Value +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (a *AdvisoryReference) GetURL() string { + if a == nil || a.URL == nil { + return "" + } + return *a.URL +} + +// GetFirstPatchedVersion returns the FirstPatchedVersion field. +func (a *AdvisoryVulnerability) GetFirstPatchedVersion() *FirstPatchedVersion { + if a == nil { + return nil + } + return a.FirstPatchedVersion +} + +// GetPackage returns the Package field. +func (a *AdvisoryVulnerability) GetPackage() *VulnerabilityPackage { + if a == nil { + return nil + } + return a.Package +} + +// GetSeverity returns the Severity field if it's non-nil, zero value otherwise. +func (a *AdvisoryVulnerability) GetSeverity() string { + if a == nil || a.Severity == nil { + return "" + } + return *a.Severity +} + +// GetVulnerableVersionRange returns the VulnerableVersionRange field if it's non-nil, zero value otherwise. +func (a *AdvisoryVulnerability) GetVulnerableVersionRange() string { + if a == nil || a.VulnerableVersionRange == nil { + return "" + } + return *a.VulnerableVersionRange +} + // GetClosedAt returns the ClosedAt field if it's non-nil, zero value otherwise. func (a *Alert) GetClosedAt() Timestamp { if a == nil || a.ClosedAt == nil { @@ -220,6 +276,14 @@ func (a *Alert) GetDismissedReason() string { return *a.DismissedReason } +// GetFixedAt returns the FixedAt field if it's non-nil, zero value otherwise. +func (a *Alert) GetFixedAt() Timestamp { + if a == nil || a.FixedAt == nil { + return Timestamp{} + } + return *a.FixedAt +} + // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. func (a *Alert) GetHTMLURL() string { if a == nil || a.HTMLURL == nil { @@ -244,6 +308,14 @@ func (a *Alert) GetMostRecentInstance() *MostRecentInstance { return a.MostRecentInstance } +// GetNumber returns the Number field if it's non-nil, zero value otherwise. +func (a *Alert) GetNumber() int { + if a == nil || a.Number == nil { + return 0 + } + return *a.Number +} + // GetRule returns the Rule field. func (a *Alert) GetRule() *Rule { if a == nil { @@ -292,6 +364,14 @@ func (a *Alert) GetTool() *Tool { return a.Tool } +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *Alert) GetUpdatedAt() Timestamp { + if a == nil || a.UpdatedAt == nil { + return Timestamp{} + } + return *a.UpdatedAt +} + // GetURL returns the URL field if it's non-nil, zero value otherwise. func (a *Alert) GetURL() string { if a == nil || a.URL == nil { @@ -2212,6 +2292,62 @@ func (c *CodeResult) GetSHA() string { return *c.SHA } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (c *CodeScanningAlertEvent) GetAction() string { + if c == nil || c.Action == nil { + return "" + } + return *c.Action +} + +// GetAlert returns the Alert field. +func (c *CodeScanningAlertEvent) GetAlert() *Alert { + if c == nil { + return nil + } + return c.Alert +} + +// GetCommitOID returns the CommitOID field if it's non-nil, zero value otherwise. +func (c *CodeScanningAlertEvent) GetCommitOID() string { + if c == nil || c.CommitOID == nil { + return "" + } + return *c.CommitOID +} + +// GetOrg returns the Org field. +func (c *CodeScanningAlertEvent) GetOrg() *Organization { + if c == nil { + return nil + } + return c.Org +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (c *CodeScanningAlertEvent) GetRef() string { + if c == nil || c.Ref == nil { + return "" + } + return *c.Ref +} + +// GetRepo returns the Repo field. +func (c *CodeScanningAlertEvent) GetRepo() *Repository { + if c == nil { + return nil + } + return c.Repo +} + +// GetSender returns the Sender field. +func (c *CodeScanningAlertEvent) GetSender() *User { + if c == nil { + return nil + } + return c.Sender +} + // GetIncompleteResults returns the IncompleteResults field if it's non-nil, zero value otherwise. func (c *CodeSearchResult) GetIncompleteResults() bool { if c == nil || c.IncompleteResults == nil { @@ -4932,6 +5068,14 @@ func (f *Feeds) GetUserURL() string { return *f.UserURL } +// GetIdentifier returns the Identifier field if it's non-nil, zero value otherwise. +func (f *FirstPatchedVersion) GetIdentifier() string { + if f == nil || f.Identifier == nil { + return "" + } + return *f.Identifier +} + // GetForkee returns the Forkee field. func (f *ForkEvent) GetForkee() *Repository { if f == nil { @@ -16236,6 +16380,78 @@ func (s *SecretScanningAlertUpdateOptions) GetState() string { return *s.State } +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetDescription() string { + if s == nil || s.Description == nil { + return "" + } + return *s.Description +} + +// GetGHSAID returns the GHSAID field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetGHSAID() string { + if s == nil || s.GHSAID == nil { + return "" + } + return *s.GHSAID +} + +// GetPublishedAt returns the PublishedAt field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetPublishedAt() Timestamp { + if s == nil || s.PublishedAt == nil { + return Timestamp{} + } + return *s.PublishedAt +} + +// GetSeverity returns the Severity field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetSeverity() string { + if s == nil || s.Severity == nil { + return "" + } + return *s.Severity +} + +// GetSummary returns the Summary field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetSummary() string { + if s == nil || s.Summary == nil { + return "" + } + return *s.Summary +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetUpdatedAt() Timestamp { + if s == nil || s.UpdatedAt == nil { + return Timestamp{} + } + return *s.UpdatedAt +} + +// GetWithdrawnAt returns the WithdrawnAt field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetWithdrawnAt() Timestamp { + if s == nil || s.WithdrawnAt == nil { + return Timestamp{} + } + return *s.WithdrawnAt +} + +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisoryEvent) GetAction() string { + if s == nil || s.Action == nil { + return "" + } + return *s.Action +} + +// GetSecurityAdvisory returns the SecurityAdvisory field. +func (s *SecurityAdvisoryEvent) GetSecurityAdvisory() *SecurityAdvisory { + if s == nil { + return nil + } + return s.SecurityAdvisory +} + // GetAdvancedSecurity returns the AdvancedSecurity field. func (s *SecurityAndAnalysis) GetAdvancedSecurity() *AdvancedSecurity { if s == nil { @@ -18732,6 +18948,22 @@ func (u *UserSuspendOptions) GetReason() string { return *u.Reason } +// GetEcosystem returns the Ecosystem field if it's non-nil, zero value otherwise. +func (v *VulnerabilityPackage) GetEcosystem() string { + if v == nil || v.Ecosystem == nil { + return "" + } + return *v.Ecosystem +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (v *VulnerabilityPackage) GetName() string { + if v == nil || v.Name == nil { + return "" + } + return *v.Name +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (w *WatchEvent) GetAction() string { if w == nil || w.Action == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index d06e6356d7..1b0556fd4d 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -183,6 +183,70 @@ func TestAdvancedSecurityCommittersBreakdown_GetUserLogin(tt *testing.T) { a.GetUserLogin() } +func TestAdvisoryIdentifier_GetType(tt *testing.T) { + var zeroValue string + a := &AdvisoryIdentifier{Type: &zeroValue} + a.GetType() + a = &AdvisoryIdentifier{} + a.GetType() + a = nil + a.GetType() +} + +func TestAdvisoryIdentifier_GetValue(tt *testing.T) { + var zeroValue string + a := &AdvisoryIdentifier{Value: &zeroValue} + a.GetValue() + a = &AdvisoryIdentifier{} + a.GetValue() + a = nil + a.GetValue() +} + +func TestAdvisoryReference_GetURL(tt *testing.T) { + var zeroValue string + a := &AdvisoryReference{URL: &zeroValue} + a.GetURL() + a = &AdvisoryReference{} + a.GetURL() + a = nil + a.GetURL() +} + +func TestAdvisoryVulnerability_GetFirstPatchedVersion(tt *testing.T) { + a := &AdvisoryVulnerability{} + a.GetFirstPatchedVersion() + a = nil + a.GetFirstPatchedVersion() +} + +func TestAdvisoryVulnerability_GetPackage(tt *testing.T) { + a := &AdvisoryVulnerability{} + a.GetPackage() + a = nil + a.GetPackage() +} + +func TestAdvisoryVulnerability_GetSeverity(tt *testing.T) { + var zeroValue string + a := &AdvisoryVulnerability{Severity: &zeroValue} + a.GetSeverity() + a = &AdvisoryVulnerability{} + a.GetSeverity() + a = nil + a.GetSeverity() +} + +func TestAdvisoryVulnerability_GetVulnerableVersionRange(tt *testing.T) { + var zeroValue string + a := &AdvisoryVulnerability{VulnerableVersionRange: &zeroValue} + a.GetVulnerableVersionRange() + a = &AdvisoryVulnerability{} + a.GetVulnerableVersionRange() + a = nil + a.GetVulnerableVersionRange() +} + func TestAlert_GetClosedAt(tt *testing.T) { var zeroValue Timestamp a := &Alert{ClosedAt: &zeroValue} @@ -237,6 +301,16 @@ func TestAlert_GetDismissedReason(tt *testing.T) { a.GetDismissedReason() } +func TestAlert_GetFixedAt(tt *testing.T) { + var zeroValue Timestamp + a := &Alert{FixedAt: &zeroValue} + a.GetFixedAt() + a = &Alert{} + a.GetFixedAt() + a = nil + a.GetFixedAt() +} + func TestAlert_GetHTMLURL(tt *testing.T) { var zeroValue string a := &Alert{HTMLURL: &zeroValue} @@ -264,6 +338,16 @@ func TestAlert_GetMostRecentInstance(tt *testing.T) { a.GetMostRecentInstance() } +func TestAlert_GetNumber(tt *testing.T) { + var zeroValue int + a := &Alert{Number: &zeroValue} + a.GetNumber() + a = &Alert{} + a.GetNumber() + a = nil + a.GetNumber() +} + func TestAlert_GetRule(tt *testing.T) { a := &Alert{} a.GetRule() @@ -318,6 +402,16 @@ func TestAlert_GetTool(tt *testing.T) { a.GetTool() } +func TestAlert_GetUpdatedAt(tt *testing.T) { + var zeroValue Timestamp + a := &Alert{UpdatedAt: &zeroValue} + a.GetUpdatedAt() + a = &Alert{} + a.GetUpdatedAt() + a = nil + a.GetUpdatedAt() +} + func TestAlert_GetURL(tt *testing.T) { var zeroValue string a := &Alert{URL: &zeroValue} @@ -2613,6 +2707,64 @@ func TestCodeResult_GetSHA(tt *testing.T) { c.GetSHA() } +func TestCodeScanningAlertEvent_GetAction(tt *testing.T) { + var zeroValue string + c := &CodeScanningAlertEvent{Action: &zeroValue} + c.GetAction() + c = &CodeScanningAlertEvent{} + c.GetAction() + c = nil + c.GetAction() +} + +func TestCodeScanningAlertEvent_GetAlert(tt *testing.T) { + c := &CodeScanningAlertEvent{} + c.GetAlert() + c = nil + c.GetAlert() +} + +func TestCodeScanningAlertEvent_GetCommitOID(tt *testing.T) { + var zeroValue string + c := &CodeScanningAlertEvent{CommitOID: &zeroValue} + c.GetCommitOID() + c = &CodeScanningAlertEvent{} + c.GetCommitOID() + c = nil + c.GetCommitOID() +} + +func TestCodeScanningAlertEvent_GetOrg(tt *testing.T) { + c := &CodeScanningAlertEvent{} + c.GetOrg() + c = nil + c.GetOrg() +} + +func TestCodeScanningAlertEvent_GetRef(tt *testing.T) { + var zeroValue string + c := &CodeScanningAlertEvent{Ref: &zeroValue} + c.GetRef() + c = &CodeScanningAlertEvent{} + c.GetRef() + c = nil + c.GetRef() +} + +func TestCodeScanningAlertEvent_GetRepo(tt *testing.T) { + c := &CodeScanningAlertEvent{} + c.GetRepo() + c = nil + c.GetRepo() +} + +func TestCodeScanningAlertEvent_GetSender(tt *testing.T) { + c := &CodeScanningAlertEvent{} + c.GetSender() + c = nil + c.GetSender() +} + func TestCodeSearchResult_GetIncompleteResults(tt *testing.T) { var zeroValue bool c := &CodeSearchResult{IncompleteResults: &zeroValue} @@ -5761,6 +5913,16 @@ func TestFeeds_GetUserURL(tt *testing.T) { f.GetUserURL() } +func TestFirstPatchedVersion_GetIdentifier(tt *testing.T) { + var zeroValue string + f := &FirstPatchedVersion{Identifier: &zeroValue} + f.GetIdentifier() + f = &FirstPatchedVersion{} + f.GetIdentifier() + f = nil + f.GetIdentifier() +} + func TestForkEvent_GetForkee(tt *testing.T) { f := &ForkEvent{} f.GetForkee() @@ -18997,6 +19159,93 @@ func TestSecretScanningAlertUpdateOptions_GetState(tt *testing.T) { s.GetState() } +func TestSecurityAdvisory_GetDescription(tt *testing.T) { + var zeroValue string + s := &SecurityAdvisory{Description: &zeroValue} + s.GetDescription() + s = &SecurityAdvisory{} + s.GetDescription() + s = nil + s.GetDescription() +} + +func TestSecurityAdvisory_GetGHSAID(tt *testing.T) { + var zeroValue string + s := &SecurityAdvisory{GHSAID: &zeroValue} + s.GetGHSAID() + s = &SecurityAdvisory{} + s.GetGHSAID() + s = nil + s.GetGHSAID() +} + +func TestSecurityAdvisory_GetPublishedAt(tt *testing.T) { + var zeroValue Timestamp + s := &SecurityAdvisory{PublishedAt: &zeroValue} + s.GetPublishedAt() + s = &SecurityAdvisory{} + s.GetPublishedAt() + s = nil + s.GetPublishedAt() +} + +func TestSecurityAdvisory_GetSeverity(tt *testing.T) { + var zeroValue string + s := &SecurityAdvisory{Severity: &zeroValue} + s.GetSeverity() + s = &SecurityAdvisory{} + s.GetSeverity() + s = nil + s.GetSeverity() +} + +func TestSecurityAdvisory_GetSummary(tt *testing.T) { + var zeroValue string + s := &SecurityAdvisory{Summary: &zeroValue} + s.GetSummary() + s = &SecurityAdvisory{} + s.GetSummary() + s = nil + s.GetSummary() +} + +func TestSecurityAdvisory_GetUpdatedAt(tt *testing.T) { + var zeroValue Timestamp + s := &SecurityAdvisory{UpdatedAt: &zeroValue} + s.GetUpdatedAt() + s = &SecurityAdvisory{} + s.GetUpdatedAt() + s = nil + s.GetUpdatedAt() +} + +func TestSecurityAdvisory_GetWithdrawnAt(tt *testing.T) { + var zeroValue Timestamp + s := &SecurityAdvisory{WithdrawnAt: &zeroValue} + s.GetWithdrawnAt() + s = &SecurityAdvisory{} + s.GetWithdrawnAt() + s = nil + s.GetWithdrawnAt() +} + +func TestSecurityAdvisoryEvent_GetAction(tt *testing.T) { + var zeroValue string + s := &SecurityAdvisoryEvent{Action: &zeroValue} + s.GetAction() + s = &SecurityAdvisoryEvent{} + s.GetAction() + s = nil + s.GetAction() +} + +func TestSecurityAdvisoryEvent_GetSecurityAdvisory(tt *testing.T) { + s := &SecurityAdvisoryEvent{} + s.GetSecurityAdvisory() + s = nil + s.GetSecurityAdvisory() +} + func TestSecurityAndAnalysis_GetAdvancedSecurity(tt *testing.T) { s := &SecurityAndAnalysis{} s.GetAdvancedSecurity() @@ -21940,6 +22189,26 @@ func TestUserSuspendOptions_GetReason(tt *testing.T) { u.GetReason() } +func TestVulnerabilityPackage_GetEcosystem(tt *testing.T) { + var zeroValue string + v := &VulnerabilityPackage{Ecosystem: &zeroValue} + v.GetEcosystem() + v = &VulnerabilityPackage{} + v.GetEcosystem() + v = nil + v.GetEcosystem() +} + +func TestVulnerabilityPackage_GetName(tt *testing.T) { + var zeroValue string + v := &VulnerabilityPackage{Name: &zeroValue} + v.GetName() + v = &VulnerabilityPackage{} + v.GetName() + v = nil + v.GetName() +} + func TestWatchEvent_GetAction(tt *testing.T) { var zeroValue string w := &WatchEvent{Action: &zeroValue}