Repository: google/go-github
Pull request #3319 (2024-10-09 19:35:53)

feat: Support Code Security Configurations API
This PR implements Code Security Configurations APIs as defined at https://docs.github.com/en/rest/code-security/configurations?apiVersion=2022-11-28

Fixes https://github.com/google/go-github/issues/3211

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3319?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
Attention: Patch coverage is `61.40351%` with `44 lines` in your changes missing coverage. Please review.
> Project coverage is 92.74%. Comparing base [(`2b8c7fa`)](https://app.codecov.io/gh/google/go-github/commit/2b8c7fa86fcd1cb4a89a44c8e7b5a49fe4be8a45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`c8041cd`)](https://app.codecov.io/gh/google/go-github/commit/c8041cdd84ce97c0ed3e1f04ccab262604943663?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 143 commits behind head on master.

| [Files with missing lines](https://app.codecov.io/gh/google/go-github/pull/3319?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Patch % | Lines |
|---|---|---|
| [github/orgs\_codesecurity\_configurations.go](https://app.codecov.io/gh/google/go-github/pull/3319?src=pr&el=tree&filepath=github%2Forgs_codesecurity_configurations.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL29yZ3NfY29kZXNlY3VyaXR5X2NvbmZpZ3VyYXRpb25zLmdv) | 61.40% | [22 Missing and 22 partials :warning: ](https://app.codecov.io/gh/google/go-github/pull/3319?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3319      +/-   ##
==========================================
- Coverage   97.72%   92.74%   -4.98%     
==========================================
  Files         153      173      +20     
  Lines       13390    11874    -1516     
==========================================
- Hits        13085    11013    -2072     
- Misses        215      745     +530     
- Partials       90      116      +26     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3319?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

maditya: @gmlewis Thanks!
I tried and fixed `go generate ./...` which updated a bunch of other files.
But `metadata` script is failing -

```
ambiguous operation "GET /user/{user_id}" could match any of: [GET /user/{account_id} GET /user/{user_id}]
github/github.go:8: running "../script/metadata.sh": exit status 1
```
Any idea how to address it? Doesn't seem related to the new API.
gmlewis: > Any idea how to address it?

Hmmm... a lot more files changed than I expected.
It looks like you may have locally updated the OpenAPI specs, which is typically done by a maintainer of the repo.

We have two options:
1. revert the changes to all the files except your original two, then run `go generate ./...` 
2. wait for another PR to update all the OpenAPI stuff and fix all the errors you are seeing

I think option 1 is probably better since option 2 may take a while, and I'm currently monitoring a hurricane locally.
maditya: >  revert the changes to all the files except your original two, then run go generate ./...

Done. Note that `go generate ./...` updates some other files, namely `github/admin_users.go`, `github/github-accessors.go` and `github/github-accessors_test.go` and will fail until `openapi_operations.yaml` is updated. I get these errors: 
```
could not find operation "GET /orgs/{org}/code-security/configurations" in openapi_operations.yaml
could not find operation "POST /orgs/{org}/code-security/configurations" in openapi_operations.yaml
could not find operation "GET /orgs/{org}/code-security/configurations/defaults" in openapi_operations.yaml
could not find operation "DELETE /orgs/{org}/code-security/configurations/detach" in openapi_operations.yaml
could not find operation "GET /orgs/{org}/code-security/configurations/{configuration_id}" in openapi_operations.yaml
could not find operation "PATCH /orgs/{org}/code-security/configurations/{configuration_id}" in openapi_operations.yaml
could not find operation "DELETE /orgs/{org}/code-security/configurations/{configuration_id}" in openapi_operations.yaml
could not find operation "POST /orgs/{org}/code-security/configurations/{configuration_id}/attach" in openapi_operations.yaml
could not find operation "PUT /orgs/{org}/code-security/configurations/{configuration_id}/defaults" in openapi_operations.yaml
could not find operation "GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories" in openapi_operations.yaml
could not find operation "GET /repos/{owner}/{repo}/code-security-configuration" in openapi_operations.yaml
github/github.go:8: running "../script/metadata.sh": exit status 1
```
gmlewis: > Note that `go generate ./...` updates some other files

That is really strange. 
`go generate ./...` should only update three files (as needed):

* github/github-accessors.go 
* github/github-accessors_test.go
* github/github-stringify_test.go

I'm going to make a new branch locally with just your changes to your two files and run `go generate ./...` and see what happens for me and report back.
gmlewis: > I'm going to make a new branch locally with just your changes to your two files and run `go generate ./...` and see what happens for me and report back.

Ah, I see what is going on now.  You are adding support for new operations not yet defined in our local OpenAPI yaml.

This section in CONTRIBUTING.md is pertinent to you:

> ### openapi_operations.yaml
> 
> Most contributors won't need to interact with `openapi_operations.yaml`, but it
> may be useful to know what it is. Its sections are:
> ...

So you can either attempt to update it yourself by running `script/metadata.sh update-openapi` and then work out any issues you find, or I can do that in a separate PR.  Which would you prefer?
gmlewis: EDIT: I've gone ahead and created #3322 which you should be able to merge into your PR (from master once I merge it), which should make the rest of this PR easier to finish.

It looks like (in addition to the code generation), the tests need to have more coverage by using existing test helper methods like `testBadOptions` and `testNewRequestAndDoFailure`. You can see these in the GitHub UI.

Patch:
diff --git a/.golangci.yml b/.golangci.yml
index 2bfeaaa2..43103588 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -6,11 +6,13 @@ linters:
   enable:
     - dogsled
     - dupl
+    - godot
     - gofmt
     - goimports
     - gosec
     - misspell
     - nakedret
+    - perfsprint
     - paralleltest
     - stylecheck
     - tparallel
@@ -24,6 +26,9 @@ linters-settings:
       - G104
       # int(os.Stdin.Fd())
       - G115
+  perfsprint:
+    errorf: true
+    strconcat: false
 issues:
   exclude-use-default: false
   exclude-rules:
@@ -56,3 +61,7 @@ issues:
     # We don't run parallel integration tests
     - linters: [ paralleltest, tparallel ]
       path: '^test/integration'
+
+    # Because fmt.Sprint(reset.Unix())) is more readable than strconv.FormatInt(reset.Unix(), 10).
+    - linters: [ perfsprint]
+      text: 'fmt.Sprint.* can be replaced with faster strconv.FormatInt'
diff --git a/example/codespaces/newreposecretwithxcrypto/main.go b/example/codespaces/newreposecretwithxcrypto/main.go
index bd6033ec..df7cd97f 100644
--- a/example/codespaces/newreposecretwithxcrypto/main.go
+++ b/example/codespaces/newreposecretwithxcrypto/main.go
@@ -31,6 +31,7 @@ import (
 	"context"
 	crypto_rand "crypto/rand"
 	"encoding/base64"
+	"errors"
 	"flag"
 	"fmt"
 	"log"
@@ -84,7 +85,7 @@ func main() {
 func getSecretName() (string, error) {
 	secretName := flag.Arg(0)
 	if secretName == "" {
-		return "", fmt.Errorf("missing argument secret name")
+		return "", errors.New("missing argument secret name")
 	}
 	return secretName, nil
 }
diff --git a/example/codespaces/newusersecretwithxcrypto/main.go b/example/codespaces/newusersecretwithxcrypto/main.go
index e1fec87d..e306ae3d 100644
--- a/example/codespaces/newusersecretwithxcrypto/main.go
+++ b/example/codespaces/newusersecretwithxcrypto/main.go
@@ -32,6 +32,7 @@ import (
 	"context"
 	crypto_rand "crypto/rand"
 	"encoding/base64"
+	"errors"
 	"flag"
 	"fmt"
 	"log"
@@ -77,7 +78,7 @@ func main() {
 func getSecretName() (string, error) {
 	secretName := flag.Arg(0)
 	if secretName == "" {
-		return "", fmt.Errorf("missing argument secret name")
+		return "", errors.New("missing argument secret name")
 	}
 	return secretName, nil
 }
diff --git a/example/newreposecretwithxcrypto/main.go b/example/newreposecretwithxcrypto/main.go
index 6737263a..9c1a42b0 100644
--- a/example/newreposecretwithxcrypto/main.go
+++ b/example/newreposecretwithxcrypto/main.go
@@ -31,6 +31,7 @@ import (
 	"context"
 	crypto_rand "crypto/rand"
 	"encoding/base64"
+	"errors"
 	"flag"
 	"fmt"
 	"log"
@@ -84,7 +85,7 @@ func main() {
 func getSecretName() (string, error) {
 	secretName := flag.Arg(0)
 	if secretName == "" {
-		return "", fmt.Errorf("missing argument secret name")
+		return "", errors.New("missing argument secret name")
 	}
 	return secretName, nil
 }
diff --git a/example/tokenauth/main.go b/example/tokenauth/main.go
index 71d4c20c..0c8f39f8 100644
--- a/example/tokenauth/main.go
+++ b/example/tokenauth/main.go
@@ -22,7 +22,7 @@ import (
 func main() {
 	fmt.Print("GitHub Token: ")
 	token, _ := term.ReadPassword(int(os.Stdin.Fd()))
-	println()
+	fmt.Println()
 
 	ctx := context.Background()
 	client := github.NewClient(nil).WithAuthToken(string(token))
diff --git a/example/topics/main.go b/example/topics/main.go
index ec3c3686..b95282ed 100644
--- a/example/topics/main.go
+++ b/example/topics/main.go
@@ -15,7 +15,7 @@ import (
 	"github.com/google/go-github/v66/github"
 )
 
-// Fetch and lists all the public topics associated with the specified GitHub topic
+// Fetch and lists all the public topics associated with the specified GitHub topic.
 func fetchTopics(topic string) (*github.TopicsSearchResult, error) {
 	client := github.NewClient(nil)
 	topics, _, err := client.Search.Topics(context.Background(), topic, nil)
diff --git a/github/authorizations.go b/github/authorizations.go
index a9b0e8d2..5e63a3ef 100644
--- a/github/authorizations.go
+++ b/github/authorizations.go
@@ -15,7 +15,7 @@ import (
 // GitHub API docs: https://docs.github.com/rest/oauth/#scopes
 type Scope string
 
-// This is the set of scopes for GitHub API V3
+// This is the set of scopes for GitHub API V3.
 const (
 	ScopeNone           Scope = "(no scope)" // REVISIT: is this actually returned, or just a documentation artifact?
 	ScopeUser           Scope = "user"
diff --git a/github/checks.go b/github/checks.go
index 71e50c15..711be207 100644
--- a/github/checks.go
+++ b/github/checks.go
@@ -401,7 +401,7 @@ type CheckSuitePreferenceResults struct {
 	Repository  *Repository     `json:"repository,omitempty"`
 }
 
-// PreferenceList represents a list of auto trigger checks for repository
+// PreferenceList represents a list of auto trigger checks for repository.
 type PreferenceList struct {
 	AutoTriggerChecks []*AutoTriggerCheck `json:"auto_trigger_checks,omitempty"` // A slice of auto trigger checks that can be set for a check suite in a repository.
 }
@@ -429,7 +429,7 @@ func (s *ChecksService) SetCheckSuitePreferences(ctx context.Context, owner, rep
 	return checkSuitePrefResults, resp, nil
 }
 
-// CreateCheckSuiteOptions sets up parameters to manually create a check suites
+// CreateCheckSuiteOptions sets up parameters to manually create a check suites.
 type CreateCheckSuiteOptions struct {
 	HeadSHA    string  `json:"head_sha"`              // The sha of the head commit. (Required.)
 	HeadBranch *string `json:"head_branch,omitempty"` // The name of the head branch where the code changes are implemented.
diff --git a/github/codesofconduct.go b/github/codesofconduct.go
index 7d7f9ef8..aba05741 100644
--- a/github/codesofconduct.go
+++ b/github/codesofconduct.go
@@ -50,7 +50,7 @@ func (s *CodesOfConductService) List(ctx context.Context) ([]*CodeOfConduct, *Re
 
 // ListCodesOfConduct returns all codes of conduct.
 //
-// Deprecated: Use CodesOfConductService.List instead
+// Deprecated: Use CodesOfConductService.List instead.
 func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Response, error) {
 	return c.CodesOfConduct.List(ctx)
 }
@@ -81,7 +81,7 @@ func (s *CodesOfConductService) Get(ctx context.Context, key string) (*CodeOfCon
 
 // GetCodeOfConduct returns an individual code of conduct.
 //
-// Deprecated: Use CodesOfConductService.Get instead
+// Deprecated: Use CodesOfConductService.Get instead.
 func (c *Client) GetCodeOfConduct(ctx context.Context, key string) (*CodeOfConduct, *Response, error) {
 	return c.CodesOfConduct.Get(ctx, key)
 }
diff --git a/github/copilot.go b/github/copilot.go
index 2697b718..349b16eb 100644
--- a/github/copilot.go
+++ b/github/copilot.go
@@ -8,6 +8,7 @@ package github
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 )
 
@@ -87,7 +88,7 @@ func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error {
 		}
 
 		if v["type"] == nil {
-			return fmt.Errorf("assignee type field is not set")
+			return errors.New("assignee type field is not set")
 		}
 
 		if t, ok := v["type"].(string); ok && t == "User" {
diff --git a/github/emojis.go b/github/emojis.go
index 93ef232f..b7a03dd9 100644
--- a/github/emojis.go
+++ b/github/emojis.go
@@ -34,7 +34,7 @@ func (s *EmojisService) List(ctx context.Context) (map[string]string, *Response,
 
 // ListEmojis returns the emojis available to use on GitHub.
 //
-// Deprecated: Use EmojisService.List instead
+// Deprecated: Use EmojisService.List instead.
 func (c *Client) ListEmojis(ctx context.Context) (map[string]string, *Response, error) {
 	return c.Emojis.List(ctx)
 }
diff --git a/github/git_commits.go b/github/git_commits.go
index 573d38be..fdb3d26c 100644
--- a/github/git_commits.go
+++ b/github/git_commits.go
@@ -129,7 +129,7 @@ type CreateCommitOptions struct {
 //meta:operation POST /repos/{owner}/{repo}/git/commits
 func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit, opts *CreateCommitOptions) (*Commit, *Response, error) {
 	if commit == nil {
-		return nil, nil, fmt.Errorf("commit must be provided")
+		return nil, nil, errors.New("commit must be provided")
 	}
 	if opts == nil {
 		opts = &CreateCommitOptions{}
diff --git a/github/github-accessors.go b/github/github-accessors.go
index f3a16c10..7995145f 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -2662,6 +2662,190 @@ func (c *CodeSearchResult) GetTotal() int {
 	return *c.Total
 }
 
+// GetAdvancedSecurity returns the AdvancedSecurity field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetAdvancedSecurity() string {
+	if c == nil || c.AdvancedSecurity == nil {
+		return ""
+	}
+	return *c.AdvancedSecurity
+}
+
+// GetCodeScanningDefaultSetup returns the CodeScanningDefaultSetup field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetCodeScanningDefaultSetup() string {
+	if c == nil || c.CodeScanningDefaultSetup == nil {
+		return ""
+	}
+	return *c.CodeScanningDefaultSetup
+}
+
+// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetCreatedAt() Timestamp {
+	if c == nil || c.CreatedAt == nil {
+		return Timestamp{}
+	}
+	return *c.CreatedAt
+}
+
+// GetDependabotAlerts returns the DependabotAlerts field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetDependabotAlerts() string {
+	if c == nil || c.DependabotAlerts == nil {
+		return ""
+	}
+	return *c.DependabotAlerts
+}
+
+// GetDependabotSecurityUpdates returns the DependabotSecurityUpdates field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetDependabotSecurityUpdates() string {
+	if c == nil || c.DependabotSecurityUpdates == nil {
+		return ""
+	}
+	return *c.DependabotSecurityUpdates
+}
+
+// GetDependencyGraph returns the DependencyGraph field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetDependencyGraph() string {
+	if c == nil || c.DependencyGraph == nil {
+		return ""
+	}
+	return *c.DependencyGraph
+}
+
+// GetDependencyGraphAutosubmitAction returns the DependencyGraphAutosubmitAction field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetDependencyGraphAutosubmitAction() string {
+	if c == nil || c.DependencyGraphAutosubmitAction == nil {
+		return ""
+	}
+	return *c.DependencyGraphAutosubmitAction
+}
+
+// GetDependencyGraphAutosubmitActionOptions returns the DependencyGraphAutosubmitActionOptions field.
+func (c *CodeSecurityConfiguration) GetDependencyGraphAutosubmitActionOptions() *DependencyGraphAutosubmitActionOptions {
+	if c == nil {
+		return nil
+	}
+	return c.DependencyGraphAutosubmitActionOptions
+}
+
+// GetDescription returns the Description field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetDescription() string {
+	if c == nil || c.Description == nil {
+		return ""
+	}
+	return *c.Description
+}
+
+// GetEnforcement returns the Enforcement field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetEnforcement() string {
+	if c == nil || c.Enforcement == nil {
+		return ""
+	}
+	return *c.Enforcement
+}
+
+// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetHTMLURL() string {
+	if c == nil || c.HTMLURL == nil {
+		return ""
+	}
+	return *c.HTMLURL
+}
+
+// GetID returns the ID field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetID() int64 {
+	if c == nil || c.ID == nil {
+		return 0
+	}
+	return *c.ID
+}
+
+// GetName returns the Name field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetName() string {
+	if c == nil || c.Name == nil {
+		return ""
+	}
+	return *c.Name
+}
+
+// GetPrivateVulnerabilityReporting returns the PrivateVulnerabilityReporting field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetPrivateVulnerabilityReporting() string {
+	if c == nil || c.PrivateVulnerabilityReporting == nil {
+		return ""
+	}
+	return *c.PrivateVulnerabilityReporting
+}
+
+// GetSecretScanning returns the SecretScanning field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetSecretScanning() string {
+	if c == nil || c.SecretScanning == nil {
+		return ""
+	}
+	return *c.SecretScanning
+}
+
+// GetSecretScanningNonProviderPatterns returns the SecretScanningNonProviderPatterns field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetSecretScanningNonProviderPatterns() string {
+	if c == nil || c.SecretScanningNonProviderPatterns == nil {
+		return ""
+	}
+	return *c.SecretScanningNonProviderPatterns
+}
+
+// GetSecretScanningPushProtection returns the SecretScanningPushProtection field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetSecretScanningPushProtection() string {
+	if c == nil || c.SecretScanningPushProtection == nil {
+		return ""
+	}
+	return *c.SecretScanningPushProtection
+}
+
+// GetSecretScanningValidityChecks returns the SecretScanningValidityChecks field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetSecretScanningValidityChecks() string {
+	if c == nil || c.SecretScanningValidityChecks == nil {
+		return ""
+	}
+	return *c.SecretScanningValidityChecks
+}
+
+// GetTargetType returns the TargetType field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetTargetType() string {
+	if c == nil || c.TargetType == nil {
+		return ""
+	}
+	return *c.TargetType
+}
+
+// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetUpdatedAt() Timestamp {
+	if c == nil || c.UpdatedAt == nil {
+		return Timestamp{}
+	}
+	return *c.UpdatedAt
+}
+
+// GetURL returns the URL field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfiguration) GetURL() string {
+	if c == nil || c.URL == nil {
+		return ""
+	}
+	return *c.URL
+}
+
+// GetConfiguration returns the Configuration field.
+func (c *CodeSecurityConfigurationWithDefaultForNewRepos) GetConfiguration() *CodeSecurityConfiguration {
+	if c == nil {
+		return nil
+	}
+	return c.Configuration
+}
+
+// GetDefaultForNewRepos returns the DefaultForNewRepos field if it's non-nil, zero value otherwise.
+func (c *CodeSecurityConfigurationWithDefaultForNewRepos) GetDefaultForNewRepos() string {
+	if c == nil || c.DefaultForNewRepos == nil {
+		return ""
+	}
+	return *c.DefaultForNewRepos
+}
+
 // GetBillableOwner returns the BillableOwner field.
 func (c *Codespace) GetBillableOwner() *User {
 	if c == nil {
@@ -5358,6 +5542,14 @@ func (d *Dependency) GetScope() string {
 	return *d.Scope
 }
 
+// GetLabeledRunners returns the LabeledRunners field if it's non-nil, zero value otherwise.
+func (d *DependencyGraphAutosubmitActionOptions) GetLabeledRunners() bool {
+	if d == nil || d.LabeledRunners == nil {
+		return false
+	}
+	return *d.LabeledRunners
+}
+
 // GetDetector returns the Detector field.
 func (d *DependencyGraphSnapshot) GetDetector() *DependencyGraphSnapshotDetector {
 	if d == nil {
@@ -19790,6 +19982,22 @@ func (r *RepositoryActiveCommitters) GetName() string {
 	return *r.Name
 }
 
+// GetConfiguration returns the Configuration field.
+func (r *RepositoryCodeSecurityConfiguration) GetConfiguration() *CodeSecurityConfiguration {
+	if r == nil {
+		return nil
+	}
+	return r.Configuration
+}
+
+// GetState returns the State field if it's non-nil, zero value otherwise.
+func (r *RepositoryCodeSecurityConfiguration) GetState() string {
+	if r == nil || r.State == nil {
+		return ""
+	}
+	return *r.State
+}
+
 // GetBody returns the Body field if it's non-nil, zero value otherwise.
 func (r *RepositoryComment) GetBody() string {
 	if r == nil || r.Body == nil {
diff --git a/github/github.go b/github/github.go
index 22fbb974..042a0b52 100644
--- a/github/github.go
+++ b/github/github.go
@@ -1595,7 +1595,7 @@ func Int64(v int64) *int64 { return &v }
 // to store v and returns a pointer to it.
 func String(v string) *string { return &v }
 
-// roundTripperFunc creates a RoundTripper (transport)
+// roundTripperFunc creates a RoundTripper (transport).
 type roundTripperFunc func(*http.Request) (*http.Response, error)
 
 func (fn roundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) {
diff --git a/github/issues_labels.go b/github/issues_labels.go
index 51e7fe6a..b97b00f3 100644
--- a/github/issues_labels.go
+++ b/github/issues_labels.go
@@ -10,7 +10,7 @@ import (
 	"fmt"
 )
 
-// Label represents a GitHub label on an Issue
+// Label represents a GitHub label on an Issue.
 type Label struct {
 	ID          *int64  `json:"id,omitempty"`
 	URL         *string `json:"url,omitempty"`
diff --git a/github/messages.go b/github/messages.go
index 30c4fca9..09974793 100644
--- a/github/messages.go
+++ b/github/messages.go
@@ -114,9 +114,9 @@ var (
 		"workflow_job":                   &WorkflowJobEvent{},
 		"workflow_run":                   &WorkflowRunEvent{},
 	}
-	// forward mapping of event types to the string names of the structs
+	// Forward mapping of event types to the string names of the structs.
 	messageToTypeName = make(map[string]string, len(eventTypeMapping))
-	// Inverse map of the above
+	// Inverse map of the above.
 	typeToMessageMapping = make(map[string]string, len(eventTypeMapping))
 )
 
diff --git a/github/orgs_codesecurity_configurations.go b/github/orgs_codesecurity_configurations.go
new file mode 100644
index 00000000..b25845a4
--- /dev/null
+++ b/github/orgs_codesecurity_configurations.go
@@ -0,0 +1,284 @@
+// Copyright 2024 The go-github AUTHORS. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package github
+
+import (
+	"context"
+	"fmt"
+	"net/http"
+)
+
+// DependencyGraphAutosubmitActionOptions represents the options for the DependencyGraphAutosubmitAction.
+type DependencyGraphAutosubmitActionOptions struct {
+	LabeledRunners *bool `json:"labeled_runners,omitempty"`
+}
+
+// CodeSecurityConfiguration represents a code security configuration.
+type CodeSecurityConfiguration struct {
+	ID                                     *int64                                  `json:"id,omitempty"`
+	TargetType                             *string                                 `json:"target_type,omitempty"`
+	Name                                   *string                                 `json:"name"`
+	Description                            *string                                 `json:"description,omitempty"`
+	AdvancedSecurity                       *string                                 `json:"advanced_security,omitempty"`
+	DependencyGraph                        *string                                 `json:"dependency_graph,omitempty"`
+	DependencyGraphAutosubmitAction        *string                                 `json:"dependency_graph_autosubmit_action,omitempty"`
+	DependencyGraphAutosubmitActionOptions *DependencyGraphAutosubmitActionOptions `json:"dependency_graph_autosubmit_action_options,omitempty"`
+	DependabotAlerts                       *string                                 `json:"dependabot_alerts,omitempty"`
+	DependabotSecurityUpdates              *string                                 `json:"dependabot_security_updates,omitempty"`
+	CodeScanningDefaultSetup               *string                                 `json:"code_scanning_default_setup,omitempty"`
+	SecretScanning                         *string                                 `json:"secret_scanning,omitempty"`
+	SecretScanningPushProtection           *string                                 `json:"secret_scanning_push_protection,omitempty"`
+	SecretScanningValidityChecks           *string                                 `json:"secret_scanning_validity_checks,omitempty"`
+	SecretScanningNonProviderPatterns      *string                                 `json:"secret_scanning_non_provider_patterns,omitempty"`
+	PrivateVulnerabilityReporting          *string                                 `json:"private_vulnerability_reporting,omitempty"`
+	Enforcement                            *string                                 `json:"enforcement,omitempty"`
+	URL                                    *string                                 `json:"url,omitempty"`
+	HTMLURL                                *string                                 `json:"html_url,omitempty"`
+	CreatedAt                              *Timestamp                              `json:"created_at,omitempty"`
+	UpdatedAt                              *Timestamp                              `json:"updated_at,omitempty"`
+}
+
+// CodeSecurityConfigurationWithDefaultForNewRepos represents a code security configuration with default for new repos param.
+type CodeSecurityConfigurationWithDefaultForNewRepos struct {
+	Configuration      *CodeSecurityConfiguration `json:"configuration"`
+	DefaultForNewRepos *string                    `json:"default_for_new_repos"`
+}
+
+// RepositoryCodeSecurityConfiguration represents a code security configuration for a repository.
+type RepositoryCodeSecurityConfiguration struct {
+	State         *string                    `json:"state,omitempty"`
+	Configuration *CodeSecurityConfiguration `json:"configuration,omitempty"`
+}
+
+// GetCodeSecurityConfigurations gets code security configurations for an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-code-security-configurations-for-an-organization
+//
+//meta:operation GET /orgs/{org}/code-security/configurations
+func (s *OrganizationsService) GetCodeSecurityConfigurations(ctx context.Context, org string) ([]*CodeSecurityConfiguration, *Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations", org)
+
+	req, err := s.client.NewRequest("GET", u, nil)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var configurations []*CodeSecurityConfiguration
+	resp, err := s.client.Do(ctx, req, &configurations)
+	if err != nil {
+		return nil, resp, err
+	}
+	return configurations, resp, nil
+}
+
+// CreateCodeSecurityConfiguration creates a code security configuration for an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#create-a-code-security-configuration
+//
+//meta:operation POST /orgs/{org}/code-security/configurations
+func (s *OrganizationsService) CreateCodeSecurityConfiguration(ctx context.Context, org string, c *CodeSecurityConfiguration) (*CodeSecurityConfiguration, *Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations", org)
+
+	req, err := s.client.NewRequest("POST", u, c)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var configuration *CodeSecurityConfiguration
+	resp, err := s.client.Do(ctx, req, &configuration)
+	if err != nil {
+		return nil, resp, err
+	}
+	return configuration, resp, nil
+}
+
+// GetDefaultCodeSecurityConfigurations gets default code security configurations for an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-default-code-security-configurations
+//
+//meta:operation GET /orgs/{org}/code-security/configurations/defaults
+func (s *OrganizationsService) GetDefaultCodeSecurityConfigurations(ctx context.Context, org string) ([]*CodeSecurityConfiguration, *Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/defaults", org)
+
+	req, err := s.client.NewRequest("GET", u, nil)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var configurations []*CodeSecurityConfiguration
+	resp, err := s.client.Do(ctx, req, &configurations)
+	if err != nil {
+		return nil, resp, err
+	}
+	return configurations, resp, nil
+}
+
+// DetachCodeSecurityConfigurationsFromRepositories detaches code security configuration from an organization's repositories.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#detach-configurations-from-repositories
+//
+//meta:operation DELETE /orgs/{org}/code-security/configurations/detach
+func (s *OrganizationsService) DetachCodeSecurityConfigurationsFromRepositories(ctx context.Context, org string, repoIDs []int64) (*Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/detach", org)
+	type selectedRepoIDs struct {
+		SelectedIDs []int64 `json:"selected_repository_ids"`
+	}
+	req, err := s.client.NewRequest("DELETE", u, selectedRepoIDs{SelectedIDs: repoIDs})
+	if err != nil {
+		return nil, err
+	}
+	resp, err := s.client.Do(ctx, req, nil)
+	if err != nil {
+		return resp, err
+	}
+	return resp, nil
+}
+
+// GetCodeSecurityConfiguration gets a code security configuration available in an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-a-code-security-configuration
+//
+//meta:operation GET /orgs/{org}/code-security/configurations/{configuration_id}
+func (s *OrganizationsService) GetCodeSecurityConfiguration(ctx context.Context, org string, id int64) (*CodeSecurityConfiguration, *Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/%v", org, id)
+
+	req, err := s.client.NewRequest("GET", u, nil)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var configuration *CodeSecurityConfiguration
+	resp, err := s.client.Do(ctx, req, &configuration)
+	if err != nil {
+		return nil, resp, err
+	}
+	return configuration, resp, nil
+}
+
+// UpdateCodeSecurityConfiguration updates a code security configuration for an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#update-a-code-security-configuration
+//
+//meta:operation PATCH /orgs/{org}/code-security/configurations/{configuration_id}
+func (s *OrganizationsService) UpdateCodeSecurityConfiguration(ctx context.Context, org string, id int64, c *CodeSecurityConfiguration) (*CodeSecurityConfiguration, *Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/%v", org, id)
+
+	req, err := s.client.NewRequest("PATCH", u, c)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var configuration *CodeSecurityConfiguration
+	resp, err := s.client.Do(ctx, req, &configuration)
+	if err != nil {
+		return nil, resp, err
+	}
+	return configuration, resp, nil
+}
+
+// DeleteCodeSecurityConfiguration deletes a code security configuration for an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#delete-a-code-security-configuration
+//
+//meta:operation DELETE /orgs/{org}/code-security/configurations/{configuration_id}
+func (s *OrganizationsService) DeleteCodeSecurityConfiguration(ctx context.Context, org string, id int64) (*Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/%v", org, id)
+
+	req, err := s.client.NewRequest("DELETE", u, nil)
+	if err != nil {
+		return nil, err
+	}
+	resp, err := s.client.Do(ctx, req, nil)
+	if err != nil {
+		return resp, err
+	}
+	return resp, nil
+}
+
+// AttachCodeSecurityConfigurationsToRepositories attaches code security configurations to repositories for an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#attach-a-configuration-to-repositories
+//
+//meta:operation POST /orgs/{org}/code-security/configurations/{configuration_id}/attach
+func (s *OrganizationsService) AttachCodeSecurityConfigurationsToRepositories(ctx context.Context, org string, id int64, scope string, repoIDs []int64) (*Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/%v/attach", org, id)
+	type selectedRepoIDs struct {
+		Scope       string  `json:"scope"`
+		SelectedIDs []int64 `json:"selected_repository_ids,omitempty"`
+	}
+	req, err := s.client.NewRequest("POST", u, selectedRepoIDs{Scope: scope, SelectedIDs: repoIDs})
+	if err != nil {
+		return nil, err
+	}
+	resp, err := s.client.Do(ctx, req, nil)
+	if err != nil && resp.StatusCode != http.StatusAccepted { // StatusAccepted(202) is the expected status code as job is queued for processing
+		return resp, err
+	}
+	return resp, nil
+}
+
+// SetDefaultCodeSecurityConfiguration sets a code security configuration as the default for an organization.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#set-a-code-security-configuration-as-a-default-for-an-organization
+//
+//meta:operation PUT /orgs/{org}/code-security/configurations/{configuration_id}/defaults
+func (s *OrganizationsService) SetDefaultCodeSecurityConfiguration(ctx context.Context, org string, id int64, newReposParam string) (*CodeSecurityConfigurationWithDefaultForNewRepos, *Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/%v/defaults", org, id)
+	type configParam struct {
+		DefaultForNewRepos string `json:"default_for_new_repos"`
+	}
+	req, err := s.client.NewRequest("PUT", u, configParam{DefaultForNewRepos: newReposParam})
+	if err != nil {
+		return nil, nil, err
+	}
+	var c *CodeSecurityConfigurationWithDefaultForNewRepos
+	resp, err := s.client.Do(ctx, req, &c)
+	if err != nil {
+		return nil, resp, err
+	}
+	return c, resp, nil
+}
+
+// GetRepositoriesForCodeSecurityConfiguration gets repositories associated with a code security configuration.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-repositories-associated-with-a-code-security-configuration
+//
+//meta:operation GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories
+func (s *OrganizationsService) GetRepositoriesForCodeSecurityConfiguration(ctx context.Context, org string, id int64) ([]*Repository, *Response, error) {
+	u := fmt.Sprintf("orgs/%v/code-security/configurations/%v/repositories", org, id)
+
+	req, err := s.client.NewRequest("GET", u, nil)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var repositories []*Repository
+	resp, err := s.client.Do(ctx, req, &repositories)
+	if err != nil {
+		return nil, resp, err
+	}
+	return repositories, resp, nil
+}
+
+// GetCodeSecurityConfigurationForRepository gets code security configuration that manages a repository's code security settings.
+//
+// GitHub API docs: https://docs.github.com/rest/code-security/configurations#get-the-code-security-configuration-associated-with-a-repository
+//
+//meta:operation GET /repos/{owner}/{repo}/code-security-configuration
+func (s *OrganizationsService) GetCodeSecurityConfigurationForRepository(ctx context.Context, org, repo string) (*RepositoryCodeSecurityConfiguration, *Response, error) {
+	u := fmt.Sprintf("repos/%v/%v/code-security-configuration", org, repo)
+
+	req, err := s.client.NewRequest("GET", u, nil)
+	if err != nil {
+		return nil, nil, err
+	}
+	var repoConfig *RepositoryCodeSecurityConfiguration
+	resp, err := s.client.Do(ctx, req, &repoConfig)
+	if err != nil {
+		return nil, resp, err
+	}
+	return repoConfig, resp, nil
+}
diff --git a/github/orgs_properties.go b/github/orgs_properties.go
index 3387d98d..d8db48fc 100644
--- a/github/orgs_properties.go
+++ b/github/orgs_properties.go
@@ -8,6 +8,7 @@ package github
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 )
 
@@ -69,7 +70,7 @@ func (cpv *CustomPropertyValue) UnmarshalJSON(data []byte) error {
 			if str, ok := item.(string); ok {
 				strSlice[i] = str
 			} else {
-				return fmt.Errorf("non-string value in string array")
+				return errors.New("non-string value in string array")
 			}
 		}
 		cpv.Value = strSlice
diff --git a/github/pulls.go b/github/pulls.go
index b6685026..35ceda44 100644
--- a/github/pulls.go
+++ b/github/pulls.go
@@ -8,6 +8,7 @@ package github
 import (
 	"bytes"
 	"context"
+	"errors"
 	"fmt"
 )
 
@@ -352,7 +353,7 @@ type pullRequestUpdate struct {
 //meta:operation PATCH /repos/{owner}/{repo}/pulls/{pull_number}
 func (s *PullRequestsService) Edit(ctx context.Context, owner string, repo string, number int, pull *PullRequest) (*PullRequest, *Response, error) {
 	if pull == nil {
-		return nil, nil, fmt.Errorf("pull must be provided")
+		return nil, nil, errors.New("pull must be provided")
 	}
 
 	u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number)
diff --git a/github/repos.go b/github/repos.go
index d928771d..9faed401 100644
--- a/github/repos.go
+++ b/github/repos.go
@@ -738,7 +738,7 @@ func (s *RepositoriesService) Delete(ctx context.Context, owner, repo string) (*
 	return s.client.Do(ctx, req, nil)
 }
 
-// Contributor represents a repository contributor
+// Contributor represents a repository contributor.
 type Contributor struct {
 	Login             *string `json:"login,omitempty"`
 	ID                *int64  `json:"id,omitempty"`
@@ -998,7 +998,7 @@ func (s *RepositoriesService) ListTags(ctx context.Context, owner string, repo s
 	return tags, resp, nil
 }
 
-// Branch represents a repository branch
+// Branch represents a repository branch.
 type Branch struct {
 	Name      *string           `json:"name,omitempty"`
 	Commit    *RepositoryCommit `json:"commit,omitempty"`
diff --git a/github/repos_contents.go b/github/repos_contents.go
index 97539aee..3a0c266b 100644
--- a/github/repos_contents.go
+++ b/github/repos_contents.go
@@ -62,7 +62,7 @@ type RepositoryContentFileOptions struct {
 }
 
 // RepositoryContentGetOptions represents an optional ref parameter, which can be a SHA,
-// branch, or tag
+// branch, or tag.
 type RepositoryContentGetOptions struct {
 	Ref string `url:"ref,omitempty"`
 }
diff --git a/github/repos_deployments.go b/github/repos_deployments.go
index d8c0b632..6277ac21 100644
--- a/github/repos_deployments.go
+++ b/github/repos_deployments.go
@@ -12,7 +12,7 @@ import (
 	"strings"
 )
 
-// Deployment represents a deployment in a repo
+// Deployment represents a deployment in a repo.
 type Deployment struct {
 	URL           *string         `json:"url,omitempty"`
 	ID            *int64          `json:"id,omitempty"`
@@ -30,7 +30,7 @@ type Deployment struct {
 	NodeID        *string         `json:"node_id,omitempty"`
 }
 
-// DeploymentRequest represents a deployment request
+// DeploymentRequest represents a deployment request.
 type DeploymentRequest struct {
 	Ref                   *string     `json:"ref,omitempty"`
 	Task                  *string     `json:"task,omitempty"`
@@ -171,7 +171,7 @@ type DeploymentStatus struct {
 	URL            *string    `json:"url,omitempty"`
 }
 
-// DeploymentStatusRequest represents a deployment request
+// DeploymentStatusRequest represents a deployment request.
 type DeploymentStatusRequest struct {
 	State          *string `json:"state,omitempty"`
 	LogURL         *string `json:"log_url,omitempty"`
diff --git a/github/search.go b/github/search.go
index 71efe87a..54bc6d5e 100644
--- a/github/search.go
+++ b/github/search.go
@@ -209,7 +209,7 @@ type Match struct {
 	Indices []int   `json:"indices,omitempty"`
 }
 
-// TextMatch represents a text match for a SearchResult
+// TextMatch represents a text match for a SearchResult.
 type TextMatch struct {
 	ObjectURL  *string  `json:"object_url,omitempty"`
 	ObjectType *string  `json:"object_type,omitempty"`
diff --git a/github/timestamp.go b/github/timestamp.go
index 00c1235e..dc1045cf 100644
--- a/github/timestamp.go
+++ b/github/timestamp.go
@@ -46,7 +46,7 @@ func (t *Timestamp) UnmarshalJSON(data []byte) (err error) {
 	return
 }
 
-// Equal reports whether t and u are equal based on time.Equal
+// Equal reports whether t and u are equal based on time.Equal.
 func (t Timestamp) Equal(u Timestamp) bool {
 	return t.Time.Equal(u.Time)
 }
diff --git a/github/users_emails.go b/github/users_emails.go
index 189187a7..3d0e1bfa 100644
--- a/github/users_emails.go
+++ b/github/users_emails.go
@@ -7,7 +7,7 @@ package github
 
 import "context"
 
-// UserEmail represents user's email address
+// UserEmail represents user's email address.
 type UserEmail struct {
 	Email      *string `json:"email,omitempty"`
 	Primary    *bool   `json:"primary,omitempty"`
diff --git a/scrape/apps.go b/scrape/apps.go
index 1b085296..307d8e5a 100644
--- a/scrape/apps.go
+++ b/scrape/apps.go
@@ -92,11 +92,11 @@ func intFromLastPathSegment(s string) int {
 type OAuthAppReviewState int
 
 const (
-	// OAuthAppRequested indicates access has been requested, but not reviewed
+	// OAuthAppRequested indicates access has been requested, but not reviewed.
 	OAuthAppRequested OAuthAppReviewState = iota + 1
-	// OAuthAppApproved indicates access has been approved
+	// OAuthAppApproved indicates access has been approved.
 	OAuthAppApproved
-	// OAuthAppDenied indicates access has been denied
+	// OAuthAppDenied indicates access has been denied.
 	OAuthAppDenied
 )
 
diff --git a/tools/metadata/main.go b/tools/metadata/main.go
index 238fc468..7be3cbed 100644
--- a/tools/metadata/main.go
+++ b/tools/metadata/main.go
@@ -10,6 +10,7 @@ package main
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"os"
 	"path/filepath"
@@ -70,7 +71,7 @@ func (c *rootCmd) opsFile() (string, *operationsFile, error) {
 func githubClient(apiURL string) (*github.Client, error) {
 	token := os.Getenv("GITHUB_TOKEN")
 	if token == "" {
-		return nil, fmt.Errorf("GITHUB_TOKEN environment variable must be set to a GitHub personal access token with the public_repo scope")
+		return nil, errors.New("GITHUB_TOKEN environment variable must be set to a GitHub personal access token with the public_repo scope")
 	}
 	return github.NewClient(nil).WithAuthToken(token).WithEnterpriseURLs(apiURL, "")
 }
@@ -83,7 +84,7 @@ type updateOpenAPICmd struct {
 func (c *updateOpenAPICmd) Run(root *rootCmd) error {
 	ctx := context.Background()
 	if c.ValidateGithub && c.Ref != "main" {
-		return fmt.Errorf("--validate and --ref are mutually exclusive")
+		return errors.New("--validate and --ref are mutually exclusive")
 	}
 	filename, opsFile, err := root.opsFile()
 	if err != nil {
@@ -102,7 +103,7 @@ func (c *updateOpenAPICmd) Run(root *rootCmd) error {
 	if c.ValidateGithub {
 		ref = opsFile.GitCommit
 		if ref == "" {
-			return fmt.Errorf("openapi_operations.yaml does not have an openapi_commit field")
+			return errors.New("openapi_operations.yaml does not have an openapi_commit field")
 		}
 	}
 	err = opsFile.updateFromGithub(ctx, client, ref)
@@ -113,7 +114,7 @@ func (c *updateOpenAPICmd) Run(root *rootCmd) error {
 		return opsFile.saveFile(filename)
 	}
 	if !operationsEqual(origOps, opsFile.OpenapiOps) {
-		return fmt.Errorf("openapi_operations.yaml does not match the OpenAPI descriptions in github.com/github/rest-api-description")
+		return errors.New("openapi_operations.yaml does not match the OpenAPI descriptions in github.com/github/rest-api-description")
 	}
 	return nil
 }
diff --git a/tools/metadata/metadata.go b/tools/metadata/metadata.go
index db763462..11eeae58 100644
--- a/tools/metadata/metadata.go
+++ b/tools/metadata/metadata.go
@@ -102,7 +102,7 @@ func normalizedOpName(name string) string {
 	return strings.TrimSpace(verb + " " + normalizeOpPath(u))
 }
 
-// matches something like "GET /some/path"
+// matches something like "GET /some/path".
 var opNameRe = regexp.MustCompile(`(?i)(\S+)(?:\s+(\S.*))?`)
 
 func parseOpName(id string) (verb, url string) {


Test patch:
diff --git a/github/copilot_test.go b/github/copilot_test.go
index 7b82390a..f27350be 100644
--- a/github/copilot_test.go
+++ b/github/copilot_test.go
@@ -16,7 +16,7 @@ import (
 	"github.com/google/go-cmp/cmp"
 )
 
-// Test invalid JSON responses, valid responses are covered in the other tests
+// Test invalid JSON responses, valid responses are covered in the other tests.
 func TestCopilotSeatDetails_UnmarshalJSON(t *testing.T) {
 	t.Parallel()
 	tests := []struct {
diff --git a/github/git_commits_test.go b/github/git_commits_test.go
index d99787fa..9ea87605 100644
--- a/github/git_commits_test.go
+++ b/github/git_commits_test.go
@@ -8,6 +8,7 @@ package github
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"io"
 	"net/http"
@@ -402,7 +403,7 @@ func TestGitService_createSignature_signerError(t *testing.T) {
 		Author:  &CommitAuthor{Name: String("go-github")},
 	}
 
-	signer := mockSigner(t, "", fmt.Errorf("signer error"), "")
+	signer := mockSigner(t, "", errors.New("signer error"), "")
 	_, err := createSignature(signer, a)
 
 	if err == nil {
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 2086baa0..bc6e2be8 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -3464,6 +3464,253 @@ func TestCodeSearchResult_GetTotal(tt *testing.T) {
 	c.GetTotal()
 }
 
+func TestCodeSecurityConfiguration_GetAdvancedSecurity(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{AdvancedSecurity: &zeroValue}
+	c.GetAdvancedSecurity()
+	c = &CodeSecurityConfiguration{}
+	c.GetAdvancedSecurity()
+	c = nil
+	c.GetAdvancedSecurity()
+}
+
+func TestCodeSecurityConfiguration_GetCodeScanningDefaultSetup(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{CodeScanningDefaultSetup: &zeroValue}
+	c.GetCodeScanningDefaultSetup()
+	c = &CodeSecurityConfiguration{}
+	c.GetCodeScanningDefaultSetup()
+	c = nil
+	c.GetCodeScanningDefaultSetup()
+}
+
+func TestCodeSecurityConfiguration_GetCreatedAt(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue Timestamp
+	c := &CodeSecurityConfiguration{CreatedAt: &zeroValue}
+	c.GetCreatedAt()
+	c = &CodeSecurityConfiguration{}
+	c.GetCreatedAt()
+	c = nil
+	c.GetCreatedAt()
+}
+
+func TestCodeSecurityConfiguration_GetDependabotAlerts(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{DependabotAlerts: &zeroValue}
+	c.GetDependabotAlerts()
+	c = &CodeSecurityConfiguration{}
+	c.GetDependabotAlerts()
+	c = nil
+	c.GetDependabotAlerts()
+}
+
+func TestCodeSecurityConfiguration_GetDependabotSecurityUpdates(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{DependabotSecurityUpdates: &zeroValue}
+	c.GetDependabotSecurityUpdates()
+	c = &CodeSecurityConfiguration{}
+	c.GetDependabotSecurityUpdates()
+	c = nil
+	c.GetDependabotSecurityUpdates()
+}
+
+func TestCodeSecurityConfiguration_GetDependencyGraph(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{DependencyGraph: &zeroValue}
+	c.GetDependencyGraph()
+	c = &CodeSecurityConfiguration{}
+	c.GetDependencyGraph()
+	c = nil
+	c.GetDependencyGraph()
+}
+
+func TestCodeSecurityConfiguration_GetDependencyGraphAutosubmitAction(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{DependencyGraphAutosubmitAction: &zeroValue}
+	c.GetDependencyGraphAutosubmitAction()
+	c = &CodeSecurityConfiguration{}
+	c.GetDependencyGraphAutosubmitAction()
+	c = nil
+	c.GetDependencyGraphAutosubmitAction()
+}
+
+func TestCodeSecurityConfiguration_GetDependencyGraphAutosubmitActionOptions(tt *testing.T) {
+	tt.Parallel()
+	c := &CodeSecurityConfiguration{}
+	c.GetDependencyGraphAutosubmitActionOptions()
+	c = nil
+	c.GetDependencyGraphAutosubmitActionOptions()
+}
+
+func TestCodeSecurityConfiguration_GetDescription(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{Description: &zeroValue}
+	c.GetDescription()
+	c = &CodeSecurityConfiguration{}
+	c.GetDescription()
+	c = nil
+	c.GetDescription()
+}
+
+func TestCodeSecurityConfiguration_GetEnforcement(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{Enforcement: &zeroValue}
+	c.GetEnforcement()
+	c = &CodeSecurityConfiguration{}
+	c.GetEnforcement()
+	c = nil
+	c.GetEnforcement()
+}
+
+func TestCodeSecurityConfiguration_GetHTMLURL(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{HTMLURL: &zeroValue}
+	c.GetHTMLURL()
+	c = &CodeSecurityConfiguration{}
+	c.GetHTMLURL()
+	c = nil
+	c.GetHTMLURL()
+}
+
+func TestCodeSecurityConfiguration_GetID(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue int64
+	c := &CodeSecurityConfiguration{ID: &zeroValue}
+	c.GetID()
+	c = &CodeSecurityConfiguration{}
+	c.GetID()
+	c = nil
+	c.GetID()
+}
+
+func TestCodeSecurityConfiguration_GetName(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{Name: &zeroValue}
+	c.GetName()
+	c = &CodeSecurityConfiguration{}
+	c.GetName()
+	c = nil
+	c.GetName()
+}
+
+func TestCodeSecurityConfiguration_GetPrivateVulnerabilityReporting(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{PrivateVulnerabilityReporting: &zeroValue}
+	c.GetPrivateVulnerabilityReporting()
+	c = &CodeSecurityConfiguration{}
+	c.GetPrivateVulnerabilityReporting()
+	c = nil
+	c.GetPrivateVulnerabilityReporting()
+}
+
+func TestCodeSecurityConfiguration_GetSecretScanning(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{SecretScanning: &zeroValue}
+	c.GetSecretScanning()
+	c = &CodeSecurityConfiguration{}
+	c.GetSecretScanning()
+	c = nil
+	c.GetSecretScanning()
+}
+
+func TestCodeSecurityConfiguration_GetSecretScanningNonProviderPatterns(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{SecretScanningNonProviderPatterns: &zeroValue}
+	c.GetSecretScanningNonProviderPatterns()
+	c = &CodeSecurityConfiguration{}
+	c.GetSecretScanningNonProviderPatterns()
+	c = nil
+	c.GetSecretScanningNonProviderPatterns()
+}
+
+func TestCodeSecurityConfiguration_GetSecretScanningPushProtection(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{SecretScanningPushProtection: &zeroValue}
+	c.GetSecretScanningPushProtection()
+	c = &CodeSecurityConfiguration{}
+	c.GetSecretScanningPushProtection()
+	c = nil
+	c.GetSecretScanningPushProtection()
+}
+
+func TestCodeSecurityConfiguration_GetSecretScanningValidityChecks(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{SecretScanningValidityChecks: &zeroValue}
+	c.GetSecretScanningValidityChecks()
+	c = &CodeSecurityConfiguration{}
+	c.GetSecretScanningValidityChecks()
+	c = nil
+	c.GetSecretScanningValidityChecks()
+}
+
+func TestCodeSecurityConfiguration_GetTargetType(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{TargetType: &zeroValue}
+	c.GetTargetType()
+	c = &CodeSecurityConfiguration{}
+	c.GetTargetType()
+	c = nil
+	c.GetTargetType()
+}
+
+func TestCodeSecurityConfiguration_GetUpdatedAt(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue Timestamp
+	c := &CodeSecurityConfiguration{UpdatedAt: &zeroValue}
+	c.GetUpdatedAt()
+	c = &CodeSecurityConfiguration{}
+	c.GetUpdatedAt()
+	c = nil
+	c.GetUpdatedAt()
+}
+
+func TestCodeSecurityConfiguration_GetURL(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfiguration{URL: &zeroValue}
+	c.GetURL()
+	c = &CodeSecurityConfiguration{}
+	c.GetURL()
+	c = nil
+	c.GetURL()
+}
+
+func TestCodeSecurityConfigurationWithDefaultForNewRepos_GetConfiguration(tt *testing.T) {
+	tt.Parallel()
+	c := &CodeSecurityConfigurationWithDefaultForNewRepos{}
+	c.GetConfiguration()
+	c = nil
+	c.GetConfiguration()
+}
+
+func TestCodeSecurityConfigurationWithDefaultForNewRepos_GetDefaultForNewRepos(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	c := &CodeSecurityConfigurationWithDefaultForNewRepos{DefaultForNewRepos: &zeroValue}
+	c.GetDefaultForNewRepos()
+	c = &CodeSecurityConfigurationWithDefaultForNewRepos{}
+	c.GetDefaultForNewRepos()
+	c = nil
+	c.GetDefaultForNewRepos()
+}
+
 func TestCodespace_GetBillableOwner(tt *testing.T) {
 	tt.Parallel()
 	c := &Codespace{}
@@ -6958,6 +7205,17 @@ func TestDependency_GetScope(tt *testing.T) {
 	d.GetScope()
 }
 
+func TestDependencyGraphAutosubmitActionOptions_GetLabeledRunners(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue bool
+	d := &DependencyGraphAutosubmitActionOptions{LabeledRunners: &zeroValue}
+	d.GetLabeledRunners()
+	d = &DependencyGraphAutosubmitActionOptions{}
+	d.GetLabeledRunners()
+	d = nil
+	d.GetLabeledRunners()
+}
+
 func TestDependencyGraphSnapshot_GetDetector(tt *testing.T) {
 	tt.Parallel()
 	d := &DependencyGraphSnapshot{}
@@ -25446,6 +25704,25 @@ func TestRepositoryActiveCommitters_GetName(tt *testing.T) {
 	r.GetName()
 }
 
+func TestRepositoryCodeSecurityConfiguration_GetConfiguration(tt *testing.T) {
+	tt.Parallel()
+	r := &RepositoryCodeSecurityConfiguration{}
+	r.GetConfiguration()
+	r = nil
+	r.GetConfiguration()
+}
+
+func TestRepositoryCodeSecurityConfiguration_GetState(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	r := &RepositoryCodeSecurityConfiguration{State: &zeroValue}
+	r.GetState()
+	r = &RepositoryCodeSecurityConfiguration{}
+	r.GetState()
+	r = nil
+	r.GetState()
+}
+
 func TestRepositoryComment_GetBody(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue string
diff --git a/github/github_test.go b/github/github_test.go
index a3eb2972..d4a06f9f 100644
--- a/github/github_test.go
+++ b/github/github_test.go
@@ -212,7 +212,7 @@ func testNewRequestAndDoFailure(t *testing.T, methodName string, client *Client,
 	testNewRequestAndDoFailureCategory(t, methodName, client, CoreCategory, f)
 }
 
-// testNewRequestAndDoFailureCategory works Like testNewRequestAndDoFailure, but allows setting the category
+// testNewRequestAndDoFailureCategory works Like testNewRequestAndDoFailure, but allows setting the category.
 func testNewRequestAndDoFailureCategory(t *testing.T, methodName string, client *Client, category RateLimitCategory, f func() (*Response, error)) {
 	t.Helper()
 	if methodName == "" {
@@ -1235,7 +1235,7 @@ func TestDo_rateLimitCategory(t *testing.T) {
 	}
 }
 
-// ensure rate limit is still parsed, even for error responses
+// Ensure rate limit is still parsed, even for error responses.
 func TestDo_rateLimit_errorResponse(t *testing.T) {
 	t.Parallel()
 	client, mux, _ := setup(t)
@@ -2265,7 +2265,7 @@ func TestAcceptedError_Is(t *testing.T) {
 	}
 }
 
-// ensure that we properly handle API errors that do not contain a response body
+// Ensure that we properly handle API errors that do not contain a response body.
 func TestCheckResponse_noBody(t *testing.T) {
 	t.Parallel()
 	res := &http.Response{
diff --git a/github/orgs_codesecurity_configurations_test.go b/github/orgs_codesecurity_configurations_test.go
new file mode 100644
index 00000000..d59b3705
--- /dev/null
+++ b/github/orgs_codesecurity_configurations_test.go
@@ -0,0 +1,510 @@
+// Copyright 2024 The go-github AUTHORS. All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package github
+
+import (
+	"context"
+	"fmt"
+	"net/http"
+	"reflect"
+	"testing"
+
+	"encoding/json"
+)
+
+func TestOrganizationsService_GetCodeSecurityConfigurations(t *testing.T) {
+	t.Parallel()
+	ctx := context.Background()
+	client, mux, _ := setup(t)
+
+	mux.HandleFunc("/orgs/o/code-security/configurations", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		fmt.Fprint(w, `[
+		{
+			"id":1,
+			"name":"config1",
+			"code_scanning_default_setup": "enabled"
+		},
+		{
+			"id":2,
+			"name":"config2",
+			"private_vulnerability_reporting": "enabled"
+		}]`)
+	})
+
+	configurations, _, err := client.Organizations.GetCodeSecurityConfigurations(ctx, "o")
+	if err != nil {
+		t.Errorf("Organizations.GetOrganizationCodeSecurityConfigurations returned error: %v", err)
+	}
+
+	want := []*CodeSecurityConfiguration{
+		{ID: Int64(1), Name: String("config1"), CodeScanningDefaultSetup: String("enabled")},
+		{ID: Int64(2), Name: String("config2"), PrivateVulnerabilityReporting: String("enabled")},
+	}
+	if !reflect.DeepEqual(configurations, want) {
+		t.Errorf("Organizations.GetCodeSecurityConfigurations returned %+v, want %+v", configurations, want)
+	}
+	const methodName = "GetCodeSecurityConfigurations"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.GetCodeSecurityConfigurations(ctx, "\n")
+		return err
+	})
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.GetCodeSecurityConfigurations(ctx, "o")
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_GetCodeSecurityConfiguration(t *testing.T) {
+	t.Parallel()
+	client, mux, _ := setup(t)
+	ctx := context.Background()
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/1", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		fmt.Fprint(w, `{
+			"id":1,
+			"name":"config1",
+			"code_scanning_default_setup": "enabled"
+		}`)
+	})
+
+	configuration, _, err := client.Organizations.GetCodeSecurityConfiguration(ctx, "o", 1)
+	if err != nil {
+		t.Errorf("Organizations.GetCodeSecurityConfiguration returned error: %v", err)
+	}
+
+	want := &CodeSecurityConfiguration{ID: Int64(1), Name: String("config1"), CodeScanningDefaultSetup: String("enabled")}
+	if !reflect.DeepEqual(configuration, want) {
+		t.Errorf("Organizations.GetCodeSecurityConfiguration returned %+v, want %+v", configuration, want)
+	}
+
+	const methodName = "GetCodeSecurityConfiguration"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.GetCodeSecurityConfiguration(ctx, "\n", -1)
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.GetCodeSecurityConfiguration(ctx, "o", 1)
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_CreateCodeSecurityConfiguration(t *testing.T) {
+	t.Parallel()
+	client, mux, _ := setup(t)
+	ctx := context.Background()
+
+	input := &CodeSecurityConfiguration{
+		Name:                     String("config1"),
+		CodeScanningDefaultSetup: String("enabled"),
+	}
+
+	mux.HandleFunc("/orgs/o/code-security/configurations", func(w http.ResponseWriter, r *http.Request) {
+		v := new(CodeSecurityConfiguration)
+		err := json.NewDecoder(r.Body).Decode(v)
+		if err != nil {
+			t.Errorf("Organizations.CreateCodeSecurityConfiguration request body decode failed: %v", err)
+		}
+
+		if !reflect.DeepEqual(v, input) {
+			t.Errorf("Organizations.CreateCodeSecurityConfiguration request body = %+v, want %+v", v, input)
+		}
+
+		fmt.Fprint(w, `{
+			"id":1,
+			"name":"config1",
+			"code_scanning_default_setup": "enabled"
+		}`)
+	})
+
+	configuration, _, err := client.Organizations.CreateCodeSecurityConfiguration(ctx, "o", input)
+	if err != nil {
+		t.Errorf("Organizations.CreateCodeSecurityConfiguration returned error: %v", err)
+	}
+
+	want := &CodeSecurityConfiguration{ID: Int64(1), Name: String("config1"), CodeScanningDefaultSetup: String("enabled")}
+	if !reflect.DeepEqual(configuration, want) {
+		t.Errorf("Organizations.CreateCodeSecurityConfiguration returned %+v, want %+v", configuration, want)
+	}
+
+	const methodName = "CreateCodeSecurityConfiguration"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.CreateCodeSecurityConfiguration(ctx, "\n", input)
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.CreateCodeSecurityConfiguration(ctx, "o", input)
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_GetDefaultCodeSecurityConfigurations(t *testing.T) {
+	t.Parallel()
+	client, mux, _ := setup(t)
+	ctx := context.Background()
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/defaults", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		fmt.Fprint(w, `[
+		{
+			"id":1,
+			"name":"config1",
+			"code_scanning_default_setup": "enabled"
+		},
+		{
+			"id":2,
+			"name":"config2",
+			"private_vulnerability_reporting": "enabled"
+		}]`)
+	})
+
+	configurations, _, err := client.Organizations.GetDefaultCodeSecurityConfigurations(ctx, "o")
+	if err != nil {
+		t.Errorf("Organizations.GetDefaultCodeSecurityConfigurations returned error: %v", err)
+	}
+
+	want := []*CodeSecurityConfiguration{
+		{ID: Int64(1), Name: String("config1"), CodeScanningDefaultSetup: String("enabled")},
+		{ID: Int64(2), Name: String("config2"), PrivateVulnerabilityReporting: String("enabled")},
+	}
+	if !reflect.DeepEqual(configurations, want) {
+		t.Errorf("Organizations.GetDefaultCodeSecurityConfigurations returned %+v, want %+v", configurations, want)
+	}
+
+	const methodName = "GetDefaultCodeSecurityConfigurations"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.GetDefaultCodeSecurityConfigurations(ctx, "\n")
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.GetDefaultCodeSecurityConfigurations(ctx, "o")
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_DetachCodeSecurityConfigurationsFromRepositories(t *testing.T) {
+	t.Parallel()
+	client, mux, _ := setup(t)
+	ctx := context.Background()
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/detach", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "DELETE")
+		w.WriteHeader(http.StatusNoContent)
+	})
+
+	resp, err := client.Organizations.DetachCodeSecurityConfigurationsFromRepositories(ctx, "o", []int64{1})
+	if err != nil {
+		t.Errorf("Organizations.DetachCodeSecurityConfigurationsFromRepositories returned error: %v", err)
+	}
+
+	want := http.StatusNoContent
+	if resp.StatusCode != want {
+		t.Errorf("Organizations.DetachCodeSecurityConfigurationsFromRepositories returned status %d, want %d", resp.StatusCode, want)
+	}
+
+	const methodName = "DetachCodeSecurityConfigurationsFromRepositories"
+	testBadOptions(t, methodName, func() (err error) {
+		_, err = client.Organizations.DetachCodeSecurityConfigurationsFromRepositories(ctx, "\n", []int64{1})
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		resp, err := client.Organizations.DetachCodeSecurityConfigurationsFromRepositories(ctx, "o", []int64{1})
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_UpdateCodeSecurityConfiguration(t *testing.T) {
+	t.Parallel()
+	ctx := context.Background()
+	client, mux, _ := setup(t)
+
+	input := &CodeSecurityConfiguration{
+		Name:                     String("config1"),
+		CodeScanningDefaultSetup: String("enabled"),
+	}
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/1", func(w http.ResponseWriter, r *http.Request) {
+		v := new(CodeSecurityConfiguration)
+		err := json.NewDecoder(r.Body).Decode(v)
+		if err != nil {
+			t.Errorf("Organizations.UpdateCodeSecurityConfiguration request body decode failed: %v", err)
+		}
+
+		if !reflect.DeepEqual(v, input) {
+			t.Errorf("Organizations.UpdateCodeSecurityConfiguration request body = %+v, want %+v", v, input)
+		}
+
+		fmt.Fprint(w, `{
+			"id":1,
+			"name":"config1",
+			"code_scanning_default_setup": "enabled"
+		}`)
+	})
+
+	configuration, _, err := client.Organizations.UpdateCodeSecurityConfiguration(ctx, "o", 1, input)
+	if err != nil {
+		t.Errorf("Organizations.UpdateCodeSecurityConfiguration returned error: %v", err)
+	}
+
+	want := &CodeSecurityConfiguration{ID: Int64(1), Name: String("config1"), CodeScanningDefaultSetup: String("enabled")}
+	if !reflect.DeepEqual(configuration, want) {
+		t.Errorf("Organizations.UpdateCodeSecurityConfiguration returned %+v, want %+v", configuration, want)
+	}
+
+	const methodName = "UpdateCodeSecurityConfiguration"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.UpdateCodeSecurityConfiguration(ctx, "\n", -1, input)
+		return
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.UpdateCodeSecurityConfiguration(ctx, "o", 1, input)
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_DeleteCodeSecurityConfiguration(t *testing.T) {
+	t.Parallel()
+	ctx := context.Background()
+	client, mux, _ := setup(t)
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/1", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "DELETE")
+		w.WriteHeader(http.StatusNoContent)
+	})
+
+	resp, err := client.Organizations.DeleteCodeSecurityConfiguration(ctx, "o", 1)
+	if err != nil {
+		t.Errorf("Organizations.DeleteCodeSecurityConfiguration returned error: %v", err)
+	}
+
+	want := http.StatusNoContent
+	if resp.StatusCode != want {
+		t.Errorf("Organizations.DeleteCodeSecurityConfiguration returned status %d, want %d", resp.StatusCode, want)
+	}
+
+	const methodName = "DeleteCodeSecurityConfiguration"
+	testBadOptions(t, methodName, func() (err error) {
+		_, err = client.Organizations.DeleteCodeSecurityConfiguration(ctx, "\n", -1)
+		return
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		resp, err := client.Organizations.DeleteCodeSecurityConfiguration(ctx, "o", 1)
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_AttachCodeSecurityConfigurationsToRepositories(t *testing.T) {
+	t.Parallel()
+	ctx := context.Background()
+	client, mux, _ := setup(t)
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/1/attach", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "POST")
+		type request struct {
+			Scope                 string  `json:"scope"`
+			SelectedRepositoryIDS []int64 `json:"selected_repository_ids,omitempty"`
+		}
+		v := new(request)
+		err := json.NewDecoder(r.Body).Decode(v)
+		if err != nil {
+			t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body decode failed: %v", err)
+		}
+		if v.Scope != "selected" {
+			t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body scope = %s, want selected", v.Scope)
+		}
+		if !reflect.DeepEqual(v.SelectedRepositoryIDS, []int64{5, 20}) {
+			t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories request body selected_repository_ids = %+v, want %+v", v.SelectedRepositoryIDS, []int64{5, 20})
+		}
+		w.WriteHeader(http.StatusAccepted)
+	})
+
+	resp, err := client.Organizations.AttachCodeSecurityConfigurationsToRepositories(ctx, "o", int64(1), "selected", []int64{5, 20})
+	if err != nil {
+		t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories returned error: %v", err)
+	}
+
+	want := http.StatusAccepted
+	if resp.StatusCode != want {
+		t.Errorf("Organizations.AttachCodeSecurityConfigurationsToRepositories returned status %d, want %d", resp.StatusCode, want)
+	}
+
+	const methodName = "AttachCodeSecurityConfigurationsToRepositories"
+	testBadOptions(t, methodName, func() (err error) {
+		_, err = client.Organizations.AttachCodeSecurityConfigurationsToRepositories(ctx, "\n", -1, "", nil)
+		return
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		resp, err := client.Organizations.AttachCodeSecurityConfigurationsToRepositories(ctx, "o", 1, "selected", []int64{5, 20})
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_SetDefaultCodeSecurityConfiguration(t *testing.T) {
+	t.Parallel()
+	ctx := context.Background()
+	client, mux, _ := setup(t)
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/1/defaults", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "PUT")
+		fmt.Fprintf(w, `
+		{
+			"default_for_new_repos": "all",
+			"configuration":
+				{
+					"id": 1,
+					"name": "config1",
+					"code_scanning_default_setup": "enabled"
+				}
+		}`)
+		w.WriteHeader(http.StatusOK)
+	})
+	got, resp, err := client.Organizations.SetDefaultCodeSecurityConfiguration(ctx, "o", 1, "all")
+	if err != nil {
+		t.Errorf("Organizations.SetDefaultCodeSecurityConfiguration returned error: %v", err)
+	}
+	wantStatus := http.StatusOK
+	if resp.StatusCode != wantStatus {
+		t.Errorf("Organizations.SetDefaultCodeSecurityConfiguration returned status %d, want %d", resp.StatusCode, wantStatus)
+	}
+	want := &CodeSecurityConfigurationWithDefaultForNewRepos{
+		DefaultForNewRepos: String("all"),
+		Configuration: &CodeSecurityConfiguration{
+			ID: Int64(1), Name: String("config1"), CodeScanningDefaultSetup: String("enabled"),
+		},
+	}
+	if !reflect.DeepEqual(got, want) {
+		t.Errorf("Organizations.SetDefaultCodeSecurityConfiguration returned %+v, want %+v", got, want)
+	}
+
+	const methodName = "SetDefaultCodeSecurityConfiguration"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.SetDefaultCodeSecurityConfiguration(ctx, "\n", -1, "")
+		return
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.SetDefaultCodeSecurityConfiguration(ctx, "o", 1, "all")
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_GetRepositoriesForCodeSecurityConfiguration(t *testing.T) {
+	t.Parallel()
+	ctx := context.Background()
+	client, mux, _ := setup(t)
+
+	mux.HandleFunc("/orgs/o/code-security/configurations/1/repositories", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		fmt.Fprint(w, `[
+		{
+			"id":8,
+			"name":"repo8"
+		},
+		{
+			"id":42,
+			"name":"repo42"
+		}]`)
+	})
+
+	repositories, _, err := client.Organizations.GetRepositoriesForCodeSecurityConfiguration(ctx, "o", 1)
+	if err != nil {
+		t.Errorf("Organizations.GetRepositoriesForCodeSecurityConfiguration returned error: %v", err)
+	}
+
+	want := []*Repository{
+		{ID: Int64(8), Name: String("repo8")},
+		{ID: Int64(42), Name: String("repo42")},
+	}
+	if !reflect.DeepEqual(repositories, want) {
+		t.Errorf("Organizations.GetRepositoriesForCodeSecurityConfiguration returned %+v, want %+v", repositories, want)
+	}
+
+	const methodName = "GetRepositoriesForCodeSecurityConfiguration"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.GetRepositoriesForCodeSecurityConfiguration(ctx, "\n", -1)
+		return
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.GetRepositoriesForCodeSecurityConfiguration(ctx, "o", 1)
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
+
+func TestOrganizationsService_GetCodeSecurityConfigurationForRepository(t *testing.T) {
+	t.Parallel()
+	ctx := context.Background()
+	client, mux, _ := setup(t)
+
+	mux.HandleFunc("/repos/o/repo8/code-security-configuration", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "GET")
+		fmt.Fprint(w, `{
+		    "state": "attached",
+			"configuration": {
+				"id":42,
+				"name":"config42",
+				"code_scanning_default_setup": "enabled"
+			}
+		}`)
+		w.WriteHeader(http.StatusOK)
+	})
+
+	rc, _, err := client.Organizations.GetCodeSecurityConfigurationForRepository(ctx, "o", "repo8")
+	if err != nil {
+		t.Errorf("Organizations.GetCodeSecurityConfigurationForRepository returned error: %v", err)
+	}
+	c := &CodeSecurityConfiguration{ID: Int64(42), Name: String("config42"), CodeScanningDefaultSetup: String("enabled")}
+	want := &RepositoryCodeSecurityConfiguration{
+		State:         String("attached"),
+		Configuration: c,
+	}
+	if !reflect.DeepEqual(rc, want) {
+		t.Errorf("Organizations.GetCodeSecurityConfigurationForRepository returned %+v, want %+v", rc, want)
+	}
+
+	const methodName = "GetCodeSecurityConfigurationForRepository"
+	testBadOptions(t, methodName, func() (err error) {
+		_, _, err = client.Organizations.GetCodeSecurityConfigurationForRepository(ctx, "\n", "\n")
+		return
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Organizations.GetCodeSecurityConfigurationForRepository(ctx, "o", "repo8")
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}
diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go
index c2c1b63e..a351ab93 100644
--- a/github/orgs_members_test.go
+++ b/github/orgs_members_test.go
@@ -126,7 +126,7 @@ func TestOrganizationsService_IsMember(t *testing.T) {
 	})
 }
 
-// ensure that a 404 response is interpreted as "false" and not an error
+// Ensure that a 404 response is interpreted as "false" and not an error.
 func TestOrganizationsService_IsMember_notMember(t *testing.T) {
 	t.Parallel()
 	client, mux, _ := setup(t)
@@ -146,8 +146,8 @@ func TestOrganizationsService_IsMember_notMember(t *testing.T) {
 	}
 }
 
-// ensure that a 400 response is interpreted as an actual error, and not simply
-// as "false" like the above case of a 404
+// Ensure that a 400 response is interpreted as an actual error, and not simply
+// as "false" like the above case of a 404.
 func TestOrganizationsService_IsMember_error(t *testing.T) {
 	t.Parallel()
 	client, mux, _ := setup(t)
@@ -209,7 +209,7 @@ func TestOrganizationsService_IsPublicMember(t *testing.T) {
 	})
 }
 
-// ensure that a 404 response is interpreted as "false" and not an error
+// Ensure that a 404 response is interpreted as "false" and not an error.
 func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) {
 	t.Parallel()
 	client, mux, _ := setup(t)
@@ -229,8 +229,8 @@ func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) {
 	}
 }
 
-// ensure that a 400 response is interpreted as an actual error, and not simply
-// as "false" like the above case of a 404
+// Ensure that a 400 response is interpreted as an actual error, and not simply
+// as "false" like the above case of a 404.
 func TestOrganizationsService_IsPublicMember_error(t *testing.T) {
 	t.Parallel()
 	client, mux, _ := setup(t)
diff --git a/scrape/apps_test.go b/scrape/apps_test.go
index c15b305b..1a417648 100644
--- a/scrape/apps_test.go
+++ b/scrape/apps_test.go
@@ -40,7 +40,7 @@ func Test_AppRestrictionsEnabled(t *testing.T) {
 
 			got, err := client.AppRestrictionsEnabled("o")
 			if err != nil {
-				t.Errorf("AppRestrictionsEnabled returned err: %v", err)
+				t.Fatalf("AppRestrictionsEnabled returned err: %v", err)
 			}
 			if want := tt.want; got != want {
 				t.Errorf("AppRestrictionsEnabled returned %t, want %t", got, want)
@@ -59,7 +59,7 @@ func Test_ListOAuthApps(t *testing.T) {
 
 	got, err := client.ListOAuthApps("e")
 	if err != nil {
-		t.Errorf("ListOAuthApps(e) returned err: %v", err)
+		t.Fatalf("ListOAuthApps(e) returned err: %v", err)
 	}
 	want := []OAuthApp{
 		{
diff --git a/scrape/forms_test.go b/scrape/forms_test.go
index e3e802b0..28c30c6c 100644
--- a/scrape/forms_test.go
+++ b/scrape/forms_test.go
@@ -76,7 +76,7 @@ func Test_ParseForms(t *testing.T) {
 			t.Parallel()
 			node, err := html.Parse(strings.NewReader(tt.html))
 			if err != nil {
-				t.Errorf("error parsing html: %v", err)
+				t.Fatalf("error parsing html: %v", err)
 			}
 			if got, want := parseForms(node), tt.forms; !cmp.Equal(got, want) {
 				t.Errorf("parseForms(%q) returned %+v, want %+v", tt.html, got, want)
@@ -99,7 +99,7 @@ func Test_FetchAndSumbitForm(t *testing.T) {
 	mux.HandleFunc("/submit", func(w http.ResponseWriter, r *http.Request) {
 		err := r.ParseForm()
 		if err != nil {
-			t.Errorf("error parsing form: %v", err)
+			t.Fatalf("error parsing form: %v", err)
 		}
 		want := url.Values{"hidden": {"h"}, "name": {"n"}}
 		if got := r.Form; !cmp.Equal(got, want) {
@@ -111,7 +111,7 @@ func Test_FetchAndSumbitForm(t *testing.T) {
 	setValues := func(values url.Values) { values.Set("name", "n") }
 	_, err := fetchAndSubmitForm(client.Client, client.baseURL.String()+"/", setValues)
 	if err != nil {
-		t.Errorf("fetchAndSubmitForm returned err: %v", err)
+		t.Fatalf("fetchAndSubmitForm returned err: %v", err)
 	}
 	if !submitted {
 		t.Error("form was never submitted")
diff --git a/scrape/scrape_test.go b/scrape/scrape_test.go
index 24bab0a2..c31bb833 100644
--- a/scrape/scrape_test.go
+++ b/scrape/scrape_test.go
@@ -6,6 +6,7 @@ import (
 	"net/http/httptest"
 	"net/url"
 	"os"
+	"path/filepath"
 	"testing"
 )
 
@@ -27,9 +28,9 @@ func setup(t *testing.T) (client *Client, mux *http.ServeMux) {
 
 func copyTestFile(t *testing.T, w io.Writer, filename string) {
 	t.Helper()
-	f, err := os.Open("testdata/" + filename)
+	f, err := os.Open(filepath.Join("testdata", filename))
 	if err != nil {
-		t.Errorf("unable to open test file: %v", err)
+		t.Fatalf("unable to open test file: %v", err)
 	}
 	_, err = io.Copy(w, f)
 	if err != nil {
diff --git a/test/integration/audit_log_test.go b/test/integration/audit_log_test.go
index 639ea7a6..a7f79b74 100644
--- a/test/integration/audit_log_test.go
+++ b/test/integration/audit_log_test.go
@@ -13,9 +13,9 @@ import (
 	"testing"
 )
 
-// TestOrganizationAuditLog test that the client can read an org's audit log
-// Note: Org must be part of an enterprise
-// Test requires auth - set env var GITHUB_AUTH_TOKEN
+// TestOrganizationAuditLog test that the client can read an org's audit log.
+// Note: Org must be part of an enterprise.
+// Test requires auth - set env var GITHUB_AUTH_TOKEN.
 func TestOrganizationAuditLog(t *testing.T) {
 	org := "example_org"
 	entries, _, err := client.Organizations.GetAuditLog(context.Background(), org, nil)