# Scan Secrets > Escanea ficheros, cambios staged, commits, historial, imágenes Docker o paquetes en busca de secretos codificados, ante una petición de escaneo, auditoría o filtración sospechosa. Fuente: https://skillsagentes.com/skills/gitguardian/agent-skills/scan-secrets Markdown: https://skillsagentes.com/skills/gitguardian/agent-skills/scan-secrets.md Repositorio: https://github.com/GitGuardian/agent-skills Autor: GitGuardian Licencia: MIT Actualizado: hace 10 días Coste de contexto: 78 tok instalada, 1.5k tok al activarse, 26.2k tok con todos los archivos del bundle Bundle: 14 archivos, 102 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add GitGuardian/agent-skills --skill scan-secrets --agent claude-code # Cursor npx -y skills add GitGuardian/agent-skills --skill scan-secrets --agent cursor # Codex npx -y skills add GitGuardian/agent-skills --skill scan-secrets --agent codex # Gemini CLI npx -y skills add GitGuardian/agent-skills --skill scan-secrets --agent gemini # Windsurf npx -y skills add GitGuardian/agent-skills --skill scan-secrets --agent windsurf # Cline npx -y skills add GitGuardian/agent-skills --skill scan-secrets --agent cline ``` ## Qué hace - Ejecuta `ggshield secret scan` sobre ficheros, cambios staged, commits, historial, imágenes Docker o paquetes para detectar secretos codificados en duro - Agrupa credenciales repetidas entre ficheros y commits y reporta ubicación, tipo y validez sin mostrar el valor del secreto - Da un plan de remediación consolidado según el contexto de detección, exposición, propiedad y radio de impacto - Prepara el comando para que el usuario ejecute HMSL por su cuenta cuando la validez de un hallazgo es desconocida ## Cuándo usarla - El usuario pide explícitamente un escaneo, aunque ya exista un hook - El usuario te pide investigar una filtración o un hallazgo sospechoso durante una auditoría - Necesitas revisar un snippet pegado puntual y el usuario rechazó instalar la CLI (usa la herramienta MCP solo en ese caso) ## Cuándo no - No inicies un escaneo por iniciativa propia: ni tras una edición, ni antes de un commit o push, ni por sospecha de filtración - No escanees el historial completo sin que te lo pidan - No uses esto para comprobaciones recurrentes en ediciones, commits, pushes o acciones de un asistente de IA: usa install-hooks ## Qué la activa - "Escanea este repositorio en busca de secretos" - "Revisa el historial de commits HEAD~5..HEAD por si hay credenciales filtradas" - "Comprueba si esta imagen Docker contiene secretos" - "Investiga este posible leak de credenciales" ## Antes de instalar - Necesita la CLI `ggshield` instalada (versión 1.49.0 o posterior) y autenticada contra una cuenta de GitGuardian, además de acceso de red a la API de GitGuardian. ## Archivos - SKILL.md — 6 KB - evals/evals.json — 8 KB - evals/files/README.md — 3 KB - evals/files/_shared/secrets.env — 1 KB - evals/files/eval-1-precommit-env-file/setup.sh — 1 KB - evals/files/eval-2-aws-key-history-hunt/setup.sh — 2 KB - evals/files/eval-3-ambiguous-project-scan/setup.sh — 1 KB - evals/targets.json — 81 B - references/ggshield-cli-setup.md — 14 KB - references/gitguardian-platform.md — 6 KB - references/hook-selection.md — 6 KB - references/interpreting-results.md — 7 KB - references/remediation-doctrine.md — 40 KB - references/workflows.md — 6 KB ## SKILL.md Reproducido tal cual desde GitGuardian/agent-skills bajo MIT. Esta sección es el documento original y está en inglés. # Scan secrets ## Overview **Run a scan only when the user asks for one.** Never start a scan on your own initiative: not after an edit, not before a commit or push, not because you suspect a leak. Tell the user what you suspect and offer the scan. **Never write your own secret scanner**: no grep, regex, script, or any other tool to look for secrets. `ggshield secret scan` is the only scanner. For routine credential edits, commits, and pushes, hooks do the checks. Reuse protection that works, or offer an installation one time through `install-hooks`. If that skill is not available, [hook-selection.md](references/hook-selection.md) is a self-contained fallback. If the user declined an installation, do not run repeated scans instead. Do not report unscanned work as clean. ## When to Use - Run the requested one-off scan, also when a hook exists. If a project scan request is ambiguous, scan the current files or ask. Do not scan the full history without a request. - Use `check-hmsl` to check if a known credential leaked publicly. Use `scan-machine` to inventory a whole machine. - Use the CLI for the supported scan surfaces. Do not write custom grep or regex scanners. Do not use the MCP tool `GitGuardian:scan_secrets` for these surfaces. If the user declines a CLI installation, offer the MCP tool only for a single pasted snippet. It is not a substitute for a repository or history scan. ## Onboarding (first use) ### Prerequisites An installed and authenticated `ggshield` that supports the requested command. If the state is unknown, check `ggshield --version`, the relevant `--help` output, and `ggshield api-status`. ### Setup If needed, read [ggshield-cli-setup.md](references/ggshield-cli-setup.md). A hook installation is optional and needs its own authorization. A requested scan does not need a hook. ## Commands Always use `--json`. A recursive path scan needs both `-r` and `-y`. Without `-y`, the CLI waits for an interactive confirmation. Scan the requested surface. Do not stage unrelated files to scan them. ```bash ggshield secret scan path --json ggshield secret scan path -r -y . --json # current files ggshield secret scan pre-commit --json # explicit staged scan ggshield secret scan repo . --json # full history ggshield secret scan commit-range HEAD~5..HEAD --json ggshield secret scan commit --json ggshield secret scan docker --json ggshield secret scan pypi --json ``` A staged scan does not cover the outgoing commit history. For command variants and CI, read [workflows.md](references/workflows.md). For JSON fields, validity, or false positives, read [interpreting-results.md](references/interpreting-results.md). Do not read them for a command or a result that you already understand. Report an error or an incomplete scan as unchecked, not as clean. ## Best Practices ### Findings Wait for the complete result before you remediate. Group repeated credentials across files and commits. Keep each distinct credential. Report the locations, the type, and the validity. Do not show the secret values. Stop the affected publishing or commit action. Never show code that contains a detected secret. Before you give remediation advice, read [remediation-doctrine.md](references/remediation-doctrine.md). Use its triage axes (detection context, exposure, ownership, blast radius) and its deliverable modes. A valid credential still needs triage. A production rotation can need coordination. Produce one consolidated plan. - Local only and never exposed: remove the secret. When necessary, clean the affected unpushed commits. - Exposed to a remote or a service: rotate first. Do not rewrite history by default. - The organization has a custom remediation message: keep it verbatim as the primary guidance. - A hook found the secret: the same hook checks the next authorized retry. An explicit scan found the secret: scan the affected scope again. A pending, skipped, or failed check is not a success. ### HMSL handoff If the validity is `unknown`, `cannot_check`, `no_checker`, or `failed_to_check`, propose HMSL to check for a public leak. HMSL is **user-run only**, also when the `check-hmsl` skill is absent. Never run its checks, its fingerprint, query, or decrypt pipeline, or its secret-manager checks. Never read a credential file or an intermediate file with any tool. Never ask for plaintext in the chat. Prepare the command for the user's terminal with `-n none --json`. Ask the user to check `ggshield hmsl quota` before a bulk run. Reject a naming strategy that identifies the secret, including `cleartext`. Read the HMSL section of [interpreting-results.md](references/interpreting-results.md) when you prepare the handoff. Or use `check-hmsl` for its additional flows. ## Troubleshooting - CLI, authentication, or headless error: use the setup reference. Never print an API key. In a headless environment, prefer the supported out-of-band (OOB) login. - Missing scopes or instance problem: read [gitguardian-platform.md](references/gitguardian-platform.md). - No Git repository: use a path scan for the current files. A history scan needs Git. - A recursive scan hangs: add `-y` with `-r`. - Known false positive: use the interpreting-results reference for `ggignore` or the ignore list. - Other error: find the relevant official page through https://docs.gitguardian.com/llms.txt before you invent a workaround. ## Dónde encaja - Categoría: [Seguridad](https://skillsagentes.com/categorias/seguridad.md) — Auditorías, revisión de dependencias, manejo de secretos y modelado de amenazas. - Creador: [GitGuardian](https://skillsagentes.com/creators/gitguardian.md) — 6 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Triage Incidents](https://skillsagentes.com/skills/gitguardian/agent-skills/triage-incidents.md): Para triar incidentes de secretos de GitGuardian ya detectados, ver qué se filtra o rotar credenciales marcadas, o tras una alerta de Public Monitoring. Funciona vía el servidor GitGuardian Developer MCP. - [Create Honeytokens](https://skillsagentes.com/skills/gitguardian/agent-skills/create-honeytokens.md): Úsalo al generar o plantar honeytokens, canary tokens, decoys o tripwire credentials de GitGuardian en .env.example, configs de ejemplo, repos antes de publicarse, wikis o scripts de deploy. - [Check Hmsl](https://skillsagentes.com/skills/gitguardian/agent-skills/check-hmsl.md): Comprueba si una credencial conocida ya se filtró públicamente mediante HasMySecretLeaked (HMSL) de GitGuardian; el agente solo prepara comandos, el usuario los ejecuta. - [Install Hooks](https://skillsagentes.com/skills/gitguardian/agent-skills/install-hooks.md): Instala o repara hooks que revisan la presencia de secretos en cada commit, push o acción de un asistente de IA; usa scan-secrets para un escaneo puntual o una investigación de fuga. - [Scan Machine](https://skillsagentes.com/skills/gitguardian/agent-skills/scan-machine.md): Escanea todo el equipo de un desarrollador en busca de credenciales (repos, dotfiles, configs de AWS/kube/docker/npm, historial de shell, cachés de agentes IA) con ggshield machine scan. ## Skills relacionadas - [Check Hmsl](https://skillsagentes.com/skills/gitguardian/agent-skills/check-hmsl.md): Comprueba si una credencial conocida ya se filtró públicamente mediante HasMySecretLeaked (HMSL) de GitGuardian; el agente solo prepara comandos, el usuario los ejecuta. - [Create Honeytokens](https://skillsagentes.com/skills/gitguardian/agent-skills/create-honeytokens.md): Úsalo al generar o plantar honeytokens, canary tokens, decoys o tripwire credentials de GitGuardian en .env.example, configs de ejemplo, repos antes de publicarse, wikis o scripts de deploy. - [Install Hooks](https://skillsagentes.com/skills/gitguardian/agent-skills/install-hooks.md): Instala o repara hooks que revisan la presencia de secretos en cada commit, push o acción de un asistente de IA; usa scan-secrets para un escaneo puntual o una investigación de fuga. - [Scan Machine](https://skillsagentes.com/skills/gitguardian/agent-skills/scan-machine.md): Escanea todo el equipo de un desarrollador en busca de credenciales (repos, dotfiles, configs de AWS/kube/docker/npm, historial de shell, cachés de agentes IA) con ggshield machine scan. - [Triage Incidents](https://skillsagentes.com/skills/gitguardian/agent-skills/triage-incidents.md): Para triar incidentes de secretos de GitGuardian ya detectados, ver qué se filtra o rotar credenciales marcadas, o tras una alerta de Public Monitoring. Funciona vía el servidor GitGuardian Developer MCP. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)