# 간단한 디택션 작성하기

## 개요

간단한 디택션은 CLI 워크플로에서 YAML로 생성할 수 있으며, 다음에서 생성하는 것에 더해 가능합니다. [간단한 디택션 빌더](/ko/detections/rules/simple-detection-builder.md) Console에서.

CLI 워크플로에서 생성한 후 Panther에 업로드한 간단한 디택션은 다음에서 보고 편집할 수 있습니다. [간단한 디택션 빌더](/ko/detections/rules/simple-detection-builder.md) Console에서. 이는 팀 구성원들의 YAML 경험 수준이 서로 다를 경우 유용할 수 있습니다.

간단한 디택션은 다음에서 사용할 수 있습니다. [디택션 파생](/ko/detections/rules/derived.md).

디택션을 로컬에서 간단한 디택션(YAML)으로 작성할지 Python 디택션으로 작성할지 확신이 없다면, 다음을 참조하세요. [Python과 간단한 디택션 YAML 사용](https://docs.panther.com/ko/detections/rules/pages/03a99462193d3cb6f09cb46a6d9fa32a7a6035d0#using-python-vs.-simple-detections-yaml) 섹션.

{% hint style="info" %}
팀에서 CLI 워크플로를 사용해 디택션 콘텐츠를 관리하는 경우, 다음을 사용해 디택션에 적용한 변경 사항은 [간단한 디택션 빌더](/ko/detections/rules/simple-detection-builder.md) Console에서 다음 업로드 시 덮어써집니다(다음 제외: [인라인 필터](#inlinefilters) Console에서 생성된 것으로, 이는 유지됩니다).

Console의 간단한 디택션 빌더를 사용하여 디택션을 생성하거나 편집하는 경우, 결과 YAML 표현을 복사하여 로컬 디택션 파일에 포함해 다음 업로드 시 변경 사항이 덮어써지는 것을 방지하세요.
{% endhint %}

### 간단한 디택션 YAML의 제한 사항

* [예약된 룰](/ko/detections/rules.md) Run Panther AI [정책](/ko/detections/policies.md) 간단한 디택션으로 생성할 수 없습니다.
  * 오직 [룰](/ko/detections/rules.md) 만 YAML에서 생성할 수 있습니다.
* Panther 관리형 간단한 디택션은 아직 제공되지 않습니다.
  * 하지만 다음을 사용하는 것은 가능합니다. [Panther 관리형 Python 디택션](/ko/detections/panther-managed.md) 을(를) 자체 간단한 디택션과 함께 사용하는 것.
* 특정 로그 소스용 함수를 포함해 Python에서 사용할 수 있는 많은 헬퍼 함수는 YAML로 표현되지 않습니다.
  * 일부 [전역 헬퍼](https://github.com/panther-labs/panther-analysis/tree/master/global_helpers) 는 YAML 키로 변환되었습니다. 예: [`deep_get()` ](/ko/detections/rules/python/globals.md#deep_get)은 [`DeepKey`](/ko/detections/rules/writing-simple-detections/match-expression.md#deepkey).
* 간단한 디택션에서는 외부 API 호출을 할 수 없으며, 여기에는 값을 가져와 사용하기 위해 Dynamo KV 스토어에서 값을 가져오는 것도 포함됩니다. [캐싱](/ko/detections/rules/python/caching.md).

## YAML에서 간단한 디택션(룰)을 만드는 방법

<details>

<summary>CLI 워크플로에서 간단한 디택션 룰 만들기</summary>

간단한 디택션을 로컬에서 작성하는 경우(다음이 아니라 [간단한 디택션 빌더](/ko/detections/rules/simple-detection-builder.md) Console에서), 로컬 디택션 파일은 GitHub 또는 GitLab 같은 버전 관리 시스템에서 관리하는 것을 권장합니다.

**폴더 설정**

룰을 폴더로 그룹화하는 경우, 각 폴더 이름에는 반드시 다음이 포함되어야 합니다. `룰` 업로드 중(PAT 또는 Console의 대량 업로더 사용) 이를 찾을 수 있도록 하기 위해서입니다.

로그/리소스 유형을 기준으로 룰을 폴더로 그룹화하는 것을 권장합니다. 예: `suricata_rules` 또는 `aws_s3_policies`.

**파일 설정**

각 룰 및 예약된 룰은 다음으로 구성됩니다:

* YAML 사양 파일(다음 확장자를 가진 파일 `.yml` 디택션 로직과 디택션의 메타데이터 속성을 포함하는 확장)
  * 이 파일은 일부 추가 키가 있는 Python YAML 파일과 유사한 구문을 가지고 있습니다.

간단한 디택션 규칙에는 다음이라고 불리는 불리언 논리 목록이 포함됩니다 [일치 표현식](/ko/detections/rules/writing-simple-detections/match-expression.md) 의심스러운 행동을 감지합니다. 값 반환 `참` 의심스러운 활동을 나타내며, 이는 알러트를 트리거합니다.

에 대해 자세히 알아보기 [간단한 디택션 YAML 구문](#simple-detection-yaml-syntax), 그리고 a를 봅니다 [아래 필수 및 선택 YAML 필드의 전체 목록](#simple-detection-rule-specification-reference).

* YAML 파일을 만드세요(예: `my_new_룰.yml`) 아래 템플릿을 사용하여(최상위 수준의 `디택션` 키):

  ```yaml
  AnalysisType: 룰
  DedupPeriodMinutes: 60 # 1시간
  표시 이름: 형식 확인용 예제 룰
  활성화됨: true
  룰ID: Type.Behavior.MoreContext
  심각도: 높음
  로그 유형:
    - LogType.GoesHere
  보고서:
    보고서 이름(예: CIS, MITRE ATT&CK):
      - 이 룰과 관련된 특정 보고서 섹션
  태그:
    - 태그
    - Go
    - 여기
  설명: >
    이 룰은 Panther CLI의 CLI 워크플로를 검증하기 위해 존재합니다
  런북: >
    먼저, 이 스펙 형식을 작성한 사람이 누구인지 알아낸 다음, 피드백과 함께 그들에게 알려주세요.
  참조: https://www.a-clickable-link-to-more-info.com
  디택션:
    - KeyPath: hostName
      조건: 포함
      값: prod
  ```

이 룰이 Panther에 업로드된 후에는 Console에서 다음 항목에 표시됩니다 [간단한 디택션 빌더](/ko/detections/rules/simple-detection-builder.md).

</details>

## 간단한 디택션 YAML 구문

각 사용자 지정 Simple 디택션은 다음으로 구성될 수 있습니다:

* 디택션 키

  ```yaml
  디택션: 
  ```
* 필터 키

  ```yaml
  InlineFilters: 
  ```
* 메타데이터 키

  ```yaml
  AnalysisType: 
  Enabled: 
  CreateAlert: 
  RuleID:
  CreatedBy:
  로그 유형: 
  보고서: 
  태그: 
  Tests: 
  ```
* 알러트 키 (동적)

  ```yaml
  DynamicSeverities: 
  알러트Title: 
  알러트Context: 
  GroupBy: 
  ```
* 알러트 키 (정적)

  ```yaml
  Severity:
  Description:
  DedupPeriodMinutes:
  임계값: 
  표시 이름:
  출력 ID:
  참조:
  Runbook:
  요약 속성: 
  ```

필수 및 선택 사항을 포함하여 이러한 각 키에 대해 자세히 알아보려면, [아래의 Simple 디택션 룰 사양 참조](#simple-detection-rule-specification-reference).

### `디택션`

다음 `디택션` 키 내에 하나 이상 포함하세요 [일치 표현식](/ko/detections/rules/writing-simple-detections/match-expression.md).

### `인라인 필터`

사용 방법에 대해 자세히 알아보기 `인라인 필터` Simple 디택션에서 [인라인 필터로 디택션 수정하기](/ko/detections/rules/inline-filters.md#creating-filters-in-the-cli-workflow).

### Simple 디택션의 동적 알러트 키

알러트 필드는 해당 디택션에서 생성된 알러트에 적용되는 Simple 디택션 정의의 필드입니다.

알러트 필드는 정적일 수도 있고 동적일 수도 있습니다. 정적 알러트 필드의 경우 디택션 정의에서 값을 지정하며, 이 값은 들어오는 이벤트에 따라 변경되지 않습니다. 그러나 동적 알러트 필드는 이벤트의 정보를 사용하여 값을 결정할 수 있습니다.

사용 중이라면 [알러트 중복 제거](/ko/detections/rules.md#deduplication-of-alerts)로 설정되면 *첫 번째* 디택션과 일치하는 이벤트는 이러한 알러트 키에서 사용됩니다.

#### `DynamicSeverities`

다음을 사용하여 `DynamicSeverities` 이 디택션과 일치하는 경우 생성된 알러트의 심각도를 동적으로 설정합니다. 이 필드는 동적이며, 이벤트의 값을 사용하여 심각도를 결정할 수 있기 때문입니다.

다음 경우 `DynamicSeverities` 가 존재하면 해당 값이 다음의 값보다 우선합니다. `Severity` 키. `Severity` 는 여전히 필요하며, 다음에 포함된 항목 중 어느 것과도 일치하지 않으면 해당 값이 대체 값이 됩니다. [일치 표현식](/ko/detections/rules/writing-simple-detections/match-expression.md) 포함된 `DynamicSeverities`.

다음 `DynamicSeverities` 키 내에 하나 이상 포함하세요 `ChangeTo` 키이며, 각각에는 대응하는 `조건` 키가 있습니다. 의 값은 `ChangeTo` 다음 중 하나여야 합니다. [알러트 심각도](/ko/detections/rules.md#alert-severity). `ChangeTo` 블록은 위에서 아래로 순서대로 평가되며, 일치하는 항목이 발견되면 평가가 중지됩니다.

내부에서 `조건`, 하나 이상의 [일치 표현식](/ko/detections/rules/writing-simple-detections/match-expression.md). `조건` 목록에는 다음과 같은 제한 사항이 있습니다:

* 아니요 [리스트 컴프리헨션](/ko/detections/rules/writing-simple-detections/match-expression.md#list-comprehension-match-expressions), [multi-key](/ko/detections/rules/writing-simple-detections/match-expression.md#multi-key-match-expressions), 또는 [절대값](/ko/detections/rules/writing-simple-detections/match-expression.md#absolute-match-expressions) match 표현식을 사용할 수 있습니다.
* 아니요 [조합자](/ko/detections/rules/writing-simple-detections/match-expression.md#combinators) 사용할 수 있습니다.

예시:

```yaml
DynamicSeverities:
  - ChangeTo: CRITICAL
    조건:
      - Key: status
        조건: 같음
        값: severe
  - ChangeTo: MEDIUM
    조건:
      - KeyPath: user.name
        조건: 다음으로 시작
        값: admin_
      - DeepKey:
          - user
          - roles
        조건: 포함
        값: wheel
```

#### `알러트Title`

다음을 사용하여 `알러트Title` 이 디택션에 대한 match로 생성된 알러트의 제목을 동적으로 설정하는 데 사용됩니다. 이 필드는 이벤트의 값을 제목에 사용할 수 있으므로 동적입니다.

다음의 값은 `알러트Title` 문자열이어야 합니다. 중괄호를 사용하여 이벤트 값을 참조할 수 있습니다. 중괄호 안에서는 JSON path 구문을 사용하세요.

예시:

```yaml
알러트Title: "{actor.username} 사용자가 {time}에 {target.username}을 가장했습니다"
```

#### `알러트Context`

`알러트Context` 를 사용하면 사전(dictionary) 형식으로 생성된 알러트에 전달할 이벤트 데이터를 지정할 수 있습니다.

내부에서 `알러트Context`, 하나 이상의 `KeyName` Run Panther AI `KeyValue` 쌍. `KeyName` 알러트 컨텍스트 사전의 키가 될 원하는 문자열을 받습니다. 내부에서 `KeyValue`다음과 같이 [키 지정자](/ko/detections/rules/writing-simple-detections/match-expression.md#key-specifiers) 를 사용하여 이벤트 키를 나타내면, 해당 값이 알러트 컨텍스트 사전의 값이 됩니다.

`KeyValue` 값은 JSON 규격을 준수해야 합니다. 규격에 맞지 않는 값의 예로는 Python의 `nan`, `inf`및 `-inf`.

예시:

```yaml
알러트Context:
  - KeyName: ip
    KeyValue:
      Key: sourceIP
  - KeyName: user
    KeyValue:
      DeepKey:
        - user
        - username
  - KeyName: resource
    KeyValue:
      KeyPath: resource.arns
```

#### `GroupBy`

`GroupBy` 은 디택션의 중복 제거 문자열을 설정합니다. 중복 제거 문자열이 설정되는 우선순위 순서를 포함한 중복 제거에 대해 자세히 알아보려면 [규칙 및 예약 규칙](/ko/detections/rules.md#deduplication-of-alerts).

다음 `GroupBy` 키에는 다음으로 정의된 하나 이상의 이벤트 키 목록을 포함하세요 [키 지정자](/ko/detections/rules/writing-simple-detections/match-expression.md#key-specifiers).

예시:

```yaml
GroupBy:
  - 키: sourceIP
  - KeyPath: user.name
  - KeyPath: resource.arn
```

아래에 제공된 키의 값은 `GroupBy` 중복 제거 문자열을 형성하기 위해 콜론으로 결합됩니다. 위 예제의 출력된 중복 제거 문자열은 다음과 같습니다:

```
<sourceIP의 값>:<user.name의 값>:<resource.arn의 값>
```

## Simple 디택션 룰 사양 참조

아래 표에는 Simple 디택션에 사용할 수 있는 모든 YAML 키가 포함되어 있습니다. 필수 필드는 **굵게**.

Python 룰을 작성 중이라면 대신 다음을 참조하세요 [Python 룰 사양 참조](/ko/detections/rules/python.md#python-rule-specification-reference).

<table data-header-hidden data-full-width="false"><thead><tr><th width="231">필드 이름</th><th width="264">설명</th><th width="282.5081967213115">예상 값</th></tr></thead><tbody><tr><td>필드 이름</td><td>설명</td><td>예상 값</td></tr><tr><td><strong><code>AnalysisType</code></strong></td><td>이 분석이 룰, scheduled_룰, policy 또는 global인지 나타냅니다</td><td><code>룰</code></td></tr><tr><td><strong><code>활성화됨</code></strong></td><td>이 룰이 활성화되어 있는지 여부</td><td>불리언</td></tr><tr><td><strong><code>RuleID</code></strong></td><td>룰의 고유 식별자</td><td>문자열</td></tr><tr><td><strong><code>LogTypes</code></strong></td><td>이 룰을 적용할 로그 목록</td><td>문자열 목록</td></tr><tr><td><code>CreatedBy</code></td><td>이 디택션의 작성자입니다. Panther 사용자 UUID, 이메일 주소 또는 임의의 텍스트 값으로 설정할 수 있습니다. 자세한 내용은 다음을 참조하세요 <a href="/pages/5f0ed921cfc97d649f3af6d2a4a6b7d06f7759cc#the-createdby-detection-field">the <code>CreatedBy</code> 디택션 필드</a>.</td><td>문자열</td></tr><tr><td><strong><code>Severity</code></strong></td><td>어떤 <a href="/pages/03a99462193d3cb6f09cb46a6d9fa32a7a6035d0#alert-severity">심각도</a> 연관된 알러트가 가져야 하는지</td><td>다음 문자열 중 하나: <code>정보</code>, <code>낮음</code>, <code>보통</code>, <code>높음</code>, 또는 <code>치명적</code><br>이 필드는 다음에 의해 덮어써집니다 <code>DynamicSeverities</code>하지만 <code>DynamicSeverities</code> 정의된 경우에도 필수입니다</td></tr><tr><td><code>CreateAlert</code></td><td>룰이 다음을 생성해야 하는지 여부 <a href="/pages/28a2f0a91092222209c65334fa10beb60037d689#signals-vs.-rule-matches-vs.-alerts">룰 일치/알러트</a> 일치 시 (기본값 true)</td><td>불리언</td></tr><tr><td><strong><code>디택션</code></strong></td><td>이벤트 데이터에 적용할 일치 표현식 목록</td><td>목록 <a href="/pages/210c60623b14405c0f4aa0870a4229c56a600413">일치 표현식</a></td></tr><tr><td><a href="#dynamicseverities"><code>DynamicSeverities</code></a></td><td>대체 <a href="/pages/03a99462193d3cb6f09cb46a6d9fa32a7a6035d0#alert-severity">심각도들</a> 사용자 지정 조건 집합에 기반한</td><td>다음으로 구성된 동적 심각도 구성 목록 <code>ChangeTo</code> Run Panther AI <code>조건</code> 필드들입니다. <code>ChangeTo</code> 은(는) <code>Severity</code> 값이며 <code>조건</code> 의 목록입니다 <a href="/pages/210c60623b14405c0f4aa0870a4229c56a600413">일치 표현식</a>.</td></tr><tr><td><code>설명</code></td><td>룰에 대한 간단한 설명</td><td>문자열</td></tr><tr><td><a href="#groupby"><code>GroupBy</code></a></td><td>알러트를 중복 제거할 기준이 되는 이벤트 값 집합</td><td>이벤트 키 목록</td></tr><tr><td><code>DedupPeriodMinutes</code></td><td>알러트의 유사한 이벤트가 함께 그룹화되는 기간(분)</td><td><code>15</code>,<code>30</code>,<code>60</code>,<code>180</code> (3시간),<code>720</code> (12시간), 또는 <code>1440</code> (24시간)</td></tr><tr><td><code>DisplayName</code></td><td>Panther Console과 알러트에 표시할 사용자 친화적인 이름입니다. 이 <code>RuleID</code> 가 설정되지 않으면 표시됩니다.</td><td>문자열</td></tr><tr><td><code>OutputIds</code></td><td>정적 대상 재정의입니다. 이는 이 룰의 알러트가 어떻게 라우팅될지 결정하는 데 사용되며, 심각도에 따른 기본 라우팅보다 우선합니다.</td><td>문자열 목록</td></tr><tr><td><code>Reference</code></td><td>이 룰이 존재하는 이유로, 보통 문서에 대한 링크입니다</td><td>문자열</td></tr><tr><td><code>Reports</code></td><td>이 룰이 해당 프레임워크에서 어떤 값을 다루는지에 대한 프레임워크 또는 보고서 이름과 값의 매핑</td><td>문자열에서 문자열 목록으로의 맵</td></tr><tr><td><code>Runbook</code></td><td>이 룰이 알러트를 반환할 경우 수행할 작업입니다. 설명적인 런북을 제공하는 것이 권장됩니다. 왜냐하면 <a href="/pages/6e9f85a6a2f1c7f2fb9c3093e77d535eff45c9f4#panther-ai-alert-triage">Panther AI 알러트 분류</a> 이를 고려할 것이기 때문입니다.</td><td>문자열</td></tr><tr><td><code>SummaryAttributes</code></td><td>알러트가 요약해야 하는 필드 목록입니다.</td><td>문자열 목록</td></tr><tr><td><code>Threshold</code></td><td>알러트가 전송되기 전에 이 룰을 트리거해야 하는 이벤트 수입니다.</td><td>정수</td></tr><tr><td><code>Tags</code></td><td>이 룰을 분류하는 데 사용되는 태그</td><td>문자열 목록</td></tr><tr><td><code>Tests</code></td><td>이 룰에 대한 단위 테스트</td><td>맵 목록</td></tr><tr><td><code>인라인 필터</code></td><td>형식의 필터 목록 <a href="/pages/210c60623b14405c0f4aa0870a4229c56a600413">일치 표현식</a> 데이터를 필터링하는 데 사용</td><td>목록 <a href="/pages/210c60623b14405c0f4aa0870a4229c56a600413">일치 표현식</a> (필터 호환 버전으로 제한됨)</td></tr><tr><td><a href="#alerttitle"><code>알러트Title</code></a></td><td>대체 <code>DisplayName</code> 알러트를 위한 동적 제목을 만들기 위해 이벤트 값을 사용할 수 있는</td><td>문자열</td></tr><tr><td><a href="#alertcontext"><code>알러트Context</code></a></td><td>커스텀 키 아래 Event에 추가하여 동적 알러트 컨텍스트를 만드는 이벤트 값</td><td>키 이름과 키 값 쌍 목록</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.panther.com/ko/detections/rules/writing-simple-detections.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
