

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

# 识别预签名的请求
<a name="identifying-requests"></a>

## 识别使用预签名 URL 的请求
<a name="requests"></a>

Amazon S3 提供了[两种用于在请求级别监控使用情况的内置机制](https://docs.aws.amazon.com/AmazonS3/latest/userguide/logging-with-S3.html)：Amazon S3 服务器访问日志和 AWS CloudTrail 数据事件。 这两种机制都可以识别预签名 URL 的使用情况。 

要筛选日志以了解预签名 URL 的使用情况，您可以使用身份验证类型。有关服务器访问日志，请查看 “[身份验证类型” 字段，在 Amazon Athena 表中定义该字段](https://docs.aws.amazon.com/AmazonS3/latest/userguide/LogFormat.html#:~:text=Authentication%20Type)时，该字段通常命名为 [authty](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-s3-access-logs-to-identify-requests.html#:~:text=authtype) pe。对于 CloudTrail，[AuthenticationMethod](https://docs.aws.amazon.com/AmazonS3/latest/userguide/cloudtrail-logging-understanding-s3-entries.html#:~:text=AuthenticationMethod)在`additionalEventData`实地考察。在这两种情况下，使用预签名 URL 的请求的字段值均为`QueryString`，而`AuthHeader`大多数其他请求的字段值均为。

`QueryString`用法并不总是与预签名 URL 相关联。要将搜索限制为仅使用预签名 URL，请查找包含查询字符串参数`X-Amz-Expires`的请求。对于服务器访问日志，[请检查 Request-URI](https://docs.aws.amazon.com/AmazonS3/latest/userguide/LogFormat.html#:~:text=Request%2DURI) 并查找查询字符串中`X-Amz-Expires`包含参数的请求。 对于 CloudTrail，检查`requestParameters`元素中是否有`X-Amz-Expires`元素。

```
{"Records": [{…, "requestParameters": {…, "X-Amz-Expires": "300"}}, …]}
```

以下 Athena 查询将应用此过滤器：

```
SELECT * FROM {athena-table} WHERE
  authtype = 'QueryString' AND 
  request_uri LIKE '%X-Amz-Expires=%';
```

对于 AWS CloudTrail Lake，以下查询将应用此过滤器：

```
SELECT * FROM {data-store-event-id} WHERE 
  additionalEventData['AuthenticationMethod'] = 'QueryString' AND 
  requestParameters['X-Amz-Expires'] IS NOT NULL
```

## 识别其他类型的预签名请求
<a name="other"></a>

在 Amazon S3 服务器访问日志中`HtmlForm`，POST 请求还具有唯一的身份验证类型，以及 CloudTrail。 这种身份验证类型不太常见，因此在您的环境中可能找不到这些请求。

以下 Athena 查询将过滤器应用于：`HtmlForm`

```
SELECT * FROM {athena-table} WHERE 
  authtype = 'HtmlForm';
```

对于 CloudTrail Lake，以下查询将应用过滤器：

```
SELECT * FROM {data-store-event-id} WHERE 
  additionalEventData['AuthenticationMethod'] = 'HtmlForm'
```

## 识别请求模式
<a name="patterns"></a>

您可以使用上一节中讨论的技术来查找预签名的请求。但是，为了使这些数据有用，你需要找到模式。您的查询的简单`TOP 10`结果可能会提供见解，但如果这还不够，请使用下表中的分组选项。


| **分组选项** | **服务器访问日志** | **CloudTrail湖** | **描述** | 
| --- | --- | --- | --- | 
| **用户代理** | `GROUP BY useragent` | `GROUP BY userAgent` | 此分组选项可帮助您找到请求的来源和目的。用户代理由用户提供，作为身份验证或授权机制不可靠。但是，如果你正在寻找模式，它可能会揭示很多信息，因为大多数客户使用的是至少部分人类可读的唯一字符串。 | 
| **请求者** | `GROUP BY requester` | `GROUP BY userIdentity['arn']` | 此分组选项有助于查找签署请求的 IAM 委托人。如果您的目标是阻止这些请求或为现有请求创建例外，则这些查询可为此目的提供足够的信息。当您按照 IAM 最佳实践使用角色时，该角色会有一个明确标识的所有者，您可以使用该信息来了解更多信息。 | 
| **来源 IP 地址** | `GROUP BY remoteip` | `GROUP BY sourceIPAddress` | 此选项按到达 Amazon S3 之前的最后一个网络转换跳点进行分组。[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/presigned-url-best-practices/identifying-requests.html)<br />如果您的目标是实施网络控制，则这些数据非常有用。您可能需要将此选项与诸如`endpoint`（用于服务器访问日志）或`vpcEndpointId`（对于 CloudTrail Lake）之类的数据结合使用以明确来源，因为不同的网络可能会重复私有 IP 地址。 | 
| **S3 存储桶名称** | `GROUP BY bucket_name` | `GROUP BY requestParameters['bucketName']` | 此分组选项有助于查找已收到请求的存储桶。这可以帮助您确定是否需要例外。 | 