Skip to content
이 페이지는 AI의 도움으로 작성 및 번역되었습니다. 부정확한 내용이 있으면 개선에 참여해 주세요. GitHub에서 편집

YAML 규칙 구문

PRX-WAF 규칙은 YAML 파일로 정의됩니다. 각 파일은 여러 규칙을 포함할 수 있습니다.

규칙 구조

yaml
- id: "CUSTOM-001"
  name: "Block SQL Injection in query params"
  description: "Detects classic SQL injection patterns in URL query strings"
  category: "sqli"
  severity: "high"
  priority: 100
  enabled: true
  action: "block"
  conditions:
    - field: "query_string"
      operator: "regex"
      value: "(?i)(union|select|insert|update|delete|drop|exec)"
  tags: ["sqli", "owasp"]

규칙 필드

필드유형필수설명
idstring고유 규칙 식별자 (예: "CUSTOM-001")
namestring사람이 읽을 수 있는 규칙 이름
descriptionstring아니오규칙이 탐지하는 내용에 대한 설명
categorystring규칙 카테고리: sqli, xss, rfi, rce, bot, scanner, custom
severitystring위협 심각도: low, medium, high, critical
priorityinteger아니오평가 순서 (높을수록 먼저 평가됨, 기본값: 0)
enabledboolean아니오규칙 활성화 여부 (기본값: true)
actionstring탐지 시 취할 액션 (아래 액션 참조)
conditionsarray일치 조건 목록 (아래 조건 참조)
tagsstring[]아니오검색 및 필터링을 위한 태그

조건 필드

각 조건에는 다음이 포함됩니다:

필드유형필수설명
fieldstring검사할 요청 필드 (아래 필드 참조)
operatorstring비교 연산자 (아래 연산자 참조)
valuestring비교 값
negateboolean아니오true이면 매칭을 반전 (기본값: false)
transformstring[]아니오비교 전 적용할 변환 (예: ["lowercase", "url_decode"])

요청 필드

필드설명
methodHTTP 메서드 (GET, POST 등)
uri전체 요청 URI
pathURI 경로 부분
query_string원시 쿼리 문자열
header.<name>특정 헤더 값 (예: header.user-agent)
headers모든 헤더 (연결됨)
body요청 바디 (원시)
ip클라이언트 IP 주소
host호스트 헤더 값
cookie.<name>특정 쿠키 값

연산자

연산자설명
equals정확한 문자열 매칭
contains부분 문자열 포함 여부
starts_with지정된 접두사로 시작
ends_with지정된 접미사로 끝남
regex정규식 매칭 (Rust regex 구문)
ip_rangeIP가 CIDR 범위 내에 있는지 확인
length_gt길이가 값보다 큼
length_lt길이가 값보다 작음
exists필드가 존재하고 비어 있지 않음
not_exists필드가 존재하지 않거나 비어 있음
in_list쉼표로 구분된 목록에서 값과 일치

액션

액션설명
block요청을 403 Forbidden으로 거부
allow추가 처리 없이 즉시 허용
log이벤트 로깅만 (차단 없음)
challengeJavaScript 챌린지 제공 (봇 탐지)
redirect다른 URL로 리디렉션
rate_limit클라이언트에 속도 제한 적용

여러 조건

규칙에 여러 조건이 있으면 모두 참이어야 합니다 (AND 논리):

yaml
- id: "CUSTOM-002"
  name: "Block POST with SQL in body from non-admin IPs"
  category: "sqli"
  severity: "high"
  action: "block"
  conditions:
    - field: "method"
      operator: "equals"
      value: "POST"
    - field: "body"
      operator: "regex"
      value: "(?i)(union.*select|select.*from)"
    - field: "ip"
      operator: "ip_range"
      negate: true
      value: "10.0.0.0/8"

변환

조건에 transform을 사용하여 비교 전에 필드 값을 전처리합니다:

yaml
conditions:
  - field: "query_string"
    operator: "regex"
    value: "(?i)script"
    transform:
      - "url_decode"        # URL 디코딩 먼저
      - "html_entity_decode" # HTML 엔티티 디코딩
      - "lowercase"         # 소문자 변환

사용 가능한 변환: lowercase, uppercase, url_decode, base64_decode, html_entity_decode, remove_whitespace

Rhai 스크립팅

복잡한 탐지 로직에는 인라인 Rhai 스크립트를 사용합니다:

yaml
- id: "CUSTOM-003"
  name: "Complex custom detection"
  category: "custom"
  severity: "medium"
  action: "log"
  script: |
    let score = 0;
    if request.header("user-agent").contains("bot") { score += 10; }
    if request.query_string().len() > 1000 { score += 20; }
    score > 25

다음 단계

Released under the Apache-2.0 License.