# 安全配置状态

应用了 security configuration 的每个存储库都有一个配置状态，用于反映该存储库与该配置之间关系的当前状态。

存储库的配置状态指示其与已应用 security configuration的关系的当前状态。 这种关系可能会随时间而变化，例如，当存储库管理员重写设置、管理员启用强制或附件失败时。 有关配置和存储库交互方式的详细信息，请参阅 [大规模启用安全功能](/zh/enterprise-server@3.22/code-security/concepts/security-at-scale/organization-security)。

可以在组织的设置页上的 security configurations 存储库表中查看配置状态，或使用 REST API 检索它们。 有关详细信息，请参阅 [使用存储库表筛选组织中的存储库](/zh/enterprise-server@3.22/code-security/how-tos/secure-at-scale/configure-organization-security/manage-your-coverage/filter-repositories) 和 [配置](/zh/enterprise-server@3.22/rest/code-security/configurations)。

## 配置状态参考

下表描述了所有配置状态、导致每个状态的原因、每个状态在组织设置存储库表中的显示方式以及建议的操作。

在存储库表中，“配置状态”筛选器支持“附加”、“已删除”、“失败”、“强制”和“企业删除”。 状态为 `detached` “无配置”的存储库显示为“无配置”，不能按 UI 中的配置状态进行筛选。 但是，在列出组织级配置的存储库时，REST API `status` 的参数会接受 `detached` 。

| Status                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Description                                                                                                                                                                                                              | 原因                              | 用户界面显示          | 建议的操作                                                                                                                                                                                                     |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attached`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | 当前正在应用该配置。 存储库从配置继承所有设置。                                                                                                                                                                                                 | 组织或企业管理员将配置应用到存储库。              | 配置名称（例如，“我的配置”） | 无需采取任何行动。                                                                                                                                                                                                 |
| `attaching`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | 正在应用配置。 这是一个暂时性状态。                                                                                                                                                                                                       | 组织或企业管理员刚刚应用了配置。                |                 |                                                                                                                                                                                                           |
| <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-clock" aria-label="Applying" role="img"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"></path></svg> 正在应用 CONFIGURATION-NAME                                                                                                                                                                                                                                                                                                                                                                                                                                          | 等待操作完成。 如果状态没有更改，请检查是否存在附加失败问题。                                                                                                                                                                                          |                                 |                 |                                                                                                                                                                                                           |
| `updating`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | 正在存储库上更新配置。                                                                                                                                                                                                              | 组织或企业管理员更改了配置中的设置。              |                 |                                                                                                                                                                                                           |
| <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-clock" aria-label="Updating" role="img"><path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Zm7-3.25v2.992l2.028.812a.75.75 0 0 1-.557 1.392l-2.5-1A.751.751 0 0 1 7 8.25v-3.5a.75.75 0 0 1 1.5 0Z"></path></svg> 更新 CONFIGURATION-NAME                                                                                                                                                                                                                                                                                                                                                                                                                                            | 等待更新完成。                                                                                                                                                                                                                  |                                 |                 |                                                                                                                                                                                                           |
| `enforced`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | 该配置正在被主动应用并强制执行。 存储库管理员无法更改配置控制的功能的启用状态。                                                                                                                                                                                 | 组织或企业管理员在配置上启用了强制实施。            |                 |                                                                                                                                                                                                           |
| <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-shield" aria-label="Enforced" role="img"><path d="M7.467.133a1.748 1.748 0 0 1 1.066 0l5.25 1.68A1.75 1.75 0 0 1 15 3.48V7c0 1.566-.32 3.182-1.303 4.682-.983 1.498-2.585 2.813-5.032 3.855a1.697 1.697 0 0 1-1.33 0c-2.447-1.042-4.049-2.357-5.032-3.855C1.32 10.182 1 8.566 1 7V3.48a1.75 1.75 0 0 1 1.217-1.667Zm.61 1.429a.25.25 0 0 0-.153 0l-5.25 1.68a.25.25 0 0 0-.174.238V7c0 1.358.275 2.666 1.057 3.86.784 1.194 2.121 2.34 4.366 3.297a.196.196 0 0 0 .154 0c2.245-.956 3.582-2.104 4.366-3.298C13.225 9.666 13.5 8.36 13.5 7V3.48a.251.251 0 0 0-.174-.237l-5.25-1.68ZM8.75 4.75v3a.75.75 0 0 1-1.5 0v-3a.75.75 0 0 1 1.5 0ZM9 10.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> 已强制执行 CONFIGURATION-NAME | 无需采取任何行动。 有关详细信息，请参阅“[安全配置的强制执行](/zh/enterprise-server@3.22/code-security/reference/security-at-scale/configuration-enforcement)”。                                                                                       |                                 |                 |                                                                                                                                                                                                           |
| `removed`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | 存储库级设置已更改，该设置与配置冲突。 配置仍与存储库关联，但存储库不再继承所有设置。                                                                                                                                                                              | 存储库管理员更改了未强制配置的安全设置。            |                 |                                                                                                                                                                                                           |
| <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-alert" aria-label="Removed" role="img"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> 已删除 CONFIGURATION-NAME                                                                                                                                                                                                                                                                                                                  | 若要还原预期设置，请重新应用存储库的“Advanced Security”页中的配置。 为防止将来发生覆盖，请考虑启用强制执行。                                                                                                                                                         |                                 |                 |                                                                                                                                                                                                           |
| `removed_by_enterprise`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | 企业级配置更改导致与存储库设置发生冲突。                                                                                                                                                                                                     | 企业管理员更改了与应用于存储库的组织级别配置冲突的设置。    |                 |                                                                                                                                                                                                           |
| <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-alert" aria-label="Removed" role="img"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> 已删除 CONFIGURATION-NAME                                                                                                                                                                                                                                                                                                                  | 与企业管理员协调以解决冲突。 在组织或企业级别重新应用配置。                                                                                                                                                                                           |                                 |                 |                                                                                                                                                                                                           |
| `failed`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | 无法将配置附加到存储库。                                                                                                                                                                                                             | 现有存储库设置与配置之间的冲突导致无法附加。          |                 |                                                                                                                                                                                                           |
| <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-alert" aria-label="Failed" role="img"><path d="M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"></path></svg> 失败原因                                                                                                                                                                                                                                                                                                                                     | 在存储库表中按 `config-status:failed` 进行筛选，然后按照相应存储库的修复指南进行操作。 有关详细信息，请参阅“[诊断安全配置问题](/zh/enterprise-server@3.22/code-security/reference/security-at-scale/troubleshoot-security-configurations/configuration-issue-diagnosis)”。 |                                 |                 |                                                                                                                                                                                                           |
| `detached`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | 未应用任何配置。 存储库的安全设置是单独管理的。                                                                                                                                                                                                 | 组织管理员解除了该配置的关联，或者该存储库从未关联到任何配置。 | 无需配置            | 如果希望存储库继承集中管理的设置，请应用配置。 有关详细信息，请参阅“[删除自定义安全配置](/zh/enterprise-server@3.22/code-security/how-tos/secure-at-scale/configure-organization-security/establish-complete-coverage/apply-custom-configuration)”。 |

## 理解 `removed` 与 `detached`

这些状态反映不同的情况：

* **`removed`**：存储库管理员更改了与未强制配置冲突的安全设置。 配置仍与存储库相关联，但存储库不再计入组织的该配置的覆盖范围指标。 重新应用配置可还原关系。
* **`detached`**：配置与存储库完全断开连接。 存储库的现有安全设置保持不变，但没有配置对其进行管理。 若要还原集中管理的设置，请应用新的配置。

若要防止存储库达到 `removed` 状态，请对配置启用强制。 有关详细信息，请参阅“[安全配置的强制执行](/zh/enterprise-server@3.22/code-security/reference/security-at-scale/configuration-enforcement)”。

## 使用审核日志跟踪配置状态更改

每当配置状态发生更改时，组织的审核日志记录 `repository_security_configuration` 事件。 可以使用筛选器搜索这些事件 `action:repository_security_configuration` 。 有关详细信息，请参阅 [组织的审核日志事件](/zh/enterprise-server@3.22/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/audit-log-events-for-your-organization) 和 [搜索企业的审核日志](/zh/enterprise-server@3.22/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/searching-the-audit-log-for-your-enterprise)。

## 延伸阅读

* [大规模启用安全功能](/zh/enterprise-server@3.22/code-security/concepts/security-at-scale/organization-security)
* [安全配置的强制执行](/zh/enterprise-server@3.22/code-security/reference/security-at-scale/configuration-enforcement)
* [诊断安全配置问题](/zh/enterprise-server@3.22/code-security/reference/security-at-scale/troubleshoot-security-configurations/configuration-issue-diagnosis)