trufflesecurity/trufflehog
GitHub: trufflesecurity/trufflehog
一款强大的凭证泄露扫描与验证工具,支持从 Git、云存储等多种来源发现并分析敏感密钥。
Stars: 24832 | Forks: 2242
TruffleHog
Find leaked credentials.
[](https://goreportcard.com/report/github.com/trufflesecurity/trufflehog/v3)
[](/LICENSE)
[](/pkg/detectors)
# :mag_right: _正在扫描_

**...以及更多**
要了解更多关于 TruffleHog 及其功能和特性的信息,请访问我们的 [product page](https://trufflesecurity.com/trufflehog?gclid=CjwKCAjwouexBhAuEiwAtW_Zx5IW87JNj97Ci7heFnA5ar6-DuNzT2Y5nIl9DuZ-FOUqx0Qg3vb9nxoClcEQAvD_BwE)。
# :globe_with_meridians: TruffleHog 企业版
您是否有兴趣持续监控 **Git、Jira、Slack、Confluence、Microsoft Teams、Sharepoint(以及更多)** 以查找凭据?我们有一个企业级产品可以提供帮助!在
了解更多。
我们将企业版产品的收入用于资助更多很棒的开源项目,让整个社区都能受益。
# 什么是 TruffleHog 🐽
TruffleHog 是最强大的密钥**发现、分类、验证**和**分析**工具。在此上下文中,密钥(secret)是指机器用来向另一台机器进行身份验证的凭据。这包括 API 密钥、数据库密码、私有加密密钥等。
## 发现 🔍
TruffleHog 可以在许多地方查找密钥,包括 Git、聊天记录、Wiki、日志、API 测试平台、对象存储、文件系统等。
## 分类 📁
TruffleHog 可对 800 多种密钥类型进行分类,并将它们映射回其所属的特定身份。它是 AWS 密钥?Stripe 密钥?Cloudflare 密钥?Postgres 密码?SSL 私钥?有时很难通过查看来判断,因此 TruffleHog 会对它发现的所有内容进行分类。
## 验证 ✅
对于 TruffleHog 可以分类的每一个密钥,它还可以登录以确认该密钥是否有效。此步骤对于了解是否存在活动的当前危险至关重要。
## 分析 🔬
对于大约 20 种最常泄露的凭据类型,TruffleHog 不会仅发送一个请求来检查密钥是否可以登录,而是可以发送许多请求来了解关于该密钥的所有信息。谁创建了它?它可以访问哪些资源?它对这些资源拥有什么权限?
# :loudspeaker: 加入我们的社区
有问题?反馈?加入 Slack 或 Discord 与我们交流。
加入我们的 [Slack Community](https://join.slack.com/t/trufflehog-community/shared_invite/zt-pw2qbi43-Aa86hkiimstfdKH9UCpPzQ)
加入 [Secret Scanning Discord](https://discord.gg/8Hzbrnkr7E)
# :tv: 演示

```
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --org=trufflesecurity
```
# :floppy_disk: 安装
您有多种选择:
### MacOS 用户
```
brew install trufflehog
```
### Docker:
_在执行以下命令之前,请确保 Docker 引擎正在运行:_
#### Unix
```
docker run --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys
```
#### Windows 命令提示符
```
docker run --rm -it -v "%cd:/=\%:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys
```
#### Windows PowerShell
```
docker run --rm -it -v "${PWD}:/pwd" trufflesecurity/trufflehog github --repo https://github.com/trufflesecurity/test_keys
```
#### M1 和 M2 Mac
```
docker run --platform linux/arm64 --rm -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys
```
### 二进制发布版
```
Download and unpack from https://github.com/trufflesecurity/trufflehog/releases
```
### 从源码编译
```
git clone https://github.com/trufflesecurity/trufflehog.git
cd trufflehog; go install
```
### 使用安装脚本
```
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
```
### 使用安装脚本,校验和签名(需要安装 cosign)
```
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -v -b /usr/local/bin
```
### 使用安装脚本安装特定版本
```
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
```
# :closed_lock_with_key: 验证工件
校验和应用于所有工件,生成的校验和文件使用 cosign 签名。
您需要以下工具来验证签名:
- [Cosign](https://docs.sigstore.dev/cosign/system_config/installation/)
验证步骤如下:
1. 从 [releases](https://github.com/trufflesecurity/trufflehog/releases) 页面下载所需的工件文件以及以下文件。
- trufflehog\_{version}\_checksums.txt
- trufflehog\_{version}\_checksums.txt.pem
- trufflehog\_{version}\_checksums.txt.sig
2. 验证签名:
cosign verify-blob \
--certificate \
--signature \
--certificate-identity-regexp 'https://github\.com/trufflesecurity/trufflehog/\.github/workflows/.+' \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com"
3. 确认签名有效后,您可以继续验证 SHA256 校验和是否与下载的工件一致:
sha256sum --ignore-missing -c trufflehog_{version}_checksums.txt
将 `{version}` 替换为下载文件的版本
或者,如果您使用安装脚本,请传递 `-v` 选项以执行签名验证。
这要求在运行安装脚本之前安装 Cosign 二进制文件。
# :rocket: 快速入门
## 1:仅扫描仓库中已验证的密钥
命令:
```
trufflehog git https://github.com/trufflesecurity/test_keys --results=verified
```
预期输出:
```
🐷🔑🐷 TruffleHog. Unearth your secrets. 🐷🔑🐷
Found verified result 🐷🔑
Detector Type: AWS
Decoder Type: PLAIN
Raw result: AKIAYVP4CIPPERUVIFXG
Line: 4
Commit: fbc14303ffbf8fb1c2c1914e8dda7d0121633aca
File: keys
Email: counter
Repository: https://github.com/trufflesecurity/test_keys
Timestamp: 2022-06-16 10:17:40 -0700 PDT
...
```
## 2:仅扫描 GitHub 组织中已验证的密钥
```
trufflehog github --org=trufflesecurity --results=verified
```
## 3:仅扫描 GitHub 仓库中已验证的密钥并获取 JSON 输出
命令:
```
trufflehog git https://github.com/trufflesecurity/test_keys --results=verified --json
```
预期输出:
```
{"SourceMetadata":{"Data":{"Git":{"commit":"fbc14303ffbf8fb1c2c1914e8dda7d0121633aca","file":"keys","email":"counter \u003ccounter@counters-MacBook-Air.local\u003e","repository":"https://github.com/trufflesecurity/test_keys","timestamp":"2022-06-16 10:17:40 -0700 PDT","line":4}}},"SourceID":0,"SourceType":16,"SourceName":"trufflehog - git","DetectorType":2,"DetectorName":"AWS","DecoderName":"PLAIN","Verified":true,"Raw":"AKIAYVP4CIPPERUVIFXG","Redacted":"AKIAYVP4CIPPERUVIFXG","ExtraData":{"account":"595918472158","arn":"arn:aws:iam::595918472158:user/canarytokens.com@@mirux23ppyky6hx3l6vclmhnj","user_id":"AIDAYVP4CIPPJ5M54LRCY"},"StructuredData":null}
...
```
## 4:扫描 GitHub 仓库及其 Issues 和 Pull Requests
```
trufflehog github --repo=https://github.com/trufflesecurity/test_keys --issue-comments --pr-comments
```
## 5:扫描 S3 存储桶以获取高置信度结果(已验证 + 未知)
```
trufflehog s3 --bucket= --results=verified,unknown
```
## 6:使用 IAM 角色扫描 S3 存储桶
```
trufflehog s3 --role-arn=
```
## 7:在 Docker 中使用 SSH 认证扫描 Github 仓库
```
docker run --rm -v "$HOME/.ssh:/root/.ssh:ro" trufflesecurity/trufflehog:latest git ssh://github.com/trufflesecurity/test_keys
```
## 8:扫描单个文件或目录
```
trufflehog filesystem path/to/file1.txt path/to/file2.txt path/to/dir
```
## 9:扫描本地 git 仓库
克隆 git 仓库。例如 [test keys](git@github.com:trufflesecurity/test_keys.git) 仓库。
```
$ git clone git@github.com:trufflesecurity/test_keys.git
```
从父目录(git 仓库外部)运行 trufflehog。
```
$ trufflehog git file://test_keys --results=verified,unknown
```
为了防止本地扫描中的恶意 git 配置(参见 CVE-2025-41390),TruffleHog 在扫描之前将本地 git 仓库克隆到临时目录。这遵循 [Git's security best practices](https://git-scm.com/docs/git#_security)。如果您想指定自定义路径来克隆仓库(而不是 tmp),可以使用 `--clone-path` 标志。如果您想跳过本地克隆过程并直接扫描仓库(仅对受信任的仓库执行此操作),可以使用 `--trust-local-git-config` 标志。
## 10:仅扫描 GCS 存储桶中已验证的密钥
```
trufflehog gcs --project-id= --cloud-environment --results=verified
```
## 11:仅扫描 Docker 镜像中已验证的密钥
多次使用 `--image` 标志以扫描多个镜像。
```
# to scan from a remote registry
trufflehog docker --image trufflesecurity/secrets --results=verified
# to scan from the local docker daemon
trufflehog docker --image docker://new_image:tag --results=verified
# to scan from an image saved as a tarball
trufflehog docker --image file://path_to_image.tar --results=verified
```
## 12:在 CI 中扫描
将 `--since-commit` 标志设置为人们合并到的默认分支(例如:"main")。将 `--branch` 标志设置为您的 PR 分支名称(例如:"feature-1")。根据您使用的 CI/CD 平台,此值可以动态拉取(例如:[CIRCLE_BRANCH in Circle CI](https://circleci.com/docs/variables/) 和 [TRAVIS_PULL_REQUEST_BRANCH in Travis CI](https://docs.travis-ci.com/user/environment-variables/))。如果仓库已克隆且目标分支已在 CI/CD 工作流中检出,那么 `--branch HEAD` 应该就足够了。如果发现有效凭据,`--fail` 标志将返回 183 错误代码。
```
trufflehog git file://. --since-commit main --branch feature-1 --results=verified,unknown --fail
```
## 13:扫描 Postman 工作区多次使用 `--workspace-id`、`--collection-id`、`--environment` 标志以扫描多个目标。
```
trufflehog postman --token= --workspace-id=
```
## 14:扫描 Jenkins 服务器
```
trufflehog jenkins --url https://jenkins.example.com --username admin --password admin
```
## 15:扫描 Elasticsearch 服务器
### 扫描本地集群
使用 TruffleHog 连接本地集群有两种方式:(1) 用户名和密码,(2) 服务令牌。
#### 使用用户名和密码连接本地集群
```
trufflehog elasticsearch --nodes 192.168.14.3 192.168.14.4 --username truffle --password hog
```
#### 使用服务令牌连接本地集群
```
trufflehog elasticsearch --nodes 192.168.14.3 192.168.14.4 --service-token ‘AAEWVaWM...Rva2VuaSDZ’
```
### 扫描 Elastic Cloud 集群
要扫描 Elastic Cloud 上的集群,您需要 Cloud ID 和 API 密钥。
```
trufflehog elasticsearch \
--cloud-id 'search-prod:dXMtY2Vx...YjM1ODNlOWFiZGRlNjI0NA==' \
--api-key 'MlVtVjBZ...ZSYlduYnF1djh3NG5FQQ=='
```
## 16. 扫描 GitHub 仓库以查找跨分叉对象引用和已删除的提交
以下命令将枚举 GitHub 仓库上已删除和隐藏的提交,然后扫描其中的密钥。这是一个 Alpha 发布版功能。
```
trufflehog github-experimental --repo https://github.com//.git --object-discovery
```
除了正常的 TruffleHog 输出外,`--object-discovery` 标志还会在新的 `$HOME/.trufflehog` 目录中创建两个文件:`valid_hidden.txt` 和 `invalid.txt`。这些用于在提交枚举期间跟踪状态,并为用户提供所有隐藏和已删除提交的完整列表(`valid_hidden.txt`)。如果您想在扫描后自动删除这些文件,请添加标志 `--delete-cached-data`。
**注意**:使用此方法枚举仓库上的所有有效提交需要 20 分钟到几个小时,具体取决于仓库的大小。我们添加了一个进度条,以便随时向您更新枚举所需的时间。实际的密钥扫描运行速度极快。
有关跨分叉对象引用的更多信息,请 [read our blog post](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github)。
## 17. 扫描 Hugging Face
### 扫描 Hugging Face 模型、数据集或空间
```
trufflehog huggingface --model --space --dataset
```
### 扫描属于 Hugging Face 组织或用户的所有模型、数据集和空间
```
trufflehog huggingface --org --user
```
(可选)扫描组织或用户时,您可以使用 `--skip-models`、`--skip-datasets`、`--skip-spaces` 跳过整类资源,或者使用 `--ignore-models `、`--ignore-datasets `、`--ignore-spaces ` 跳过特定资源。
### 扫描讨论和 PR 评论
```
trufflehog huggingface --model --include-discussions --include-prs
```
## 18. 扫描标准输入
```
aws s3 cp s3://example/gzipped/data.gz - | gunzip -c | trufflehog stdin
```
# :question: 常见问题
- 我只看到 `🐷🔑🐷 TruffleHog. Unearth your secrets. 🐷🔑🐷` 程序就退出了,怎么回事?
- 这意味着未检测到密钥
- 为什么扫描 GitHub 组织需要很长时间
- 未经身份验证的 GitHub 扫描有速率限制。要提高速率限制,请包含带有个人访问令牌的 `--token` 标志
- 它说私钥已验证,这是什么意思?
- 已验证的结果意味着 TruffleHog 通过针对服务的 API 测试确认凭据有效。对于私钥,我们已确认该密钥可用于实时 SSH 或 SSL 身份验证。查看我们的 Driftwood 博客文章以了解更多信息 [Blog post](https://trufflesecurity.com/blog/driftwood-know-if-private-keys-are-sensitive/)
- 有没有简单的方法可以忽略特定的密钥?
- 如果扫描源 [supports line numbers](https://github.com/trufflesecurity/trufflehog/blob/d6375ba92172fd830abb4247cca15e3176448c5d/pkg/engine/engine.go#L358-L365),那么您可以在包含密钥的行上添加 `trufflehog:ignore` 注释以忽略该密钥。
# :newspaper: v3 有哪些新功能?
TruffleHog v3 是使用 Go 语言完全重写的,具有许多强大的新功能。
- 我们**增加了 700 多个凭据检测器,支持针对其各自的 API 进行主动验证**。
- 我们还添加了原生**支持扫描 GitHub、GitLab、Docker、文件系统、S3、GCS、Circle CI 和 Travis CI**。
- 使用我们的 [Driftwood](https://trufflesecurity.com/blog/driftwood) 技术,**即时验证私钥**,对比数百万 GitHub 用户和**数十亿** TLS 证书。
- 扫描二进制文件、文档和其他文件格式
- 可作为 GitHub Action 和 pre-commit hook 使用
## 什么是凭据验证?
对于检测到的每个潜在凭据,我们都煞费苦心地针对我们认为其所属的 API 实现了程序化验证。验证消除了误报,并提供了三种结果状态:
- **verified**(已验证):通过 API 测试确认为有效且活动的凭据
- **unverified**(未验证):检测到凭据但未确认有效(可能无效、已过期或验证已禁用)
- **unknown**(未知):尝试验证但因错误而失败,例如网络或 API 故障
例如,[AWS credential detector](pkg/detectors/aws/aws.go) 针对 AWS API 执行 `GetCallerIdentity` API 调用,以验证 AWS 凭据是否处于活动状态。
# :memo: 用法
TruffleHog 为您可能想要扫描的每个数据源都有一个子命令:
- git
- github
- gitlab
- docker
- s3
- filesystem(文件和目录)
- syslog
- circleci
- travisci
- gcs(Google Cloud Storage)
- postman
- jenkins
- elasticsearch
- stdin
- multi-scan
每个子命令都可以有选项,您可以通过提供给子命令的 `--help` 标志查看:
```
$ trufflehog git --help
usage: TruffleHog git []
Find credentials in git repositories.
Flags:
-h, --help Show context-sensitive help (also try --help-long and --help-man).
--log-level=0 Logging verbosity on a scale of 0 (info) to 5 (trace). Can be disabled with "-1".
--profile Enables profiling and sets a pprof and fgprof server on :18066.
-j, --json Output in JSON format.
--json-legacy Use the pre-v3.0 JSON format. Only works with git, gitlab, and github sources.
--github-actions Output in GitHub Actions format.
--concurrency=20 Number of concurrent workers.
--no-verification Don't verify the results.
--results=RESULTS Specifies which type(s) of results to output: verified (confirmed valid by API), unknown (verification failed due to error), unverified (detected but not verified), filtered_unverified (unverified but would have been filtered out). Defaults to all types.
--allow-verification-overlap
Allow verification of similar credentials across detectors
--filter-unverified Only output first unverified result per chunk per detector if there are more than one results.
--filter-entropy=FILTER-ENTROPY
Filter unverified results with Shannon entropy. Start with 3.0.
--config=CONFIG Path to configuration file.
--print-avg-detector-time
Print the average time spent on each detector.
--no-update Don't check for updates.
--fail Exit with code 183 if results are found.
--verifier=VERIFIER ... Set custom verification endpoints.
--custom-verifiers-only Only use custom verification endpoints.
--archive-max-size=ARCHIVE-MAX-SIZE
Maximum size of archive to scan. (Byte units eg. 512B, 2KB, 4MB)
--archive-max-depth=ARCHIVE-MAX-DEPTH
Maximum depth of archive to scan.
--archive-timeout=ARCHIVE-TIMEOUT
Maximum time to spend extracting an archive.
--include-detectors="all" Comma separated list of detector types to include. Protobuf name or IDs may be used, as well as ranges.
--exclude-detectors=EXCLUDE-DETECTORS
Comma separated list of detector types to exclude. Protobuf name or IDs may be used, as well as ranges. IDs defined here take precedence over the include list.
--version Show application version.
-i, --include-paths=INCLUDE-PATHS
Path to file with newline separated regexes for files to include in scan.
-x, --exclude-paths=EXCLUDE-PATHS
Path to file with newline separated regexes for files to exclude in scan.
--exclude-globs=EXCLUDE-GLOBS
Comma separated list of globs to exclude in scan. This option filters at the `git log` level, resulting in faster scans.
--since-commit=SINCE-COMMIT
Commit to start scan from.
--branch=BRANCH Branch to scan.
--max-depth=MAX-DEPTH Maximum depth of commits to scan.
--bare Scan bare repository (e.g. useful while using in pre-receive hooks)
Args:
Git repository URL. https://, file://, or ssh:// schema expected.
```
例如,要扫描 `git` 仓库,请从以下开始
```
trufflehog git https://github.com/trufflesecurity/trufflehog.git
```
## 配置
TruffleHog 支持通过 `--config` 标志提供的配置文件中定义 [custom regex detectors](#custom-regex-detector-alpha)
和多个源。
正则表达式检测器可以与任何子命令一起使用,而在配置中定义的
源仅用于 `multi-scan` 子命令。
源的配置格式可以在 Truffle Security 的
[source configuration documentation page](https://docs.trufflesecurity.com/scan-data-for-secrets) 上找到。
示例 GitHub 源配置和 [options reference](https://docs.trufflesecurity.com/github#Fvm1I):
```
sources:
- connection:
'@type': type.googleapis.com/sources.GitHub
repositories:
- https://github.com/trufflesecurity/test_keys.git
unauthenticated: {}
name: example config scan
type: SOURCE_TYPE_GITHUB
verify: true
```
您可以在 `sources` 键下定义多个连接(见上文),
TruffleHog 将并发扫描所有源。
## S3
除了 IAM 用户外,S3 源还支持假定 IAM 角色进行扫描。这使得用户更容易扫描多个 AWS 账户,而无需依赖每个账户的硬编码凭据。
TruffleHog 最初使用的 IAM 身份需要在每个要假定的 IAM 角色的 [trust policy](https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/) 中作为主体拥有 `AssumeRole` 权限。
使用本地设置的凭据或 EC2 实例上的实例元数据扫描特定存储桶:
```
trufflehog s3 --bucket=
```
使用假定角色扫描特定存储桶:
```
trufflehog s3 --bucket= --role-arn=
```
可以将多个角色作为单独的参数传递。以下命令将尝试扫描每个角色有权在 S3 API 中列出的每个存储桶:
```
trufflehog s3 --role-arn= --role-arn=
```
退出代码:
- 0:没有错误,也没有发现结果。
- 1:遇到错误。源可能未完成扫描。
- 183:未遇到错误,但发现了结果。仅在使用 `--fail` 标志时返回。
## :octocat: TruffleHog Github Action
### 一般用法
```
on:
push:
branches:
- main
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Secret Scanning
uses: trufflesecurity/trufflehog@main
with:
extra_args: --results=verified,unknown
```
在上面的示例配置中,我们扫描所有 PR 和推送到 `main` 的代码中的活动密钥。仅扫描引用提交中的代码更改。如果您想扫描整个分支,请参阅下面的“高级用法”部分。
### 浅克隆
如果您将 TruffleHog 整合到独立工作流中,并且没有在 TruffleHog 旁边运行任何其他 CI/CD 工具,那么我们建议使用 [Shallow Cloning](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---depthltdepthgt) 来加快您的工作流程。以下是如何执行此操作的示例:
根据事件类型(推送或 PR),我们计算存在的提交数量。然后我们加 2,以便我们可以引用代码更改之前的基础提交。我们将该整数值传递给 checkout action 中的 `fetch-depth` 标志以及相关分支。现在我们的 checkout 过程应该会短得多。
### 金丝雀检测
TruffleHog 静态检测 [https://canarytokens.org/](https://canarytokens.org/)。

### 高级用法
```
- name: TruffleHog
uses: trufflesecurity/trufflehog@main
with:
# Repository path
path:
# Start scanning from here (usually main branch).
base:
# Scan commits until here (usually dev branch).
head: # optional
# Extra args to be passed to the trufflehog cli.
extra_args: --log-level=2 --results=verified,unknown
```
如果您想指定特定的 `base` 和 `head` 引用,可以使用 `base` 参数(TruffleHog CLI 中的 `--since-commit` 标志)和 `head` 参数(TruffleHog CLI 中的 `--branch` 标志)。我们仅建议在默认行为不起作用的非常特定的用例中使用这些参数。
#### 高级用法:扫描整个分支
```
- name: scan-push
uses: trufflesecurity/trufflehog@main
with:
base: ""
head: ${{ github.ref_name }}
extra_args: --results=verified,unknown
```
## TruffleHog GitLab CI
### 示例用法
```
stages:
- security
security-secrets:
stage: security
allow_failure: false
image: alpine:latest
variables:
SCAN_PATH: "." # Set the relative path in the repo to scan
before_script:
- apk add --no-cache git curl jq
- curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/bin
script:
- trufflehog filesystem "$SCAN_PATH" --results=verified,unknown --fail --json | jq
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
```
在上面的示例管道中,我们扫描所有存储库目录和文件中的活动密钥。此作业仅在管道源是合并请求事件时运行,这意味着它在创建新合并请求时触发。
## Pre-commit Hook
TruffleHog 可以在 pre-commit hook 中使用,以防止凭据在离开您的计算机之前泄露。
有关更多信息,请参阅 [pre-commit hook documentation](PreCommit.md)。
## 自定义正则表达式检测器 (alpha)
TruffleHog 支持检测和验证自定义正则表达式。
对于检测,至少需要一个**正则表达式**和**关键字**。
**关键字**是出现在要检测的正则表达式中或周围的固定文字字符串标识符。为了允许验证的最大灵活性,使用包含正则表达式匹配项的 webhook。
TruffleHog 会将包含正则表达式匹配项的 JSON POST 请求发送到配置的 webhook 端点。如果端点以 `200 OK` 响应状态代码响应,则该密钥被视为已验证。如果由于网络/API 错误导致验证失败,则结果标记为未知。
自定义检测器支持几种不同的过滤机制:熵、针对整个匹配项的正则表达式、针对捕获的密钥的正则表达式,以及针对密钥检查的排除词列表(如果存在捕获组,则为捕获组;如果不存在捕获组,则为整个匹配项)。请注意,如果您的自定义检测器设置了多个 `regex`(在此示例中为 `hogID` 和 `hogToken`),则过滤器将应用于每个正则表达式。[Here](examples/generic_with_filters.yml) 是使用这些过滤器的自定义检测器的示例。
**注意:** 此功能为 Alpha 版,可能会发生变化。
### 正则表达式检测器示例
[Here](/pkg/custom_detectors/CUSTOM_DETECTORS.md) 是如何设置带有验证服务器的自定义正则表达式检测器的方法。
## 通用 JWT 检测
TruffleHog 支持检测和验证其发现的通用 JWT 的一个子集。
具体来说,如果 JWT 使用公钥加密而不是 HMAC,并且可以获得公钥,TruffleHog 可以确定 JWT 是否有效。
## :mag: 分析
TruffleHog 支持对凭据运行更深入的分析,以查看其权限及其有权访问的资源。
```
trufflehog analyze
```
# :heart: 贡献者
这个项目的存在要感谢所有做出贡献的人。[[Contribute](CONTRIBUTING.md)].
# :computer: 贡献
非常欢迎贡献!请参阅我们的 [contribution guidelines first](CONTRIBUTING.md)。
我们不再接受对 TruffleHog v2 的贡献,但该代码在 `v2` 分支中可用。
## 添加新的密钥检测器
我们要发布了一些 [documentation and tooling to get started on adding new secret detectors](hack/docs/Adding_Detectors_external.md)。让我们一起改进检测吧!
# 用作库
目前,trufflehog 正处于密集开发中,此时无法对公共 API 的稳定性做出保证。
# 许可证变更
自 v3.0 起,TruffleHog 在 AGPL 3 许可证下发布,包含在 [`LICENSE`](LICENSE) 中。TruffleHog v3.0 不使用以前的代码库,但注意保持命令行界面的向后兼容性。此版本之前的工作仍在此存储库的历史记录和以前的包发布和标签中以 GPL 2.0 许可证提供。我们需要一份完整的 CLA 才能接受未来的贡献。标签:API密钥检测, DevSecOps, EVTX分析, EVTX分析, EVTX分析, EVTX分析, Git安全, Go语言, LNA, meg, Rust语言, TruffleHog, 上游代理, 云安全监控, 云服务对比, 人工智能安全, 信息安全, 凭据检测, 前端正则化, 合规性, 学术论文, 安全助手, 安全审计, 密钥扫描, 带宽管理, 开源安全工具, 微调策略, 提示注入防御, 敏感信息泄露, 数据投毒, 数据防泄漏, 数据隔离, 日志审计, 源代码安全, 漏洞扫描, 用户界面自定义, 秘密管理, 程序破解, 请求拦截, 越狱攻击, 输入验证, 逆向工程平台, 静态分析, 鲁棒性