Repository: google/go-github
File: github/dependabot_secrets.go (Go)

Code before:
}

func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	req, err := s.client.NewRequest("PUT", url, eSecret)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}

// CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-a-repository-secret
func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, eSecret.Name)
	return s.putSecret(ctx, url, eSecret)
}

// CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	repoIDs := make([]string, len(eSecret.SelectedRepositoryIDs))
	for i, secret := range eSecret.SelectedRepositoryIDs {
		repoIDs[i] = strconv.Itoa(int(secret))
	}
	params := struct {
		*DependabotEncryptedSecret
		SelectedRepositoryIDs []string `json:"selected_repository_ids,omitempty"`
	}{
		DependabotEncryptedSecret: eSecret,
		SelectedRepositoryIDs:     repoIDs,
	}

	putSecret := func(ctx context.Context, url string, eSecret interface{}) (*Response, error) {
		req, err := s.client.NewRequest("PUT", url, eSecret)
		if err != nil {
			return nil, err
		}

		return s.client.Do(ctx, req, nil)
	}

	url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, eSecret.Name)
	return putSecret(ctx, url, params)
}

func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Response, error) {
	req, err := s.client.NewRequest("DELETE", url, nil)
	if err != nil {

Review comment (security):
```suggestion
		repoIDs[i] = fmt.Sprintf("%v", secret)
```

Code after:

func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	req, err := s.client.NewRequest("PUT", url, eSecret)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}

// CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-a-repository-secret
func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, eSecret.Name)
	return s.putSecret(ctx, url, eSecret)
}

// CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value.
//
// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret
func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) {
	repoIDs := make([]string, len(eSecret.SelectedRepositoryIDs))
	for i, secret := range eSecret.SelectedRepositoryIDs {
		repoIDs[i] = fmt.Sprintf("%v", secret)
	}
	params := struct {
		*DependabotEncryptedSecret
		SelectedRepositoryIDs []string `json:"selected_repository_ids,omitempty"`
	}{
		DependabotEncryptedSecret: eSecret,
		SelectedRepositoryIDs:     repoIDs,
	}

	url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, eSecret.Name)
	req, err := s.client.NewRequest("PUT", url, params)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}

func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Response, error) {
	req, err := s.client.NewRequest("DELETE", url, nil)
	if err != nil {
		return nil, err
	}

	return s.client.Do(ctx, req, nil)
}