Content

Xây dựng Content cho Rule

Hướng dẫn người dùng xây dựng nội dung Streaming Rule để phát hành lên Marketplace.

Tài liệu này hướng dẫn Creator tạo content cho Streaming rule để đẩy lên Marketplace. Streaming Rule sử dụng định dạng Sigma-compatible YAML.


Bước 1: Truy cập Streaming rules trong package

  • Đặt file .yaml / .yml vào thư mục rules/streaming/.
  • Mỗi file là 1 rule.

Bước 2: Xây dựng content

Cấu trúc của 1 rule bao gồm:

TrườngKiểu dữ liệuBắt buộcMô tả
titlestringTên ngắn gọn mô tả rule
logsourcemapNguồn log, gồm category và/hoặc product
idstring (UUID)Định danh duy nhất, khuyến nghị dùng UUID v4
statusstringstable | test | experimental | deprecated | unsupported
descriptionstringMô tả chi tiết hành vi rule phát hiện
authorstringTên tác giả
datestringNgày tạo, format YYYY/MM/DD
levelstringcritical | high | medium | low | informational
tagslistMITRE ATT&CK mapping (xem bên dưới)
fieldslistDanh sách field trả về khi rule match
falsepositiveslistCác trường hợp false positive đã biết
tags (MITRE format)listĐịnh dạng tag theo ATT&CK (tactic/technique/sub-technique), xem ví dụ bên dưới
detection (syntax)mapĐịnh nghĩa selection/filter và condition, xem ví dụ bên dưới
condition operatorsstring expressionHỗ trợ: and, or, not, 1 of <pattern>*, all of <pattern>*

MITRE ATT&CK tag format

tags:
  - attack.execution          # Tactic
  - attack.t1059              # Technique
  - attack.t1059.001          # Sub-technique
  - attack.defense_evasion    # Nhiều tactic được phép

Detection syntax

detection:
  # Named selections (có thể có nhiều)
  selection_main:
    FieldName: "value"              # Exact match
    FieldName|contains: "partial"   # Contains
    FieldName|startswith: "prefix"  # Starts with
    FieldName|endswith: "suffix"    # Ends with
    FieldName|re: "regex.*pattern"  # Regex
    FieldName|contains:               # Danh sách OR
      - "value1"
      - "value2"

  filter_exclude:
    FieldName: "excluded_value"

  # Condition kết hợp các selection
  condition: selection_main and not filter_exclude

Condition operators

and, or, not, 1 of <pattern>*, all of <pattern>*

Lưu ý Backend chỉ kiểm tra 3 trường bắt buộc: title, logsource, detection. Các trường còn lại là tuỳ chọn nhưng được khuyến nghị để đảm bảo chất lượng và khả năng duy trì rule.

Ví dụ rule hoàn chỉnh

title: Suspicious PowerShell Encoded Command
id: f1b2c3d4-e5f6-7890-abcd-ef1234567890
status: experimental
description:
  Detects PowerShell execution with encoded command argument, which is a common
  technique used by malware and attackers to obfuscate malicious commands.
author: Security Team
date: 2024/02/20
tags:
  - attack.execution
  - attack.t1059.001
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    Image|endswith: '\powershell.exe'
    CommandLine|contains:
      - '-EncodedCommand'
      - '-enc '
  filter_admin:
    ParentImage|endswith:
      - '\msiexec.exe'
      - '\setup.exe'
  condition: selection and not filter_admin
fields:
  - CommandLine
  - ParentImage
  - User
falsepositives:
  - Legitimate software installers using encoded commands
  - Administrative scripts
level: medium

Bước 3: Validate và Test rule

Cách 1: Dùng Playground (khuyến nghị khi viết mới)

csop-client playground
# Mở http://localhost:8080
# Chọn chế độ "Rule"
# Paste nội dung YAML vào editor
# Nhấn "Validate Rule" — kết quả hiển thị ngay

Cách 2: Dùng validate (kiểm tra cú pháp YAML local)

csop-client validate <package-path>

Cách 3: Dùng test (validate qua API backend)

csop-client test <package-path>
# Chỉ các file trong rules/ mới cần API backend
# Không cần chuẩn bị sample data cho rule
Lưu ý: Mỗi file rule phải có id duy nhất (UUID v4). Có thể dùng công cụ online uuidgenerator.net hoặc lệnh uuidgen trên Linux/macOS.