Skip to main content

Securing your repository

You can use a number of GitHub features to help keep your repository secure.

Repository administrators and organization owners can configure repository security settings.

Introduction

This guide shows you how to configure security features for a repository. You must be a repository administrator or organization owner to configure security settings for a repository.

Your security needs are unique to your repository, so you may not need to enable every feature for your repository. For more information, see "GitHub security features."

某些功能可用于所有计划的存储库。 其他功能可供使用 GitHub Advanced Security 的企业使用。 GitHub Advanced Security 功能也为 GitHub.com 上的所有公共存储库启用。 更多信息请参阅“关于 GitHub Advanced Security”。

Managing access to your repository

The first step to securing a repository is to set up who can see and modify your code. For more information, see "Managing repository settings."

From the main page of your repository, click Settings, then scroll down to the "Danger Zone."

Setting a security policy

  1. From the main page of your repository, click Security.
  2. Click Security policy.
  3. Click Start setup.
  4. Add information about supported versions of your project and how to report vulnerabilities.

For more information, see "Adding a security policy to your repository."

Managing the dependency graph

The dependency graph is automatically generated for all public repositories, and you can choose to enable it for private repositories. It interprets manifest and lock files in a repository to identify dependencies.

  1. From the main page of your repository, click Settings.
  2. Click Security & analysis.
  3. Next to Dependency graph, click Enable or Disable.

For more information, see "Exploring the dependencies of a repository."

Managing Dependabot 警报

Dependabot 警报 are generated when GitHub identifies a dependency in the dependency graph with a vulnerability. You can enable Dependabot 警报 for any repository.

  1. Click your profile photo, then click Settings.
  2. Click Security & analysis.
  3. Click Enable all next to Dependabot 警报.

For more information, see "About Dependabot 警报" and "Managing security and analysis settings for your personal account."

Managing dependency review

Dependency review lets you visualize dependency changes in pull requests before they are merged into your repositories. For more information, see "About dependency review."

Dependency review is a GitHub Advanced Security feature. Dependency review is already enabled for all public repositories. Organizations that use GitHub Enterprise Cloud with Advanced Security can additionally enable dependency review for private and internal repositories. For more information, see the GitHub Enterprise Cloud documentation.

Managing Dependabot 安全更新

For any repository that uses Dependabot 警报, you can enable Dependabot 安全更新 to raise pull requests with security updates when vulnerabilities are detected.

  1. From the main page of your repository, click Settings.
  2. Click Security & analysis.
  3. Next to Dependabot 安全更新, click Enable.

For more information, see "About Dependabot 安全更新" and "Configuring Dependabot 安全更新."

Managing Dependabot 版本更新

You can enable Dependabot to automatically raise pull requests to keep your dependencies up-to-date. For more information, see "About Dependabot 版本更新."

  1. From the main page of your repository, click Settings.
  2. Click Security & analysis.
  3. Next to Dependabot 版本更新, click Enable to create a basic dependabot.yml configuration file.
  4. Specify the dependencies to update and commit the file to the repository. For more information, see "Configuring Dependabot version updates."

Configuring 代码扫描

You can set up 代码扫描 to automatically identify vulnerabilities and errors in the code stored in your repository by using a CodeQL 分析工作流程 or third-party tool. For more information, see "Setting up 代码扫描 for a repository."

代码扫描 is available for all public repositories, and for private repositories owned by organizations that are part of an enterprise with a license for GitHub Advanced Security.

Configuring 秘密扫描

秘密扫描 is enabled for all public repositories and is available for private repositories owned by organizations that are part of an enterprise with a license for GitHub Advanced Security. For more information, see the GitHub Enterprise Cloud documentation.

Next steps

You can view and manage alerts from security features to address dependencies and vulnerabilities in your code. For more information, see "Viewing and updating Dependabot 警报," "Managing pull requests for dependency updates," "Managing 代码扫描 for your repository," and "Managing alerts from 秘密扫描."

If you have a security vulnerability, you can create a security advisory to privately discuss and fix the vulnerability. For more information, see "About GitHub Security Advisories" and "Creating a security advisory."