# Private Clone

Panther에서 관리하는 Python 디택션을 귀하의 [CI/CD 워크플로 내에서](/ko/panther/detections-repo/ci-cd.md) 활용하는 데 사용할 수 있는 한 가지 방법은 의 프라이빗 클론 리포지토리를 만드는 것입니다. [panther-analysis](https://github.com/panther-labs/panther-analysis).

귀하의 조직이 디택션 본문과 기타 관련 Panther 구성을 비공개로 유지하려는 경우, 의 프라이빗 클론 리포지토리가 [panther-analysis](https://github.com/panther-labs/panther-analysis) 최선의 옵션입니다. 이 모델에서는 로컬 리포지토리 설정이 내부 콘텐츠에 대한 액세스 권한을 제어합니다.

아래에 설명된 대로 프라이빗 클론 리포지토리를 구성한 후에는 브랜치를 만들고 pull request를 활용하여 디택션 본문에 사용자 지정을 반영할 수 있습니다.

리포지토리의 퍼블릭 포크를 만드는 방법에 대한 정보는 다음을 참조하세요. [퍼블릭 포크](/ko/panther/detections-repo/setup/deprecated/public-fork.md).

{% hint style="info" %}
panther-analysis에 새 [태그된 릴리스](https://github.com/panther-labs/panther-analysis/releases)가 있을 때 업스트림 변경 사항을 가져오는 것이 권장됩니다. 또한 [main 브랜치](https://github.com/panther-labs/panther-analysis/tree/main)에서 가져올 수도 있습니다. 다른 브랜치는 안정적이라고 간주해서는 안 됩니다.
{% endhint %}

## panther-analysis 리포지토리의 프라이빗 클론 구성

다음은 현재 지원되는 기능을 기준으로 권장하는 구성입니다.

1. GitHub에서 프라이빗 리포지토리를 생성합니다.
   * 지침은 다음을 참조하세요. [GitHub 문서: 리포지토리 생성](https://docs.github.com/en/get-started/quickstart/create-a-repo)리포지토리의 공개 범위를 설정할 때 **프라이빗**.
   * 을 선택합니다. 기본 설정을 유지하세요. 어떠한 콘텐츠로도 리포지토리를 초기화하지 마세요.
2. 클론하고 [panther-analysis](https://github.com/panther-labs/panther-analysis) 다음을 사용하여 `git push --mirror` 업스트림의 git 콘텐츠와 기록으로 프라이빗 클론 리포지토리를 시드하세요.
   1. `gh repo clone panther-labs/panther-analysis`
   2. `cd panther-analysis`
   3. `git checkout main`
   4. `git push --mirror https://github.com/your_org/your_private_repo.git`\
      리포지토리의 미러를 유지 관리하는 방법에 대한 자세한 내용은 다음을 참조하세요. [GitHub 문서: 리포지토리 복제](https://docs.github.com/en/repositories/creating-and-managing-repositories/duplicating-a-repository).
3. GitHub에서 리포지토리에 대해 올바른 워크플로 권한을 활성화하세요.
   1. 프라이빗 리포지토리 내에서 다음으로 이동하세요. **설정** > **Actions** > **General**.
   2. 다음에서 아래 선택을 수행하세요. **워크플로 권한** 섹션에:
      * 토글 **읽기 및 쓰기 권한** 을 켭니다.
      * 다음을 체크하세요. **GitHub Actions가 pull request를 생성하고 승인하도록 허용**.
   3. 다음을 클릭하세요. **저장**.
4. 로컬에서 프라이빗 리포지토리를 클론하고, 새 브랜치를 만든 다음, 기존 **룰/** 디렉터리 내에 로컬 디택션 콘텐츠용 디렉터리를 생성하세요:
   1. `git checkout -b feat/my_first_branch`
   2. `mkdir rules/my_local_rules`
5. 샘플 룰 추가:
   1. 다음에서 **templates/**&#xC5D0;서 다음을 찾으세요. **example\_룰.py** 및 **example\_룰.yml**
   2. 다음에 복사하세요 **rules/my\_local\_rules/**.
      1. `cp templates/example_룰.* rules/my_local_rules`
6. 실행 `make venv` 그다음 실행하세요 `make test` 로컬 Python 환경을 설정하고 테스트 스위트를 실행합니다.
   * 파일에 변경 사항이 없었다면, 다음과 비슷한 오류가 표시되어야 합니다: `키 'LogTypes' 오류: LOG_TYPE_REGEX가 'LogType.Name'과 일치하지 않습니다`
7. 이전 단계 이후에 나타난 오류를 해결하세요:
   1. 변경하세요 `LogType` 를 Panther에서 알려진 로그 소스로, 예를 들어 **AWS.CloudTrail** 의 **example\_룰.yml**
   2. 변경하세요 `파일 이름` 내부의 **example\_룰.yml** 를 **example\_룰.py**.
8. 현재 브랜치에서 원격 저장소로 변경 사항을 커밋하세요. (`git rev-parse –abbrev-ref HEAD` 가 현재 브랜치를 제공합니다. 이 값을 직접 제공해도 됩니다.)
   1. `git add rules/my_local_rules`
   2. `git commit -m "feat: new example rules"`
   3. `git push origin` \``` git rev-parse --abbrev-ref HEAD` ``
      * 이 명령은 출력에 링크를 제공합니다.
9. 이전 단계의 출력에서 나온 링크를 사용해 `git push` 를 사용하여 브랜치의 풀 리퀘스트를 생성하세요.
10. 풀 리퀘스트를 병합하고 필요하면 브랜치를 삭제하세요.

## 업스트림 panther-analysis 업데이트와 개인 클론을 동기화 상태로 유지하기

업스트림 변경 사항과 동기화를 유지하려면 다음을 사용하는 것이 좋습니다. [Sync Panther Analysis from Upstream](https://github.com/panther-labs/panther-analysis/blob/main/.github/workflows/sync-from-upstream.yml) GitHub Action은 panther-analysis의 최신 변경 사항으로 저장소의 기본 브랜치에 대해 주기적으로 풀 리퀘스트를 엽니다.

이 Action을 구성하려면:

1. 다음 권한을 가진 GitHub 토큰을 생성하세요:
   * `Administration - 읽기`
   * `Contents - 읽기 및 쓰기`
   * `Metadata - 읽기`
   * `Pull Requests - 읽기 및 쓰기`
   * `Workflows - 읽기 및 쓰기`
2. 포크한 저장소에서 다음 이름의 새 시크릿을 추가하세요 `PANTHER_SYNC_UPSTREAM` 그리고 그 값으로 이전 단계에서 생성한 토큰을 설정하세요.

{% hint style="warning" %}
이 단계를 건너뛰면, 업스트림 저장소에 다음 위치 내 변경 사항이 있을 때마다 `.github/workflows` 디렉터리에서 Action이 PR 열기에 실패합니다.
{% endhint %}

3. Action을 처음 실행하고 포크를 업스트림 저장소와 동기화하려면, GitHub의 저장소에서 **Actions** > **Sync Panther Analysis from Upstream**.
4. 다음을 클릭하세요. **Run Workflow > Run workflow.**
   * Action이 완료되면 워크플로 실행 옆에 초록색 원이 표시됩니다. 변경 사항이 있으면 GitHub Actions가 작성한 새로 열린 풀 리퀘스트가 표시됩니다. 변경 사항이 없으면 “Local repo already synced to latest release.”와 비슷한 메시지가 표시됩니다.
   * 다음 **Sync Panther Analysis from Upstream** 이 Action은 매주 화요일 15:00Z에 크론 일정으로 실행되도록 구성되어 있습니다. 이 일정을 다음의 6번째 줄에서 수정할 수 있습니다. `.github/workflows/sync-from-upstream.yml`.
5. 일반적인 pull request와 마찬가지로 pull request를 기본 브랜치에 병합하세요.

저장소에는 병합이 최신 변경 사항으로 반영되며, 비공개 저장소와 panther-analysis의 git 기록을 모두 볼 수 있습니다.

병합 충돌 문제가 발생하거나 "all jobs have failed"라는 오류가 표시되면 다음 문제 해결 문서를 참고하세요: [GitHub Action sync-panther-analysis-from-upstream을 사용할 때 병합 충돌과 동기화 실패를 어떻게 해결하나요?](https://help.panther.com/Panther_Developer_Workflows/panther-analysis/How_do_I_resolve_merge_conflicts_and_failed_syncs_when_using_the_GitHub_Action_sync-panther-analysis-from-upstream%3F)

## 다음 단계

저장소를 클론한 후에는 CI/CD 워크플로에 Panther 디택션을 통합할 수 있습니다. 자세한 내용은 다음 문서를 참고하세요. [CircleCI](/ko/panther/detections-repo/ci-cd/deployment-workflows/circle-ci.md) 및 [GitHub Actions](/ko/panther/detections-repo/ci-cd/deployment-workflows/github-actions.md).

### GitHub Actions

자신만의 GitHub Action을 만들어 디택션 콘텐츠를 Panther 인스턴스에 업로드할 수 있으며, 저장소로 병합된 각 pull request마다 자동으로 실행되도록 구성할 수 있습니다.

다음을 참조하세요 [GitHub Actions를 통한 콘텐츠 관리](/ko/panther/detections-repo/ci-cd/deployment-workflows/github-actions.md) 자세한 내용은 다음을 참조하세요.

### 고객 기여 콘텐츠

콘텐츠를 panther-analysis에 upstream으로 다시 기여하는 것을 권장하지만,\
upstream으로 pull request를 보내는 것은 공개 저장소에서만 가능합니다. 비공개 저장소를 사용 중이며 콘텐츠를 기여하고 싶다면 Panther 지원팀에 문의해 주세요.


---

# 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/panther/detections-repo/setup/deprecated/private-cloned-repo.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.
