# 파생 디택션

## 개요

Panther에서는 단일 Base 디택션에서 하나 이상의 Derived 디택션을 생성할 수 있습니다. Derived 디택션은 변경할 수 없는 Base 디택션의 핵심 로직과, 덮어쓸 수 있는 메타데이터 및 알러트 필드 값을 상속합니다.

디택션 파생은 다음으로 생성된 룰에 사용할 수 있습니다 [간단한 디택션](https://docs.panther.com/ko/detections/..#simple-detections) 또는 [Python 탐지](https://docs.panther.com/ko/detections/rules/python).

### Derived 디택션의 사용 사례

파생은 다음과 같은 경우 특히 유용할 수 있습니다:

* 서로 다른 메타데이터를 가진 동일한 룰의 여러 복사본을 유지하는 경우
* CLI 워크플로우에서 다음을 사용하고 사용자 지정합니다 [Panther에서 관리하는 룰](https://docs.panther.com/ko/detections/panther-managed), 그리고 Panther가 업데이트를 출시할 때 병합 충돌을 해결해야 하는 일을 피하고 싶은 경우
  * 전체 예시는 다음에서 확인하세요 [병합 충돌을 피하기 위해 Derived 디택션 사용](https://docs.panther.com/ko/detections/rules/derived/using-derived-detections-to-avoid-merge-conflicts)
* 사고 대응 중에 다음 결정을 내리는 데 도움이 되는 텔레메트리를 수집하기 위해 하나의 디택션의 여러 변형을 배포할 수 있는 기능을 원합니다
* 팀의 한 구성원(예: 위협 연구 책임자)은 다른 구성원(예: SOC 분석가)이 수정할 수 있는 Base 디택션 집합을 만들고 싶어 합니다

## Base 디택션 및 Derived 디택션

Base 디택션은 사용자 지정 또는 [Panther 관리형](https://docs.panther.com/ko/detections/panther-managed) 룰이며, 여기서 Derived 디택션이 생성되었습니다.

Derived 디택션은 Base 디택션에서 생성되며 다음을 수행합니다:

* Base 디택션의 핵심 디택션 로직을 상속합니다
  * 핵심 디택션 로직은 Base 디택션의 `룰()` 함수(Python 디택션의 경우) 또는 `디택션` 필드(Simple 디택션의 경우)에서 정의됩니다.
  * Derived 디택션은 자체 디택션 로직을 지정할 수 없습니다. 예를 들어 CLI 워크플로우에서 Derived 디택션에 `디택션` 키가 포함되어 있으면 해당 내용은 무시됩니다.
* Base 디택션의 메타데이터/알러트 필드 값을 상속하지만 일부 필드는 덮어쓸 수 있습니다
  * 다음을 참조하세요 [디택션 파생의 제한 사항](#limitations-of-detection-derivation) 오늘날 덮어쓸 수 있는 필드의 전체 목록은 다음에서 확인하세요.
  * Derived 디택션에서 수행한 재정의는 Base 디택션에서 상속한 필드 값을 완전히 대체합니다. 예를 들어 Base 디택션과 Derived 디택션이 모두 [인라인 필터](https://docs.panther.com/ko/detections/rules/inline-filters) 를 정의하는 경우( `InlineFilters` 키(CLI 워크플로우에서) 또는 **이벤트만 포함하도록 필터링** 필드(콘솔에서)를 사용하면 Derived 디택션의 인라인 필터만 적용됩니다.
  * 재정의는 한 방향으로만 수행할 수 있습니다. 즉, Derived 디택션에서 수행한 재정의는 Base 디택션 값에 영향을 주지 않습니다. 예를 들어 Base 디택션이 `Enabled: False` 이고 해당 Derived 디택션이 `Enabled: True`이면 Derived 디택션만 활성화됩니다.

### Base 디택션이 업데이트될 때 발생하는 일

Base 디택션의 핵심 로직이 업데이트되면 변경 사항은 관련된 모든 Derived 디택션에 전파됩니다.

Base 디택션의 메타데이터가 업데이트될 때, 관련 Derived 디택션이 이미 업데이트된 필드의 값(들)을 덮어쓴 경우에는 변경 사항이 없습니다. 관련 Derived 디택션이 업데이트된 필드의 값(들)을 덮어쓰지 않은 경우에는 메타데이터 업데이트가 Derived 디택션으로 전파됩니다.

### 중복 알러트를 방지하려면 Base 디택션을 비활성화하세요

대부분의 경우 Base 디택션과 Derived 디택션은 동일한 들어오는 로그 집합에서 실행됩니다(하지만 [인라인 필터](https://docs.panther.com/ko/detections/rules/inline-filters) 를 사용하여 서로 다른 이벤트를 대상으로 할 수는 있습니다). 이 시나리오에서는 디택션이 핵심 로직을 공유하므로 둘 다 활성화되어 있으면 중복 알러트를 생성합니다.

이를 방지하려면 Base 디택션을 비활성화하세요. 비활성화된 Base 디택션이 업데이트되면 해당 변경 사항은 계속해서 Derived 디택션으로 전파됩니다 [위에서 설명한 대로](#what-happens-when-a-base-detection-is-updated).

#### CLI 워크플로우에서 Base 디택션을 자동으로 비활성화하기

CLI 워크플로우에서는 Base 디택션을 자동으로 비활성화하는 두 가지 방법이 있습니다:

* **옵션 1(권장)**&#xB2E4;음 설정을 귀하의 `.panther_settings.yml` 파일에 추가하세요:

  ```yaml
  auto_disable_base: true
  # ... 기타 설정 ...
  ```
* **옵션 2**: 다음을 사용하세요. `--auto-disable-base` 과 [Panther Analysis Tool `upload` 명령](https://docs.panther.com/ko/panther/detections-repo/pat/pat-commands#upload-uploading-packages-to-panther-directly).
  * 이 옵션을 따를 때는 `--auto-disable-base` 이후의 모든 upload 호출에 사용해야 합니다. 이를 생략하면 Base 디택션이 다시 활성화됩니다.

{% hint style="warning" %}
Base 디택션 중 하나 이상이 이미 활성화된 상태로 Panther 인스턴스에 업로드되었고, 이후 위의 방법 중 하나를 사용하여 Base 디택션을 자동으로 비활성화하는 경우, `--filter enabled: true` 을/를 [PAT `upload` 명령](https://docs.panther.com/ko/panther/detections-repo/pat/pat-commands#upload-uploading-packages-to-panther-directly)에 포함하지 않도록 하세요. 그렇게 하면 Base 디택션은 `upload` 전에 비활성화됩니다(즉, `enabled: true` 필터가 적용될 때). 이는 새로 비활성화된 Base 디택션이 Panther 인스턴스에 다시 업로드되지 않음을 의미합니다(그대로 유지되거나 활성화된 상태로 남음).
{% endhint %}

## Derived 디택션을 만드는 방법

{% tabs %}
{% tab title="Panther Console" %}
**Panther Console에서 Derived 디택션 만들기**

1. Panther Console의 왼쪽 탐색 모음에서 **Detections**.
2. 새 Derived 디택션의 Base 디택션이 될 디택션을 찾아 이름을 클릭합니다.
3. 오른쪽 상단에서 다음을 클릭하세요. `...`.
4. 다음을 클릭하세요. **Derive**:\ <img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-76e78c4dfce2f10d543e063c220b754f6758b6f3%2FScreenshot%202023-11-09%20at%2012.04.44%20PM.png?alt=media" alt="In the Panther Console, the three dots menu on a detection&#x27;s page is open, and the Derive option is circled." data-size="original">
5. 다음 항목에서 **기본 정보** 페이지에서 선택적으로 **이름** 및 **ID** 필드를 Derived 디택션에 맞게 편집합니다.
   * 이름이 Base 디택션의 이름과 구별되도록 하세요.
6. 다음을 클릭하세요. **계속**.
7. 아래로 스크롤하여 **필터** 및 **알러트 필드 설정** 섹션으로 이동한 다음, 인라인 필터와 알러트 필드에 원하는 재정의를 설정합니다:\
   ![The edit detection page in the Panther Console is shown. A Filter section is visible, along with a Set Alert Fields section. Within the latter are sub-sections for Required Fields and Optional Fields.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-3a5d463bf5186c6ea31672fc18baa66c63f2e850%2FScreenshot%202023-11-14%20at%2012.24.35%20PM.png?alt=media)
8. 오른쪽 상단에서 다음을 클릭하세요. **배포**.
   * 해당 디택션에는 `DERIVED` 레이블이 표시됩니다:\ <img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-ff5df9a84be3cd8e9b66db69e181bd778f7a176f%2FScreenshot%202023-11-14%20at%2012.31.51%20PM.png?alt=media" alt="The word &#x22;DERIVED&#x22; is shown in teal." data-size="original">
     {% endtab %}

{% tab title="CLI 워크플로" %}
**CLI 워크플로에서 Derived 디택션 만들기**

1. 사용하는 디렉터리에서 [Panther Analysis Tool (PAT)](https://docs.panther.com/ko/panther/detections-repo/pat), Derived 디택션용 새 YAML 파일을 만듭니다.
2. 이 YAML 파일에 Derived 디택션에 필요한 다음 필드를 추가합니다:
   * `BaseDetection`: 현재 Panther 인스턴스에 존재하거나 PAT를 사용하여 업로드할 로컬 디렉터리에 있는 임의의 룰의 룰 ID를 입력합니다.
     * 다음 `BaseDetection` 키는 이 Derived 디택션과 Base 디택션을 연결하는 링크이며, 상속을 적용해야 함을 나타내는 요소입니다.
   * `RuleID`: 앞서 `BaseDetection` 키에 대해 제공한 ID와 다른 값을 입력합니다.
   * `AnalysisType`: 이것이 `룰`, `예약된_룰`, 또는 `정책`.
     * 현재는 룰만 지원됩니다.
3. 재정의하려는 메타데이터 필드와 해당 필드의 새 값을 추가하세요.
   * 다음을 참조하세요. [제한 사항](#limitations-of-detection-derivation) 사용 가능한 재정의 필드 목록은 섹션을 참조하세요.
   * 다음을 사용할 수 있습니다 [여기에 설명된 동적 알러트 필드](https://docs.panther.com/ko/detections/writing-simple-detections#dynamic-alert-keys-in-simple-detections).
4. 다음을 사용하여 디택션을 업로드하세요 [`panther_analysis_tool upload`](https://docs.panther.com/ko/panther/detections-repo/pat/pat-commands#upload-uploading-packages-to-panther-directly) 명령을 사용하세요.
   * 권장되는 방법은 [Base 디택션을 자동으로 비활성화](#automatically-disabling-base-detections-in-the-cli-workflow).

**CLI 워크플로 예시**

아래는 Python Base 디택션의 예입니다 ([panther-analysis 리포지토리의 표준 디택션](https://github.com/panther-labs/panther-analysis/blob/main/rules/auth0_rules/auth0_mfa_policy_enabled.yml)), 그리고 그 아래에는 해당 파생 디택션이 있습니다.

```yaml
# 기본 디택션
AnalysisType: 룰
Description: 조직의 테넌트에 대해 Auth0 사용자가 MFA 정책을 활성화했습니다.
DisplayName: "Auth0 MFA 정책 활성화됨"
Enabled: True
Filename: auth0_mfa_policy_enabled.py
Runbook: 이것이 사용자가 유효한 비즈니스 이유로 수행한 것이며 예상된 작업이었는지 평가하세요. 이 알러트는 보안 모범 사례에 부합하는 설정 변경을 나타내므로 후속 조치가 불필요할 수 있습니다.
Severity: 보통
DedupPeriodMinutes: 60
LogTypes:
    - Auth0.Events
RuleID: "Auth0.MFA.Policy.Enabled"
Threshold: 1
Tests:
    - ExpectedResult: True
      Log:
        data:
            client_id: 1HXWWGKk1Zj3JF8GvMrnCSirccDs4qvr
            client_name: ""
            date: "2023-05-16 17:26:16.782000000"
            description: 다중 인증 정책 설정
            details:
                request:
                    auth:
                        credentials:
                            jti: 0107c849078d8d889af711840197ba7c
                            scopes:
                                - create:actions
                                - create:actions_log_sessions
                                # 간결성을 위해 축약됨
                        strategy: jwt
                        user:
                            email: user.name@yourcompany.io
                            name: 사용자 이름
                            user_id: google-oauth2|105261262156475850461
                    body:
                        - 모든 애플리케이션
                    channel: https://manage.auth0.com/
                    ip: 12.12.12.12
                    method: put
                    path: /api/v2/guardian/policies
                    query: {}
                    userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
                response:
                    body:
                        - 모든 애플리케이션
                    statusCode: 200
            ip: 12.12.12.12
            log_id: "90020230515215719063964000000000000001223372037488829643"
            type: sapi
            user_agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
            user_id: google-oauth2|105261262156475850461
        log_id: "90020230515215719063964000000000000001223372037488829643"
        p_any_ip_addresses:
            - 12.12.12.12
        p_any_usernames:
            - google-oauth2|105261262156475850461
        p_event_time: "2023-05-16 17:26:16.782"
        p_log_type: Auth0.Events
        p_parse_time: "2023-05-16 17:28:28.572"
        p_row_id: 2660c447622fa4c3dbb08f9918979102
        p_schema_version: 0
        p_source_id: b9031579-b2c5-45c2-b15c-632b995a4e36
        p_source_label: 조직 Auth0 테넌트 레이블
      이름: MFA 정책이 먼저 활성화됨
```

```yaml
# 파생 디택션

# 필수 필드
AnalysisType: 룰
RuleID: "Auth0.MFA.Policy.Enabled.Custom.Severity"
BaseDetection: "Auth0.MFA.Policy.Enabled"

# 덮어쓰는 필드(즉, 기본 디택션에서 상속된 기본값을 재정의)
DisplayName: "Auth0 MFA 정책 활성화 - 심각도 치명적"
Enabled: True
Severity: 치명적
Description: Auth0 사용자가 귀 조직의 테넌트에 대해 MFA 정책을 활성화했으며 - 심각도가 치명적으로 재정의되었습니다.
```

{% endtab %}
{% endtabs %}

## 모든 파생 디택션을 보는 방법

Panther 인스턴스에서 모든 파생 디택션을 보려면:

1. Panther Console의 왼쪽 탐색 모음에서 다음을 클릭하세요. **Detections**.
2. 다음을 클릭하세요. **필터** 아이콘.\
   ![](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-32af1a963a2a7704ebb1c8b50559712de6f99dfc%2Fimage.png?alt=media)
3. 다음에서 **디택션 유형** 드롭다운 필드에서 다음을 선택합니다 **파생 룰**.
4. 다음을 클릭하세요. **필터 적용**.

## 디택션 파생의 제한 사항

* 다음에는 파생이 사용할 수 없습니다 [예약된 룰](https://docs.panther.com/ko/detections/rules) 또는 [정책](https://docs.panther.com/ko/detections/policies).
* 파생은 한 단계만 가능하며, 즉 파생 디택션은 *에서 파생될 수 없습니다.*
* Console 워크플로에서는 파생 디택션이 생성될 때 테스트가 상속되지만, 그 이후 기본 디택션의 테스트가 업데이트될 때는 상속되지 않습니다.
* Python 기본 디택션에서 메타데이터 필드의 값이 Python 함수를 사용해 설정된 경우, 그 값은 파생 디택션에 제공된 동등한 정적 재정의 값보다 우선합니다. 예를 들어, Python [`severity()`](https://docs.panther.com/ko/detections/python#severity) 함수가 기본 디택션에 있으면, 그 값은 파생 디택션의 `심각도` YAML 키(CLI 워크플로에서) 또는 **심각도** 필드(Console에서)에 제공된 재정의 값보다 우선합니다.
  * 메타데이터 값을 설정하는 Python 함수("알러트 함수"라고 함)의 전체 목록과, YAML/Console에서 해당 함수가 재정의하는 필드를 [Python 디택션의 알러트 함수](https://docs.panther.com/ko/detections/python#alert-functions-in-python-detections) 표에서 확인하세요.
  * 그것 *은* 특정 Python 알러트 함수에서 설정한 값을 덮어쓰는 것이 가능합니다. 이를 사용하여 [동적 알러트 키](https://docs.panther.com/ko/detections/writing-simple-detections#dynamic-alert-keys-in-simple-detections) 를 파생 디택션에서 사용할 수 있습니다. 예를 들어, Python Base Detection의 [`severity()`](https://docs.panther.com/ko/detections/python#severity) 함수 값을 파생 디택션에서 [`DynamicSeverities`](https://docs.panther.com/ko/detections/writing-simple-detections#dynamicseverities) 필드.
    * [`DynamicSeverities`](https://docs.panther.com/ko/detections/writing-simple-detections#dynamicseverities) 를 사용하여 재정의할 수 있습니다. [`severity()`](https://docs.panther.com/ko/detections/python#severity)
    * [`알러트Title`](https://docs.panther.com/ko/detections/writing-simple-detections#alerttitle) 를 사용하여 재정의할 수 있습니다. [`title()`](https://docs.panther.com/ko/detections/python#title)
    * [`알러트Context`](https://docs.panther.com/ko/detections/writing-simple-detections#alertcontext) 를 사용하여 재정의할 수 있습니다. [`알러트_context()`](https://docs.panther.com/ko/detections/python#alert_context)
    * [`GroupBy`](https://docs.panther.com/ko/detections/writing-simple-detections#groupby) 를 사용하여 재정의할 수 있습니다. [`dedup()`](https://docs.panther.com/ko/detections/python#dedup)
* Console 워크플로에서 파생 디택션을 생성하고 기본 디택션이 Python 디택션인 경우, 알러트 필드를 동적으로 설정할 수 없습니다—이들은 정적으로만 설정할 수 있습니다.
  * 그것 *은* 기본 디택션이 Simple 디택션인 경우, Console 워크플로에서 알러트 필드를 동적으로 설정할 수 있습니다.
  * 그것 *은* CLI 워크플로(사용)에서 알러트 필드를 동적으로 설정할 수 있습니다 [`알러트Title`](https://docs.panther.com/ko/detections/writing-simple-detections#alerttitle), [`DynamicSeverities`](https://docs.panther.com/ko/detections/writing-simple-detections#groupby), [`알러트Context`](https://docs.panther.com/ko/detections/writing-simple-detections#alertcontext), 그리고 [`GroupBy`](https://docs.panther.com/ko/detections/writing-simple-detections#groupby)—기본 디택션이 Python 디택션이든 YAML 디택션이든 상관없이.
* 현재는 아래 필드만 덮어쓸 수 있습니다. 이들은 YAML 필드 이름이며 CLI 워크플로에 적용됩니다. Console에 대응하는 필드가 있는 경우, 해당 Console 필드도 덮어쓸 수 있습니다.
  * `Enabled`
  * `심각도`
  * `설명`
  * `CreateAlert`
  * `DedupPeriodMinutes`
  * `InlineFilters`
  * `DisplayName`
  * `기본 위험 점수만 사용`
  * `출력 ID`
  * `참고`
  * `Runbook`
  * `요약 속성`
  * `임계값`
  * `Tags`
  * `보고서`
  * `DynamicSeverities`
  * `알러트Title`
  * `알러트Context`
  * `GroupBy`
  * `Tests`
