Skip to content

Commit 7e3bb17

Browse files
authored
Add Dependabot field in security_and_analysis (#2846)
Fixes: #2845.
1 parent 4074b7c commit 7e3bb17

File tree

5 files changed

+73
-3
lines changed

5 files changed

+73
-3
lines changed

github/github-accessors.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-stringify_test.go

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ type SecurityAndAnalysis struct {
210210
AdvancedSecurity *AdvancedSecurity `json:"advanced_security,omitempty"`
211211
SecretScanning *SecretScanning `json:"secret_scanning,omitempty"`
212212
SecretScanningPushProtection *SecretScanningPushProtection `json:"secret_scanning_push_protection,omitempty"`
213+
DependabotSecurityUpdates *DependabotSecurityUpdates `json:"dependabot_security_updates,omitempty"`
213214
}
214215

215216
func (s SecurityAndAnalysis) String() string {
@@ -245,6 +246,21 @@ type SecretScanningPushProtection struct {
245246
Status *string `json:"status,omitempty"`
246247
}
247248

249+
func (s SecretScanningPushProtection) String() string {
250+
return Stringify(s)
251+
}
252+
253+
// DependabotSecurityUpdates specifies the state of Dependabot security updates on a repository.
254+
//
255+
// GitHub API docs: https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates
256+
type DependabotSecurityUpdates struct {
257+
Status *string `json:"status,omitempty"`
258+
}
259+
260+
func (d DependabotSecurityUpdates) String() string {
261+
return Stringify(d)
262+
}
263+
248264
// List the repositories for a user. Passing the empty string will list
249265
// repositories for the authenticated user.
250266
//

github/repos_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func TestRepositoriesService_Get(t *testing.T) {
360360
mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) {
361361
testMethod(t, r, "GET")
362362
testHeader(t, r, "Accept", strings.Join(wantAcceptHeaders, ", "))
363-
fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"},"security_and_analysis":{"advanced_security":{"status":"enabled"},"secret_scanning":{"status":"enabled"},"secret_scanning_push_protection":{"status":"enabled"}}}`)
363+
fmt.Fprint(w, `{"id":1,"name":"n","description":"d","owner":{"login":"l"},"license":{"key":"mit"},"security_and_analysis":{"advanced_security":{"status":"enabled"},"secret_scanning":{"status":"enabled"},"secret_scanning_push_protection":{"status":"enabled"},"dependabot_security_updates":{"status": "enabled"}}}`)
364364
})
365365

366366
ctx := context.Background()
@@ -369,7 +369,7 @@ func TestRepositoriesService_Get(t *testing.T) {
369369
t.Errorf("Repositories.Get returned error: %v", err)
370370
}
371371

372-
want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}, SecurityAndAnalysis: &SecurityAndAnalysis{AdvancedSecurity: &AdvancedSecurity{Status: String("enabled")}, SecretScanning: &SecretScanning{String("enabled")}, SecretScanningPushProtection: &SecretScanningPushProtection{String("enabled")}}}
372+
want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}, SecurityAndAnalysis: &SecurityAndAnalysis{AdvancedSecurity: &AdvancedSecurity{Status: String("enabled")}, SecretScanning: &SecretScanning{String("enabled")}, SecretScanningPushProtection: &SecretScanningPushProtection{String("enabled")}, DependabotSecurityUpdates: &DependabotSecurityUpdates{String("enabled")}}}
373373
if !cmp.Equal(got, want) {
374374
t.Errorf("Repositories.Get returned %+v, want %+v", got, want)
375375
}

0 commit comments

Comments
 (0)