# CircleCI를 통한 Panther 콘텐츠 관리

## 개요

CircleCI를 구성하여 테스트를 자동화하고 소스 저장소에서 Panther Console로 디택션 파이프라인을 업로드할 수 있습니다.

이 가이드는 다음 방법을 설명합니다:

* CircleCI를 지원하도록 저장소를 구성합니다.
* 저장소에 커밋한 디택션 콘텐츠를 Panther 인스턴스로 자동 업로드하도록 CircleCI를 구성합니다.

참조하세요 [Panther 콘텐츠용 CI/CD](/ko/panther/detections-repo/ci-cd.md) 에서 Panther로 CI/CD 워크플로를 시작하는 방법에 대한 정보를 확인하세요.

## CircleCI 설정

CircleCI를 사용하여 디택션 콘텐츠를 Panther 인스턴스로 업로드하려면, 먼저 저장소에 CircleCI 작업을 만들고 Panther API 자격 증명에 대한 환경 변수를 구성해야 합니다.

### 사전 요구 사항

* Panther Console에서 API 토큰을 생성합니다.
  * 참조하세요 [API 토큰 생성 방법에 대한 이 지침](/ko/panther/api.md#how-to-create-a-panther-api-token).
* 이미 CircleCI 계정이 없다면, [무료 계정을 생성하세요](https://circleci.com/signup).

### 1단계: 디택션 저장소 설정

* Panther 디택션 콘텐츠용으로 설정된 저장소가 아직 없다면, 하나 만드세요. 다음 중 하나를 수행하는 것이 권장됩니다. [비공개로 복제하거나](/ko/panther/detections-repo/setup/deprecated/private-cloned-repo.md) 또는 [공개적으로 포크하거나](/ko/panther/detections-repo/setup/deprecated/public-fork.md) Panther의 [panther-analysis 저장소를](https://github.com/panther-labs/panther-analysis).

### 2단계: 저장소에 CircleCI 작업 추가

CircleCI가 저장소의 `main` 브랜치에 커밋한 `panther-analysis` 저장소의 디택션 콘텐츠를 테스트하고 업로드하려면 CircleCI 작업을 만들어야 합니다.

1. 명령줄에서 개인 로컬 저장소의 루트로 이동합니다:\
   `cd path/to/your/repository`
2. CircleCI 구성을 위한 새 디렉터리와 새 구성 파일을 만듭니다:

   `mkdir .circleci && touch .circleci/config.yml`
3. 다음을 열고 `config.yml` 다음을 붙여넣습니다:

   ```yaml
   version: 2.1
   jobs:
     upload:
       docker:
         - image: 'cimg/python:3.11'
       steps:
         - checkout
         - run:
             name: 가상 환경 설정 및 종속성 설치
             command: make venv
         - run:
             name: 단위 테스트 실행
             command: pipenv run panther_analysis_tool test
         - run:
             name: 디택션 콘텐츠 업로드
             # (선택 사항) 아래 명령에 `--filter Enabled=true`를 추가하면 활성화된 디택션만 업로드합니다
             command:  |
               PANTHER_API_HOST=$INTERNAL_API_HOST \
               PANTHER_API_TOKEN=$INTERNAL_API_TOKEN \
               pipenv run -- panther_analysis_tool upload
   workflows:
     panther:
       jobs:
         - upload:
             filters:
               branches:
                 only:
                   - main
   ```
4. 변경 사항을 추가, 커밋 및 저장소에 푸시합니다:

   `git add . && git commit -m 'adding initial circleci configuration' && git push`

### 3단계: Panther API 자격 증명을 환경 변수로 추가

환경 변수 `PANTHER_API_TOKEN` 및 `PANTHER_API_HOST` 가 올바른 인증을 위해 설정되어 있는지 확인합니다.

1. 다음에 로그인합니다 [CircleCI](https://circleci.com/vcs-authorize/) 그리고 프로젝트가 속한 조직을 선택합니다.
2. 왼쪽 탐색 메뉴에서 **Projects**.
3. 를 클릭합니다. 프로젝트 목록에서 `panther-analysis` 저장소를 찾습니다. 프로젝트 오른쪽에서 **...** 을 클릭한 다음 **Project Settings**.

   <figure><img src="/files/7afac01ee271dcb0cff53b06603638819758cc19" alt="In the CircleCI console, the Projects screen is shown. The three dots icon has been selected on the panther-analysis project."><figcaption></figcaption></figure>
4. 왼쪽 탐색 메뉴에서 **Environment Variables**.
5. 를 클릭하고 **Add Environment Variable**을 클릭한 다음 다음을 추가합니다. `INTERNAL_API_TOKEN` 및 `INTERNAL_API_HOST`.

   <figure><img src="/files/817e3892660d56648f59b358ef24f6fab505e0ec" alt="In the CircleCI console, the Project Settings screen is shown. There is a button to &#x22;Add Environment Variable&#x22;"><figcaption></figcaption></figure>

   * CircleCI 문서의 [Using Environment Variables](https://circleci.com/docs/env-vars) 를 참조하여 자세한 내용을 확인하세요.

다음도 확인해 보세요 [Panther Analysis Tool Commands](https://docs.panther.com/panther-developer-workflows/ci-cd/deployment-workflows/pat/pat-commands) 에서 Panther Analysis 도구에 대한 자세한 정보를 확인하세요.


---

# 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/ci-cd/deployment-workflows/circle-ci.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.
