# 비공개 클론

Panther에서 관리하는 Python 디텍션을 귀하의 워크플로 내에서 활용하기 위해 사용할 수 있는 한 가지 방법은 [CI/CD 워크플로](https://docs.panther.com/ko/panther/detections-repo/ci-cd) 의 비공개 복제 저장소를 생성하는 것입니다 [panther-analysis](https://github.com/panther-labs/panther-analysis).

조직에서 디텍션 집합 및 기타 관련 Panther 설정을 비공개로 유지하려는 경우, [panther-analysis](https://github.com/panther-labs/panther-analysis) 의 비공개 복제 저장소가 최선의 선택입니다. 이 모델에서는 로컬 저장소 설정이 내부 콘텐츠에 대한 접근 권한을 제어합니다.

아래 설명된 대로 비공개 복제 저장소를 구성한 후에는 브랜치를 생성하고 풀 리퀘스트를 활용하여 디텍션 집합에 대한 맞춤화를 반영할 수 있습니다.

리포지토리의 공개 포크 생성에 대한 정보는 [Public Fork](https://docs.panther.com/ko/panther/detections-repo/setup/deprecated/public-fork).

{% 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). 저장소 가시성을 설정할 때 **Private**.
   * 기본 설정을 유지하세요 - 저장소를 어떤 콘텐츠로도 초기화하지 마세요.
2. Clone [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. 비공개 저장소 내에서 이동하세요 **Settings** > **Actions** > **General**.
   2. 다음 선택 항목을 **Workflow permissions** 섹션에서 선택하세요:
      * Toggle **Read and write permissions** 을(를) 켜세요.
      * 체크하세요 **Allow GitHub Actions to create and approve pull requests**.
   3. 클릭하세요 **Save**.
4. 로컬에서 비공개 저장소를 클론하고 새 브랜치를 만든 다음 기존 **rules/** 디렉터리 내에 로컬 디텍션 콘텐츠용 디렉터리를 생성하세요:
   1. `git checkout -b feat/my_first_branch`
   2. `mkdir rules/my_local_rules`
5. 샘플 룰을 추가하세요:
   1. 다음 아래의 **templates/**&#xC5D0;서 **example\_rule.py** 및 **example\_rule.yml.**
   2. 이 파일들을 복사하여 **rules/my\_local\_rules/**.
      1. `cp templates/example_rule.* rules/my_local_rules`
6. 다음 명령을 실행하세요 `make venv` 그런 다음 실행하세요 `make test` 로컬 Python 환경을 설정하고 테스트 스위트를 실행합니다.
   * 파일에 변경을 하지 않았다면 다음과 유사한 오류가 표시되어야 합니다: `Key 'LogTypes' error: LOG_TYPE_REGEX does not match 'LogType.Name'`
7. 이전 단계 이후에 나타난 오류를 해결하세요:
   1. 다음을 변경하세요 `LogType` 을(를) Panther에서 알려진 로그 소스(예: **AWS.CloudTrail** )로 **example\_rule.yml**
   2. 다음을 변경하세요 `파일 이름` 내의 **example\_rule.yml** 으로 **example\_rule.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 - Read`
   * `Contents - Read and write`
   * `Metadata - Read`
   * `Pull Requests - Read and write`
   * `Workflows - Read and write`
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.**
   * 액션이 완료되면 워크플로 실행 옆에 녹색 원이 표시됩니다. 변경 사항이 있으면 GitHub Actions가 작성한 새 오픈 풀 리퀘스트가 표시됩니다. 변경 사항이 없으면 “Local repo already synced to latest release.”와 유사한 메시지가 표시됩니다.
   * 해당 **Sync Panther Analysis from Upstream** Action은 매주 화요일 15:00Z에 크론 스케줄로 실행되도록 구성되어 있습니다. 이 스케줄은 `.github/workflows/sync-from-upstream.yml`.
5. 의 6행에서 수정할 수 있습니다.

풀 리퀘스트를 일반 풀 리퀘스트처럼 기본 브랜치에 병합하세요.

저장소는 병합을 최신 변경으로 반영하며, 비공개 저장소와 panther-analysis의 git 히스토리를 모두 볼 수 있습니다. [병합 충돌 문제가 발생하거나 "all jobs have failed"라는 오류가 표시되면 다음 문제 해결 문서를 참조하세요:](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)

## GitHub Action sync-panther-analysis-from-upstream을 사용할 때 병합 충돌과 실패한 동기화를 어떻게 해결합니까?

다음 단계 [저장소를 클론한 후에는 Panther 디텍션을 CI/CD 워크플로에 통합할 수 있습니다—문서는](https://docs.panther.com/ko/panther/detections-repo/ci-cd/deployment-workflows/circle-ci) 및 [CircleCI](https://docs.panther.com/ko/panther/detections-repo/ci-cd/deployment-workflows/github-actions).

### CircleCI

GitHub Actions

자체 GitHub Action을 만들어 디텍션 콘텐츠를 Panther 인스턴스로 업로드할 수 있으며, 저장소에 병합된 각 풀 리퀘스트마다 자동으로 실행되도록 구성할 수 있습니다. [자세한 내용은](https://docs.panther.com/ko/panther/detections-repo/ci-cd/deployment-workflows/github-actions) Managing Content via GitHub Actions

### 고객 기여 콘텐츠

귀하는 panther-analysis에 콘텐츠를 업스트림으로 기여하는 것이 권장되지만,\
업스트림으로 풀 리퀘스트를 보내려면 공개 저장소에서만 가능합니다. 비공개 저장소를 사용 중이며 콘텐츠를 기여하고 싶다면 Panther 지원팀에 연락하세요.
