

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 Amazon Inspector 扫描 Windows EC2 实例
<a name="windows-scanning"></a>

 Amazon Inspector 会自动发现所有支持的 Windows 实例，并将其纳入连续扫描，无需任何额外操作。有关支持哪些实例的信息，请参阅 [Amazon Inspector 支持的操作系统和编程语言](https://docs.amazonaws.cn/inspector/latest/user/supported.html)。Amazon Inspector 会定期运行 Windows 扫描。Windows 实例在发现时进行扫描，然后每 6 小时扫描一次。但是，可以在首次扫描后[调整默认扫描间隔](https://docs.amazonaws.cn/inspector/latest/user/windows-scanning.html#windows-scan-schedule)。

 激活 Amazon EC2 扫描后，Amazon Inspector 会为 Windows 资源创建以下 SSM 关联：`InspectorDistributor-do-not-delete`、`InspectorInventoryCollection-do-not-delete` 和 `InvokeInspectorSsmPlugin-do-not-delete`。若要在 Windows 实例上安装 Amazon Inspector SSM 插件，`InspectorDistributor-do-not-delete` SSM 关联会使用 [`AWS-ConfigureAWSPackage` SSM 文档](https://docs.amazonaws.cn/systems-manager/latest/userguide/sysman-ssm-docs.html)和 [`AmazonInspector2-InspectorSsmPlugin` SSM Distributor 程序包](https://docs.amazonaws.cn/systems-manager/latest/userguide/distributor.html)。有关更多信息，请参阅[适用于 Windows 的 Amazon Inspector SSM 插件](https://docs.amazonaws.cn/inspector/latest/user/deep-inspection.html#inspector/latest/user/deep-inspection.html)。若要收集实例数据并生成 Amazon Inspector 调查发现，`InvokeInspectorSsmPlugin-do-not-delete` SSM 关联会每 6 小时运行一次 Amazon Inspector SSM 插件。但是，您可以[使用 cron 或 rate 表达式自定义此设置](https://docs.amazonaws.cn/systems-manager/latest/userguide/reference-cron-and-rate-expressions.html)。

**注意**  
 Amazon Inspector 将更新的开放漏洞和评测语言（OVAL）定义文件暂存到 S3 存储桶 `inspector2-oval-prod-your-AWS-Region`。Amazon S3 存储桶包含扫描中使用的 OVAL 定义。不应修改这些 OVAL 定义。否则，Amazon Inspector 在新版本发布 CVEs 时将不会对其进行扫描。

## Windows 实例的 Amazon Inspector 扫描要求
<a name="windows-requirements"></a>

要扫描 Windows 实例，Amazon Inspector 要求实例满足以下条件：
+ 该实例是 SSM 托管实例。有关设置扫描实例的说明，请参阅[配置 SSM 代理](scanning-ec2.md#configure-ssm)。
+ 实例操作系统是支持的 Windows 操作系统之一。有关支持的操作系统类型的完整列表，请参阅[Amazon EC2 实例的状态值支持的操作系统：Amazon EC2 扫描](supported.md#supported-os-ec2)。
+ 该实例安装了 Amazon Inspector SSM 插件。Amazon Inspector 会在发现托管实例时自动为其安装 Amazon Inspector SSM 插件。有关该插件的详细信息，请参阅下一个主题。

**注意**  
如果主机在 Amazon VPC 中运行，但没有出站互联网访问权限，则 Windows 扫描要求主机能够访问区域 Amazon S3 端点。要了解如何配置 Amazon S3 Amazon VPC 端点，请参阅 *Amazon Virtual Private Cloud 用户指南*中的[创建网关端点](https://docs.amazonaws.cn/vpc/latest/privatelink/vpc-endpoints-s3.html#create-gateway-endpoint-s3)。如果您的 Amazon VPC 终端节点策略限制对外部 S3 存储桶的访问，则必须明确允许访问由 Amazon Inspector 维护的存储桶 Amazon Web Services 区域 ，该存储桶存储用于评估您的实例的 OVAL 定义。此存储桶使用以下格式：`inspector2-oval-prod-REGION`。

## 为 Windows 实例扫描设置自定义计划
<a name="windows-scan-schedule"></a>

您可以使用 SSM 为 `InvokeInspectorSsmPlugin-do-not-delete` 关联设置 cron 表达式或 rate 表达式，从而自定义 Windows Amazon EC2 实例扫描之间的间隔时间。有关更多信息，请参阅 *Amazon Systems Manager 用户指南*中的[参考：适用于 Systems Manager 的 cron 和 rate 表达式](https://docs.amazonaws.cn/systems-manager/latest/userguide/reference-cron-and-rate-expressions.html)，或使用以下说明。

从以下代码示例中选择一个，使用 rate 表达式或 cron 表达式将 Windows 实例的扫描节奏从默认的 6 小时更改为 12 小时。

以下示例要求您使用名**AssociationId**为的关联`InvokeInspectorSsmPlugin-do-not-delete`。你可以**AssociationId**通过运行以下 Amazon CLI 命令来检索你的：

```
$ aws ssm list-associations --association-filter-list "key=AssociationName,value=InvokeInspectorSsmPlugin-do-not-delete" --region us-east-1
```

**注意**  
**AssociationId**是区域性的，因此您需要先为每个区域检索一个唯一的 ID Amazon Web Services 区域。然后，您可以运行上述命令，在要为 Windows 实例设置自定义扫描计划的每个区域更改扫描节奏。

------
#### [ Example rate expression ]

```
$ aws ssm update-association \
--association-id "YourAssociationId" \
--association-name "InvokeInspectorSsmPlugin-do-not-delete" \
--schedule-expression "rate(12 hours)"
```

------
#### [ Example cron expression ]

```
$ aws ssm update-association \
--association-id "YourAssociationId" \
--association-name "InvokeInspectorSsmPlugin-do-not-delete" \
--schedule-expression "cron(0 0/12 * * ? *)"
```

------