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

sast-scanning

Skill này làm gì

Tool này kiểm tra code của bạn để tìm lỗ hổng bảo mật trước khi được sử dụng. Nó giúp phát hiện các vấn đề như mật khẩu bị lộ hoặc lỗ hổng chèn code (code injection).

Khi nào nên dùng

  • ✓Khi bạn thêm kiểm tra bảo mật vào quy trình phát triển tự động.
  • ✓Khi bạn muốn đảm bảo code an toàn trước khi phát hành.
  • ✓Khi bạn cần đáp ứng các yêu cầu bảo mật do công ty hoặc luật pháp đặt ra.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/sast-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/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/sast-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

“Quét code Python của tôi để tìm các lỗ hổng bảo mật đã biết.”

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

Cách hoạt động

Tool phân tích code đã viết mà không chạy nó, đối chiếu với các mẫu lỗ hổng bảo mật đã biết. Nó dùng các chương trình như Semgrep, CodeQL hoặc SonarQube để tìm vấ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.

SAST Scanning

Identify security vulnerabilities in source code through static analysis.

When to Use This Skill

Use this skill when:

  • Implementing secure SDLC practices
  • Adding security gates to CI/CD
  • Automating code security reviews
  • Finding vulnerabilities before deployment
  • Meeting compliance requirements

Prerequisites

  • Source code access
  • CI/CD pipeline
  • SAST tool installation

Tool Comparison

Tool License Languages Best For
Semgrep OSS/Commercial 30+ Custom rules, speed
CodeQL Free (GitHub) 10+ Deep analysis
SonarQube OSS/Commercial 25+ Quality + Security
Bandit OSS Python Python projects
Brakeman OSS Ruby Rails apps

Semgrep

Installation

# Install via pip
pip install semgrep

# Or via Homebrew
brew install semgrep

Basic Usage

# Run with default rules
semgrep --config auto .

# Run specific rulesets
semgrep --config p/security-audit .
semgrep --config p/owasp-top-ten .
semgrep --config p/ci .

# Scan specific languages
semgrep --config p/python .
semgrep --config p/javascript .

# Output formats
semgrep --config auto --json -o results.json .
semgrep --config auto --sarif -o results.sarif .

Custom Rules

# .semgrep/custom-rules.yaml
rules:
  - id: hardcoded-password
    patterns:
      - pattern-either:
          - pattern: password = "..."
          - pattern: PASSWORD = "..."
          - pattern: passwd = "..."
    message: Hardcoded password detected
    severity: ERROR
    languages: [python, javascript, java]
    metadata:
      cwe: "CWE-798"
      owasp: "A3:2017"

  - id: sql-injection
    patterns:
      - pattern: |
          $QUERY = "..." + $USER_INPUT + "..."
          $DB.execute($QUERY)
    message: Potential SQL injection
    severity: ERROR
    languages: [python]
    metadata:
      cwe: "CWE-89"

  - id: insecure-random
    pattern: random.random()
    message: Use secrets module for security-sensitive randomness
    severity: WARNING
    languages: [python]
    fix: secrets.token_hex()

CI Configuration

# .github/workflows/semgrep.yml
name: Semgrep

on:
  push:
    branches: [main]
  pull_request:

jobs:
  semgrep:
    runs-on: ubuntu-latest
    container:
      image: returntocorp/semgrep
    steps:
      - uses: actions/checkout@v4

      - name: Run Semgrep
        run: semgrep ci
        env:
          SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}

CodeQL

Setup

# .github/workflows/codeql.yml
name: CodeQL Analysis

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  schedule:
    - cron: '0 0 * * 0'

jobs:
  analyze:
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      actions: read
      contents: read

    strategy:
      matrix:
        language: ['javascript', 'python']

    steps:
      - uses: actions/checkout@v4

      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
        with:
          languages: ${{ matrix.language }}
          queries: +security-and-quality

      - name: Autobuild
        uses: github/codeql-action/autobuild@v3

      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v3
        with:
          category: "/language:${{ matrix.language }}"

Custom Queries

// queries/sql-injection.ql
/**
 * @name SQL Injection
 * @description User input in SQL query
 * @kind path-problem
 * @problem.severity error
 * @security-severity 9.0
 * @precision high
 * @id py/sql-injection
 * @tags security
 */

import python
import semmle.python.dataflow.new.DataFlow
import semmle.python.dataflow.new.TaintTracking
import semmle.python.security.dataflow.SqlInjectionQuery

from SqlInjectionConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
select sink.getNode(), source, sink, "SQL injection from $@.", source.getNode(), "user input"

SonarQube

Docker Setup

# docker-compose.yml
version: '3.8'

services:
  sonarqube:
    image: sonarqube:lts-community
    ports:
      - "9000:9000"
    environment:
      - SONAR_JDBC_URL=jdbc:postgresql://db:5432/sonar
      - SONAR_JDBC_USERNAME=sonar
      - SONAR_JDBC_PASSWORD=sonar
    volumes:
      - sonarqube_data:/opt/sonarqube/data
      - sonarqube_logs:/opt/sonarqube/logs
    depends_on:
      - db

  db:
    image: postgres:15

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

Tool này hỗ trợ những ngôn ngữ lập trình nào?

Nó hỗ trợ nhiều ngôn ngữ như Python, JavaScript, Java, Ruby và các ngôn ngữ khác, tùy thuộc vào công cụ cụ thể được dùng.

Tôi có cần cài đặt gì để dùng không?

Có, bạn cần quyền truy cập mã nguồn, một quy trình CI/CD (tích hợp và triển khai liên tục), và các công cụ phân tích bảo mật đã được cài đặt.

Tôi có thể tự tạo quy tắc bảo mật không?

Có, các công cụ như Semgrep cho phép bạn tạo quy tắc tùy chỉnh để tìm các vấn đề riêng của dự án.

Chi tiết

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

Perform static application security testing with tools like Semgrep, CodeQL, and SonarQube.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#5672
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ự