# @actsecurity/iam-lens 中文文档

规范地址：https://npmcn.com/package/%40actsecurity/iam-lens/

版本：0\.1\.193
npm 元数据更新时间：2026-11-04T19:40:05.342Z
中文译文更新时间：2026-11-06T08:36:40.999Z
软件包许可：AGPL-3\.0-or-later

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40actsecurity/iam-lens
原文对照：https://npmcn.com/package/%40actsecurity/iam-lens/?lang=original
项目主页：https://github.com/act-security-labs/iam-lens#readme
源码仓库：https://github.com/act-security-labs/iam-lens

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.9 MB，407 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：11 个
- 首次发布：2026-09-01T07:25:09.681Z
- 最新版本发布：2026-11-04T19:40:04.981Z
- 近 30 天下载量：3798（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：37（近 12 个月 37 个）

## 中文简介

AWS账户和账户之间的IAM可见度

## 安装

```sh
npm install @actsecurity/iam-lens
```

也可以使用：`pnpm add @actsecurity/iam-lens`、`yarn add @actsecurity/iam-lens`、`bun add @actsecurity/iam-lens`

## README

# 亚姆琳斯

[![NPM Version](https://img.shields.io/npm/v/@actsecurity/iam-lens.svg?logo=nodedotjs)](https://www.npmjs.com/package/@actsecurity/iam-lens) [![License: AGPL v3](https://img.shields.io/github/license/act-security-labs/iam-lens)](https://npmcn.com/package/%40actsecurity/iam-lens/LICENSE.txt) [![GuardDog](https://github.com/act-security-labs/iam-lens/actions/workflows/guarddog.yml/badge.svg)](https://github.com/act-security-labs/iam-lens/actions/workflows/guarddog.yml) [![Known Vulnerabilities](https://snyk.io/test/github/act-security-labs/iam-lens/badge.svg?targetFile=package.json&style=flat-square)](https://snyk.io/test/github/act-security-labs/iam-lens?targetFile=package.json)

在您的 AWS 组织和账户中获取可见度 。 使用您实际的 AWS IAM 策略( 下载通过 [收集地图](https://github.com/act-security-labs/iam-collect))并评价有效权限.

## 目录

1.  [快速启动](https://npmcn.com/package/%40actsecurity/iam-lens/#readme-quick-start)
2.  [什么是亚姆琳斯?](https://npmcn.com/package/%40actsecurity/iam-lens/#readme-what-is-iam-lens)
3.  [为什么用它?](https://npmcn.com/package/%40actsecurity/iam-lens/#readme-why-use-it)
4.  [开始](https://npmcn.com/package/%40actsecurity/iam-lens/#readme-getting-started)
5.  [图标](https://npmcn.com/package/%40actsecurity/iam-lens/#readme-commands)
    -   [模拟 - 模拟请求](https://npmcn.com/package/%40actsecurity/iam-lens/docs/Simulate.md)
    -   [who - can - 查找谁可以在资源上执行动作](https://npmcn.com/package/%40actsecurity/iam-lens/docs/WhoCan.md)
    -   [principle-can - 获得校长所有许可的综合政策](https://npmcn.com/package/%40actsecurity/iam-lens/docs/PrincipalCan.md)
    -   [全球CLI 选项](https://npmcn.com/package/%40actsecurity/iam-lens/docs/GlobalCliOptions.md)
6.  [贡献支持( S)](https://npmcn.com/package/%40actsecurity/iam-lens/#readme-contributing--support)
7.  [鸣谢](https://npmcn.com/package/%40actsecurity/iam-lens/#readme-acknowledgements)

## 快速启动

```bash
# Install
npm install -g @actsecurity/iam-collect @actsecurity/iam-lens

# Download all IAM policies in your account using default credentials, run download once per account
iam-collect init
iam-collect download

# Simulate a request
iam-lens simulate --principal arn:aws:iam::123456789012:role/ExampleRole --resource arn:aws:s3:::example-bucket/secret-file.txt --action s3:GetObject

# Find out who can do something
iam-lens who-can --resource arn:aws:s3:::example-bucket --actions s3:ListBucket

# Find out who can do all actions on a resource
iam-lens who-can --resource arn:aws:s3:::example-bucket
```

## 什么是亚姆琳斯?

**亚姆琳斯** 让你 **模拟** 财务报告和审定财务报表 **审计** 对您从 AWS 账户中收集的 IAM 数据(通过 [收集地图](https://github.com/act-security-labs/iam-collect)并了解适用于本金或资源的有效许可.

## 为什么用它?

-   **明白了吗** 实际权限.
-   **校验** 在所有政策实施之后,允许和拒绝结果.
-   **发现** 每一个可以访问给定资源的主 .
-   **审计** 在所有 AWS 账户和 Org 中组合复杂的政策 .
-   **调试** 没有部署或网络呼叫的当地复杂条件.

## 开始

1.  **下载您的策略** 与 [收集地图](https://github.com/act-security-labs/iam-collect) 从您的 AWS 账户获取所有政策。 iam-collection是高度可塑的,可以定制来收集所需的政策. 它只下载信息到您的文件系统或一个S3桶,所以你完全控制了自己的数据.

```bash
npm install -g @actsecurity/iam-collect
iam-collect init
iam-collect download
```

要看到 SCP 和 RCP 的效果,您应该从您的管理账户下载数据;或者允许下载组织信息的账户. 为您要分析的成员账户下载数据 . `iam-lens` 如果有数据,将分析交叉账户和跨组织的请求.

您可下载您喜欢的账户、组织和地区的信息。 数据越多 答案就越准确.

2.  **安装 iam- lens**

```bash
npm install -g @actsecurity/iam-lens
```

3.  **执行命令** 与 `iam-lens` 模拟请求,发现权限,并审计您的 IAM 政策.

模拟请求 :

```bash
iam-lens simulate \
  --principal arn:aws:iam::123456789012:role/ExampleRole \
  --resource arn:aws:s3:::example-bucket/secret-file.txt \
  --action s3:GetObject
```

或者说

发现可以在资源上执行动作的人 :

```bash
iam-lens who-can \
  --resource arn:aws:iam::111111111111:role/ImportantRole \
  --actions sts:AssumeRole iam:PassRole
```

## 图标

### `simulate` - 模拟请求

评价本金是否能够在资源上执行指定的动作(或只记通配符动作). 返回决定 : `Allowed`, (中文(简体) ), `ImplicitlyDenied`,或 `ExplicitlyDenied`全部数据 [条件密钥](https://npmcn.com/package/%40actsecurity/iam-lens/docs/Simulate.md#context-keys) 得到支持,并 [许多上下文密钥自动设定](https://npmcn.com/package/%40actsecurity/iam-lens/docs/Simulate.md#default-context-keys)。 。 。 .

[完整模拟文档](https://npmcn.com/package/%40actsecurity/iam-lens/docs/Simulate.md)

```bash
# Simple simulate: can this role list objects in the bucket?
iam-lens simulate \
  --principal arn:aws:iam::111111111111:role/MyRole \
  --resource arn:aws:s3:::my-bucket \
  --action s3:ListBucket

# Simulate a wildcard action (ListAllMyBuckets) – normal simulation uses the principal's account
iam-lens simulate \
  --principal arn:aws:iam::222222222222:user/Alice \
  --action s3:ListAllMyBuckets

# Include custom context keys
iam-lens simulate \
  --principal arn:aws:iam::333333333333:role/DevRole \
  --resource arn:aws:sqs:us-east-1:333333333333:my-queue \
  --action sqs:SendMessage \
  --context aws:SourceVpc vpc-1234567890abcdef0 \
  --verbose

# Assert the result must be “Allowed”; exit code will be nonzero if not
iam-lens simulate \
  --principal arn:aws:iam::444444444444:role/ReadOnly \
  --resource arn:aws:dynamodb:us-east-1:444444444444:table/Books \
  --action dynamodb:Query \
  --expect Allowed

# Simulate unsigned access to a concrete resource ARN
iam-lens simulate \
  --anonymous \
  --resource arn:aws:s3:::public-bucket/report.txt \
  --action s3:GetObject

# Simulate an administrator principal outside the dataset, without SCPs
iam-lens simulate \
  --external-principal \
  --principal arn:aws:iam::999999999999:role/ExternalRole \
  --resource arn:aws:s3:::example-bucket/report.txt \
  --action s3:GetObject

# Simulate access to a resource outside the dataset
iam-lens simulate \
  --external-resource \
  --principal arn:aws:iam::444444444444:role/ReadOnly \
  --resource arn:aws:s3:::external-bucket/report.txt \
  --resource-account 999999999999 \
  --action s3:GetObject
```

这些变体明确了它们的假设:

-   **无名** 请求没有身份政策、会话政策、许可边界或SCP。 需要资源 ARN( 支持 wildcard 资源模式), 但不需要收集资源; 指定 `--resource-account` 当它不能被推断的时候, 无法提供主上下文密钥 。 现有的资源政策,RCP,VPC端点政策以及收集的S3控制仍然适用.
-   **外部主笔** 请求从未收账的账户中创建一个本金模型,其中包含一个合成的允许所有身份政策,没有权限边界或SCP。 届会政策和收集的资源方控制仍然适用,因此交叉账户访问仍然需要适用的资源方赠款。 在发现模式下,主标记等未知主属性作为条件返回.
-   **外部资源** 请求需要具体资源ARN,并保留所收集的主体身份政策、许可界限、会话政策、SCP和VPC端点政策。 它们不实行区域协商进程,而是采用供应或合成资源/信托政策。 S3 ABAC 和 Block Public Access 默认禁用未收集的资源;ABAC 可用 `--s3-abac-override enabled`。 。 。 .

匿名,外主,外主资源模拟不支持通配符只操作. 政策凌驾和其他细节的完整文件.

[完整模拟文档](https://npmcn.com/package/%40actsecurity/iam-lens/docs/Simulate.md)

### `who-can` - 找到谁可以在资源上执行动作

```bash
iam-lens who-can [options]
```

列出您 IAM 数据中允许在一个资源上执行一个或多个指定动作(或只记通配符动作)的所有主符 。 如果适用,它将检查资源政策,以找到交叉账户权限和AWS服务主机。 还模拟了潜在的公共资源政策,用于未签名的访问,返回为 `"principal": "anonymous"`,包括通配符资源模式.

[完全可以获取文件](https://npmcn.com/package/%40actsecurity/iam-lens/docs/WhoCan.md)

**实例:**

```bash
# Who can get this object?
iam-lens who-can \
  --resource arn:aws:s3:::my-bucket/secret-file.txt \
  --actions s3:GetObject

# Who can list all IAM roles in this account? (wildcard action – no resource)
iam-lens who-can \
  --resource-account 555555555555 \
  --actions iam:ListRoles

# Check multiple actions at once
iam-lens who-can \
  --resource arn:aws:dynamodb:us-east-1:555555555555:table/Books \
  --actions dynamodb:Query dynamodb:UpdateItem

# Check a wildcard resource prefix and inspect allowed patterns
iam-lens who-can \
  --resource arn:aws:s3:::my-bucket/reports/* \
  --actions s3:GetObject

# Check all actions for a bucket
iam-lens who-can \
  --resource arn:aws:s3:::my-bucket
```

[完全可以获取文件](https://npmcn.com/package/%40actsecurity/iam-lens/docs/WhoCan.md)

### `principal-can` - 获得校长所有许可的综合政策

```bash
iam-lens principal-can --principal <arn> [--shrink-action-lists]
```

创建一个合并的政策文件,显示一个主机能够根据其身份政策、权限界限、SCP、RCP和资源政策执行的所有权限。 产出是综合的IAM政策,代表所有政策评价之后的有效授权.

[完整的主要文件](https://npmcn.com/package/%40actsecurity/iam-lens/docs/PrincipalCan.md)

**实例:**

```bash
# Get all permissions for a user or role
iam-lens principal-can \
  --principal arn:aws:iam::123456789012:user/Alice

# Get permissions for a role with shrunk action lists
iam-lens principal-can \
  --principal arn:aws:iam::123456789012:role/MyRole \
  --shrink-action-lists
```

[完整的主要文件](https://npmcn.com/package/%40actsecurity/iam-lens/docs/PrincipalCan.md)

## 贡献支持( S)

最好的支持方法是 [打开一个问题](https://github.com/act-security-labs/iam-lens/issues) 并告诉我们任何错误, 特性请求, 或问题。 我们总是想方设法改进工程,使工程对大家更加有用.

## 鸣谢

特别感谢 [齐亚德·阿尔姆巴舍](https://www.linkedin.com/in/ziadmo/) 用于测试,验证,提供反馈,以及作者认为"这很好"时不放.

## 常见问题

### @actsecurity/iam-lens 是什么？

AWS账户和账户之间的IAM可见度

### 如何安装 @actsecurity/iam-lens？

在项目目录运行 npm install @actsecurity/iam-lens，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 iam-lens，可以用 npx iam-lens 直接运行。

### @actsecurity/iam-lens 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @actsecurity/iam-lens 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @actsecurity/iam-lens 可以商用吗？

@actsecurity/iam-lens 使用 AGPL-3\.0-or-later 许可。最严格的 Copyleft：除分发外，通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括，不构成法律意见，请以许可原文为准。

### @actsecurity/iam-lens 的下载量有多少？

根据 npm 官方下载统计，@actsecurity/iam-lens 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,798 次，日均约 127 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @actsecurity/iam-lens 还在维护吗？

最新版本 0\.1\.193 发布于 2026/11/05（1 天前）；至今共发布 37 个版本，其中过去 12 个月发布了 37 个；首次发布于 2026/09/01。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

