Chuyển đến nội dung
Skillpedia
Bảo mật40k · #7419

secret-scanning

Skill này làm gì

Công cụ này giúp tìm và ngăn chặn các thông tin nhạy cảm, như mật khẩu và khóa truy cập, bị lộ ngoài ý muốn trong mã GitHub của bạn. Nó có thể cảnh báo rò rỉ và thậm chí chặn các lần đẩy mã có chứa bí mật.

Khi nào nên dùng

  • ✓Khi thiết lập bảo mật cho dự án trên GitHub.
  • ✓Khi bạn nghi ngờ một mật khẩu hoặc khóa đã bị đẩy lên nhầm.
  • ✓Để ngăn bí mật được gửi lên kho lưu trữ.

Liên kết skill

https://github.com/github/awesome-copilot/blob/main/skills/secret-scanning/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/github/awesome-copilot/blob/main/skills/secret-scanning/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Làm thế nào để thiết lập bảo vệ push (push protection) cho kho lưu trữ của tôi?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

GitHub quét mã của bạn để tìm các mẫu bí mật đã biết. Nếu tìm thấy, nó có thể thông báo cho bạn hoặc chặn lần đẩy mã, tùy theo cấu hình của bạn.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Secret Scanning

This skill provides procedural guidance for configuring GitHub secret scanning — detecting leaked credentials, preventing secret pushes, defining custom patterns, and managing alerts.

When to Use This Skill

Use this skill when the request involves:

  • Enabling or configuring secret scanning for a repository or organization
  • Setting up push protection to block secrets before they reach the repository
  • Defining custom secret patterns with regular expressions
  • Resolving a blocked push from the command line
  • Triaging, dismissing, or remediating secret scanning alerts
  • Configuring delegated bypass for push protection
  • Excluding directories from secret scanning via secret_scanning.yml
  • Understanding alert types (user, partner, push protection)
  • Enabling validity checks or extended metadata checks
  • Scanning local code changes for secrets before committing (via MCP / AI coding agent) — see the Pre-Commit Scanning via AI Coding Agents section below for the recommended plugin

How Secret Scanning Works

Secret scanning automatically detects exposed credentials across:

  • Entire Git history on all branches
  • Issue descriptions, comments, and titles (open and closed)
  • Pull request titles, descriptions, and comments
  • GitHub Discussions titles, descriptions, and comments
  • Wikis and secret gists

Availability

Repository Type Availability
Public repos Automatic, free
Private/internal (org-owned) Requires GitHub Secret Protection on Team/Enterprise Cloud
User-owned Enterprise Cloud with Enterprise Managed Users

Core Workflow — Enable Secret Scanning

Step 1: Enable Secret Protection

  1. Navigate to repository Settings → Advanced Security
  2. Click Enable next to "Secret Protection"
  3. Confirm by clicking Enable Secret Protection

For organizations, use security configurations to enable at scale:

  • Settings → Advanced Security → Global settings → Security configurations

Step 2: Enable Push Protection

Push protection blocks secrets during the push process — before they reach the repository.

  1. Navigate to repository Settings → Advanced Security
  2. Enable "Push protection" under Secret Protection

Push protection blocks secrets in:

  • Command line pushes
  • GitHub UI commits
  • File uploads
  • REST API requests
  • REST API content creation endpoints

Step 3: Configure Exclusions (Optional)

Create .github/secret_scanning.yml to auto-close alerts for specific directories:

paths-ignore:
  - "docs/**"
  - "test/fixtures/**"
  - "**/*.example"

Limits:

  • Maximum 1,000 entries in paths-ignore
  • File must be under 1 MB
  • Excluded paths also skip push protection checks

Best practices:

  • Be as specific as possible with exclusion paths
  • Add comments explaining why each path is excluded
  • Review exclusions periodically — remove stale entries
  • Inform the security team about exclusions

Step 4: Enable Additional Features (Optional)

Non-provider patterns — detect private keys, connection strings, generic API keys:

  • Settings → Advanced Security → enable "Scan for non-provider patterns"

AI-powered generic secret detection — uses Copilot to detect unstructured secrets like passwords:

  • Settings → Advanced Security → enable "Use AI detection"

Validity checks — verify if detected secrets are still active:

  • Settings → Advanced Security → enable "Validity checks"
  • GitHub periodically tests detected credentials against provider APIs
  • Status shown in alert: active, inactive, or unknown

Extended metadata checks — additional context about who owns a secret:

  • Requires validity checks to be enabled first
  • Helps prioritize remediation and identify responsible teams

Core Workflow — Resolve Blocked Pushes

When push protection blocks a push from the command line:

Option A: Remove the Secret

If the secret is in the latest commit:

# Remove the secret from the file
# Then amend the commit
git commit --amend --all
git push

If the secret is in an earlier commit:

# Find the earliest commit containing the secret
git log

# Start interactive rebase before that commit
git rebase -i <COMMIT-ID>~1

# Change 'pick' to 'edit' for the offending commit
# Remove the secret, then:
git add .
git commit --amend
git rebase --continue
git push

Option B: Bypass Push Protection

  1. Visit the URL returned in the push error message (as the same user)

…

Câu hỏi thường gặp

“Secrets” là gì?

Secrets là các thông tin nhạy cảm như mật khẩu, khóa API, token và chứng chỉ, không nên được chia sẻ công khai hoặc xuất hiện trong mã.

Điều gì xảy ra nếu tìm thấy bí mật?

Tùy cấu hình, bạn có thể nhận cảnh báo, hoặc việc đẩy mã có thể bị chặn cho đến khi bí mật được xóa hoặc xử lý.

Tôi có thể bỏ qua một số tệp hoặc thư mục không?

Có, bạn có thể cấu hình GitHub bỏ qua các đường dẫn cụ thể nơi bí mật có thể xuất hiện hợp lệ và không cần quét.

Chi tiết

Mô tả gốc của tác giả

Guide for configuring and managing GitHub secret scanning, push protection, custom patterns, and secret alert remediation. For pre-commit secret scanning in AI coding agents via the GitHub MCP Server, this skill references the Advanced Security plugin (`advanced-security@copilot-plugins`). Use this skill when enabling secret scanning, setting up push protection, defining custom patterns, triaging

repo: github/awesome-copilot

Độ phổ biến

Sao GitHub
40k
Vị trí xếp hạng
#7419
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự