Panther 분석 도구 명령어

PAT를 사용해 Panther 콘텐츠 관리하기

개요

Panther 분석 도구(PAT)를 사용하여 Panther 디택션 콘텐츠를 관리할 수 있습니다. PAT를 사용하면 upload, test, 및 삭제 자산 등 기타 작업을 수행할 수 있습니다.

각 PAT 명령은 특정 옵션. 예를 들어, 여러 명령에서 --filter를 사용하여 작업의 범위를 좁힐 수 있습니다. --filter 여러 명령과 함께 사용하여 작업 범위를 좁힐 수 있습니다.

PAT 명령

다음 코드 블록에서 사용 가능한 전체 PAT 명령 목록을 확인하세요. 그 아래에는 몇몇 명령에 대한 추가 정보가 있습니다.

PAT 명령은 다음을 사용하여 실행할 수 있습니다 panther_analysis_tool 또는 pat. 여기에서 이러한 별칭에 대해 자세히 알아보세요.

각 PAT 명령을 실행하는 데 필요한 Panther 권한을 이해하려면 다음을 참조하세요 명령별로 필요한 권한.

$ pat --help
                                                                                                                                       
사용법: pat [OPTIONS] COMMAND [ARGS]...                                                                                                
                                                                                                                                       
Panther 분석 도구: Panther 정책 및 룰 관리를 위한 커맨드 라인 도구입니다.                                                   
                                                                                                                                       
                                                                                                                                       
╭─ 옵션 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --version                     버전을 표시하고 종료                                                                                 │
│ --debug                       디버그 모드 활성화                                                                                  │
│ --skip-version-check          Panther 버전 검사 건너뛰기                                                                            │
│ --install-completion          현재 셸에 대한 자동완성 설치.                                                                        │
│ --show-completion             복사하거나 설치를 사용자화하기 위해 현재 셸의 자동완성을 표시합니다.                                           │
│ --help                        이 메시지를 표시하고 종료합니다.                                                                  │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ 명령 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ release                 Panther 디텍션을 포함하는 리포지토리에 대한 릴리스 자산을 생성합니다. 다음이라는 파일을 생성합니다                 │
│                         panther-analysis-all.zip 및 선택적으로 panther-analysis-all.sig 를 생성합니다                               │
│ test                    분석 사양을 검증하고 정책 및 룰 테스트를 실행합니다.                                                    │
│ debug                   디버그 환경에서 단일 룰 테스트를 실행하여 print 문을 보거나 브레이크포인트를 사용할 수 있습니다.            │
│                         브레이크포인트를 사용할 수 있습니다.                                                                 │
│ publish                 새 릴리스를 게시하고 릴리스 자산을 생성하여 업로드합니다. 다음이라는 파일을 생성합니다                    │
│                         panther-analysis-all.zip 및 선택적으로 panther-analysis-all.sig 를 생성합니다                               │
│ upload                  지정된 정책 및 룰을 Panther 배포에 업로드합니다.                                                     │
│ delete                  Panther 배포에서 정책, 룰 또는 저장된 쿼리를 삭제합니다.                                            │
│ update-custom-schemas   Panther 배포에서 커스텀 스키마를 업데이트하거나 생성합니다.                                           │
│ test-lookup-table       Lookup Table 사양 파일을 검증합니다.                                                               │
│ validate                대량 업로드를 Panther 인스턴스에 대해 검증합니다.                                                    │
│ zip                     Panther에 업로드하기 위해 로컬 정책 및 룰의 아카이브를 생성합니다.                                      │
│ check-connection        Panther API 연결을 확인합니다                                                                           │
│ benchmark               특정 로그 유형에 대해 한 룰의 성능을 테스트합니다. 룰은 작업 디렉터리에 있는 유일한 항목이거나 --path, --ignore-files, 및 --filter로 지정되어야 합니다. │
│                         이 기능은 데이터 리플레이의 확장 기능이며 동일한 제한을 받습니다.                                   │
│                         및 동일한 제한을 받습니다.                                                                         │
│ enrich-test-data        테스트 데이터를 Panther API의 추가 인리치먼트로 보강합니다.                                         │
│ check-packs             팩에 누락된 디텍션이 없는지 확인합니다.                                                           │
│ init                    새 Panther 프로젝트를 초기화합니다                                                                           │
│ update                  Panther Analysis의 최신 콘텐츠를 가져와 병합합니다. 콘텐츠를 업데이트하고 싶을 때마다 이 명령을 다시 실행하세요.     │
│                         업데이트하세요. Panther Analysis 항목과 동일한 ID 및 BaseVersion 필드가 있는 항목은 최신 Panther Analysis 항목과 병합됩니다. │
│                         병합됩니다. 병합 충돌이 있는 항목은 `merge` 명령으로 수동 해결하기 위해 건너뛰어집니다.                       │
│                         모든 병합 충돌을 건너뛰지 않고 해당 파일들에 기록하려면 --write-merge-conflicts 플래그를 사용하세요.             │
│                         충돌을 해당 파일에 기록합니다.                                                                    │
│ install                 Panther Analysis의 분석 항목을 로컬 리포지토리에 설치하고 활성화합니다.                                   │
│ explore                 최신 Panther Analysis 콘텐츠를 탐색합니다                                                               │
│ merge                   분석 항목을 최신 Panther Analysis 콘텐츠와 병합합니다                                                      │
│ migrate                 BaseVersion 필드를 추가하여 Panther Analysis 콘텐츠를 기반으로 하는 모든 분석 항목을 마이그레이션하고 최신 상태로 만듭니다. │
│                         최신 상태로 만듭니다.                                                                               │
│ fmt                     현재 디렉터리의 코드를 포맷하고 표준화하여 다른 명령에서 변경을 줄이는 데 도움을 줍니다.                         │
│                         명령들에서 변경을 줄이는 데 도움을 줍니다.                                                         │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

init: Panther 디렉터리 준비 중

이 명령은 Panther 디렉터리를 처음 설정할 때 한 번만 실행해야 합니다.

다음 작업을 수행합니다:

  • 다음을 생성합니다 .gitignore 파일이 필요한 경우 생성하고 여기에 추가합니다

  • 다음을 활성화합니다 git rerere

  • 다음을 생성합니다 .cache 디렉터리로, 빠른 로딩을 위해 로컬에 콘텐츠를 저장합니다 panther-analysis 빠른 로딩을 위해

    • 에서 최신 콘텐츠를 가져옵니다 panther-analysis

migrate: 레거시 관리 흐름에서 콘텐츠 이전 중

migrate PAT에게 향후 업데이트를 위해 기존 분석 항목을 추적하기 시작하라고 지시합니다.

다음을 실행하면 pat migrate 리포지토리를 검사하고 다음을 수행합니다:

  • Panther Analysis의 ID와 일치하는 ID를 가진 각 분석 항목에 대해 panther-analysis:

    • 다음을 추가합니다 BaseVersion 필드를 YAML 파일에 추가합니다.

    • 항목을 최신 Panther Analysis 버전과 병합합니다 panther-analysis.

      • 병합 충돌이 있는 경우 PAT는 항목을 병합하지 않습니다. 충돌을 해결하려면 pat migrate <ID>.

      • 다음을 선택적으로 사용할 수 있습니다 --auto-accept 플래그를 사용하여 병합 충돌을 완전히 피할 수 있습니다.

        circle-info

        참고: pat migrate <ID> 은 마이그레이션 중에 병합 충돌을 해결하기 위한 것입니다. 마이그레이션 중에 병합 충돌이 발생한 항목은 아직 마이그레이션되지 않았습니다. 이는 pat migrate 와 매우 유사합니다 pat merge <ID>, 이는 pat update를 실행한 후에 병합 충돌을 해결하는 데 사용됩니다. 병합 명령은 마이그레이션 단계에서 사용해서는 안 됩니다.

  • Panther Analysis의 ID와 일치하지 않는 ID를 가진 각 분석 항목에 대해 panther-analysis변경되지 않습니다. 해당 항목은 커스텀으로 간주됩니다.

이 명령의 출력은 다음에 저장됩니다 ./migration_status.md.

update: panther-analysis의 최신 콘텐츠 가져오기 및 병합

콘텐츠를 업데이트하고 싶을 때마다 이 명령을 다시 실행하세요.

이 명령은 최신 panther-analysis 콘텐츠를 가져와 귀하의 콘텐츠와 병합합니다. PAT는 분석 항목의 ID가 panther-analysis 와 동일하고 BaseVersion 필드가 panther-analysis의 항목의 최신 버전보다 작은지를 판단하여 항목이 업데이트가 필요한지 확인합니다. panther-analysis. 항목의 ID가 panther-analysis 와 동일하지만 BaseVersion 필드가 없으면 업데이트를 받지 않습니다. 마찬가지로, 항목이 panther-analysis 에 일치하는 ID가 없지만 BaseVersion 필드가 있으면 업데이트를 받지 않습니다.

병합 충돌이 있는 항목은 pat update의 일부로 업데이트되지 않으며, 병합 명령으로 수동 해결해야 합니다. 병합 충돌이 있던 모든 항목의 목록이 update 명령.

circle-info

명령의 출력에 인쇄됩니다. pat updatepat update에서 발생한 병합 충돌이 있는 경우, 로 해결할 수 있습니다 pat merge

(그러나 이는 성공적으로 업데이트된 콘텐츠를 테스트하고 업로드하는 데 필수는 아닙니다). --write-merge-conflicts 모든 병합 충돌을 파일에 기록하려면 플래그를 사용하세요(이는 AI를 사용하여 충돌을 해결하는 경우 유용할 수 있습니다). 다음을 사용하세요 또는 --auto-accept panthers --auto-accept yours

(그러나 이는 성공적으로 업데이트된 콘텐츠를 테스트하고 업로드하는 데 필수는 아닙니다). 병합 충돌을 자동으로 해결하려면(해결 후에도 항목에 문제가 있거나 테스트가 실패할 수 있으므로 각 항목은 해결 후 검토되어야 합니다). --preview

플래그를 사용하면 업데이트의 드라이런을 수행합니다. 이 플래그는 파일을 업데이트하지 않고 업데이트될 항목의 ID와 병합 충돌이 발생할 항목을 출력하게 합니다.explore panther-analysis 컨텐츠 제거

다음 명령을 실행하세요 pat explore : 사용 가능한 항목 보기 panther-analysis 를 사용하여 디렉터리의 콘텐츠를 보려면 .cache 디렉터리에서 콘텐츠를 봅니다. (이 명령은 p-a 릴리스의 최신과 비교하여 p-a 콘텐츠가 오래된 경우 새 p-a 콘텐츠를 가져옵니다.) ID, 유형 또는 설명으로 검색할 수 있습니다.

다음에 액세스할 수 있습니다 분석 콘텐츠 트리를 사용하여 키를 사용하세요. 아무 분석 유형에서 엔터 키를 눌러 해당 유형으로 필터링할 수 있습니다. 아무 단일 분석 ID에서 엔터 키를 눌러 해당 유형으로 필터링할 수 있습니다. 엔터 키를 눌러 해당 ID로 필터링할 수 있습니다.

검색 바는 테이블의 항목을 필터링하는 데 사용할 수 있습니다. YAML 또는 python 파일에 텍스트가 포함된 항목을 대소문자 구분하여 필터링하는 일반 텍스트 검색을 사용할 수 있습니다. 또한 커맨드 라인에서 사용 가능한 필터를 사용하여 검색할 수 있습니다. 예를 들어 data "prod env" AnalysisType=rule Severity=Critical,High 라는 검색은 YAML 또는 python에 data 가 포함된 항목을 대소문자 구분으로 검색하고, prod env 가 YAML 또는 python에 포함된 항목을 검색하며, 분석 유형이 scheduled_rule이고 심각도가 Critical 또는 High인 항목을 찾습니다. 검색에서 단어나 구를 묶으려면 작은따옴표나 큰따옴표를 사용할 수 있습니다. 모든 따옴표는 적용되려면 맞는 끝 따옴표가 있어야 합니다. 큰따옴표는 백슬래시(\)로 이스케이프할 수 있습니다.\작은따옴표는 이스케이프할 수 없습니다.

특정 항목에서 엔터 키를 눌러 해당 유형으로 필터링할 수 있습니다. 를 누르면 해당 소스 코드가 열립니다. YAML과 Python 파일이 있는 분석 유형의 경우 두 파일을 나란히 보여줍니다.

circle-info

특정 항목을 볼 때 ^v 를 사용하여 설치하고 활성화할 수 있습니다(별도의 pat install 명령을 사용하는 대신).

탐색기 GUI는 ctrl+q 또는 또는 ctrl+c 로 종료할 수 있습니다..

install: 항목 복사 및 활성화 panther-analysis 를 사용하여 항목을 복사합니다

다음 명령을 실행하세요 pat install Panther Analysis에서 항목을 귀하의 리포지토리로 복사합니다. (설치하려는 항목을 이해하려면 panther-analysis 를 실행하는 것이 권장됩니다) pat explore.)

분석 항목에 전역 헬퍼나 데이터 모델과 같은 종속성이 있는 경우, 해당 종속성도 귀하의 리포지토리에 복제되어 설치됩니다.

fmt: 코드 포맷 및 표준화

현재 디렉터리의 코드를 포맷하고 표준화하려면 실행하세요. PAT 사용의 일부로 요구되는 형식 변경이 있습니다. 이 명령은 도구가 수행하는 다른 모든 변경과 별도로 형식 변경을 쉽게 수행할 수 있게 해줍니다. PAT와 상호작용하는 동안 논리 변경과 형식 변경을 독립적으로 유지하는 데 사용하세요.

YAML 파일에 대해 수행하는 변경 사항은 다음과 같습니다:

  • 모든 불리언 표기의 대소문자를 정규화합니다(예: True -> true)

  • 모든 들여쓰기를 2칸으로 표준화합니다

  • 명시적 null을(를) 빈 값으로 대체합니다(예: Field: null -> Field: )

  • 모든 인라인 스타일 필드를 블록 스타일로, JSON을 블록 스타일로 대체합니다

  • 명시적 멀티라인 표식(예: ) 없이 문자열 내부의 모든 개행을 제거합니다 |>)

병합: 분석 항목을 해당 항목의 최신 Panther Analysis 버전과 병합

circle-info

pat merge <ID> 은(는) 를 실행한 후 병합 충돌을 해결하는 데 사용됩니다. pat update아직 코드를 마이그레이션 중이라면 pat migrate <ID> 를 사용하여 병합 충돌이 있는 항목을 마이그레이션하세요.

을(를) 실행한 후에는 pat update병합 충돌로 인해 분석 항목이 깔끔하게 업데이트되지 않을 수 있습니다. 항목을 최신 Panther Analysis 버전과 병합하고 병합 충돌을 해결하려면 pat merge <ID>를 실행하세요, 여기서 ID 는 병합 충돌을 해결하려는 분석 항목의 ID입니다.

YAML 병합 충돌은 커스텀 YAML 병합 충돌 해결 도구 내에서 해결됩니다. 이 도구는 필드별로 빠르게 비교하여 충돌을 해결할 때 귀하의 버전 또는 Panther의 버전을 선택할 수 있게 해줍니다. 이 도구는 라인 단위가 아닌 필드 단위로 변경을 비교하므로 포맷 변경으로 인한 병합 충돌을 피할 수 있게 해줍니다. YAML에서는 최상위 필드만 비교합니다.

모든 YAML 충돌 이후에 명령은 Python 병합 충돌을 해결하게 합니다. 기본적으로 이는 vi내에서 발생합니다. 다른 편집기를 사용하려면 --editor 플래그를 제공하거나 환경 변수를 설정하세요 환경 변수에 설정하여 지정할 수 있습니다. 편집기는 CLI 명령으로 사용 가능해야 합니다. 일부 편집기는 기본적으로 CLI 명령을 설치하지 않으므로 선호하는 편집기가 CLI를 통해 사용 가능한지 확인하세요.

병합 충돌을 성공적으로 해결한 후, 명령은 YAML의 BaseVersion 필드를 업데이트합니다.

병합 충돌을 다르게 해결하려면 다음 플래그를 제공할 수 있습니다:

  • --auto-accept: 다른 명령과 동일하게 작동합니다. 다음 값을 허용합니다 yours 또는 panthers 값으로 사용될 수 있습니다. 병합의 한 쪽을 자동으로 선택하여 병합 충돌을 피합니다.

  • --write-merge-conflicts: 모든 병합 충돌을 미해결 상태로 파일에 기록합니다. 이렇게 해도 충돌은 해결되지 않으며 공백 관련 YAML 충돌은 피할 수 없습니다. BaseVersion 업데이트됩니다.

test: 단위 테스트 실행

정의된 사양 파일을 로드하고 로컬에서 단위 테스트를 평가하려면 PAT를 사용하십시오:

특정 속성을 기준으로 룰 또는 정책을 필터링하려면:

circle-info

다음을 실행하면 pat test for correlation rules간단한 디텍션(Simple Detections) requires an API token. See Authenticating with an API token 에서 자세한 정보를 확인하세요.

debug: Debug a test using print statements and breakpoints

다음을 사용하세요 debug to run a specific unit test in debug mode:

See print statements:

See your errors with traceback info:

benchmark: Evaluating rule performance

다음을 사용하여 benchmark to test the performance of an existing or draft rule against one hour of data, for one log type. It can be particularly useful to iterate on a rule that is timing out. This is a long-running command intended to be used manually, as needed—not in a regular CI/CD workflow.

The API token used with this command must be granted the "Read Panther Metrics" (also known as SummaryRead) and "Manage Rules" (also known as RuleModify) permissions. Because benchmark is an extension of Data Replay, it is subject to the same limitations.

You must provide a single rule to benchmark, either by having just one rule in the working directory (./ 또는 --path), or through the use of --ignore-files 또는 --filter.

If you do not specify a certain hour of data, the system will select the historical hour with the highest volume of data. To specify a specific hour to run against, use --hour. (Most common time formats are supported, e.g., 2023-07-31T09:00:00-7:00—minutes, seconds, etc. will be truncated). For example:

For a rule with multiple log types, one must be specified using --log-type. For example:

The output of benchmark will be written to both stdout, and to the directory indicated by the --out option.

enrich-test-data: Enriching test data with Enrichment content

다음을 사용하세요 enrich-test-data to enrich the test content of your Rules and Scheduled Rules with data from connected Enrichment providers and custom Lookup Tables. This allows you to build more sophisticated test cases for detections that rely on enrichment content.

enrich-test-data is simple to use, but may introduce substantial changes to your analysis YAML files. The command will modify files based on the following criteria:

  • If the Rule or Scheduled Rule does not have test cases, the YAML file will not be modified.

  • If the log type does not support enrichment, the YAML file will not be modified.

  • If the log type supports enrichment and there are test cases:

    • Test cases represented as inline JSON content will be reformatted into YAML.

    • The YAML file will be formatted according to common YAML conventions, using two spaces for indentation.

Similar to other commands, enrich-test-data works from the current directory, recursively. If you run the command at the root directory of your panther-analysis copy, it will attempt to enrich all Rules and Scheduled Rules. To enrich content in a single directory, navigate to that directory before running the command.

You can run enrich-test-data in PAT versions 0.26 and beyond using the following command:

The output of the command will be written to stdout, including a list of any Rules or Scheduled Rules that were enriched.

validate: Ensuring detection content is ready to be uploaded

키는 이 파생 디텍션과 그 베이스 디텍션 간의 연결이며, 상속이 적용되어야 함을 나타냅니다. validate command verifies your detection content is ready to be uploaded to your Panther instance by running the same checks that happen during the upload process. Because some of these checks require configuration information in your Panther instance, validate makes an API call.

To validate your detections against your Panther instance using PAT:

  1. Run the following command:

    {% code fullWidth="false" %}

    {% endcode %}

    • You may exclude the --api-token--api-host options if you are setting configuration values another way, i.e., by using environment variables or a configuration file.

zip: Creating a package to upload to the Panther Console

To create a package for uploading manually to the Panther Console, run the following command:

Panther 콘솔에 콘텐츠 업로드

  1. In the lefthand side of the Panther Console, click 디텍션(Detections).

  2. Click the Upload button in the upper right corner.

  3. Drag and drop your .zip file onto the page, or click Select file.

upload: Uploading packages to Panther directly

circle-info

Starting with PAT version 0.22.0, if you have authenticated with an API token and execute the upload command, an asynchronous bulk upload will automatically be performed, to prevent timeout issues.

If you did not use an API token to authenticate, you can use the --batch option. The --batch option is only available in versions of PAT after 0.19.0.

The upload command uploads your detection content to your Panther instance.

To use upload:

  1. 다음 명령을 실행하세요 panther_analysis_tool test to ensure your unit tests are passing.

  2. Run the following command: panther_analysis_tool upload --path <path-to-your-detections> --api-token <your-api-token> --api-host https://api.<your-panther-instance-name>.runpanther.net/public/graphql

    • You may exclude the --api-token--api-host options if you are setting configuration values another way, i.e., by using environment variables or a configuration file.

When using upload, detections and Lookup Tables with existing IDs are overwritten. Locally deleted detections will not automatically be deleted in your Panther instance on upload—they must be removed with the 삭제 command (or manually deleted in your Panther Console). When using the CLI workflow, it's recommended to set a detection's Enabled property to false, instead of deleting.

If you update the ID of an entity (i.e., the value of RuleId 또는 PolicyId) and use upload—but do not also use 삭제 to manually remove the old entity, both versions will exist in your Panther instance. If you intend to update the ID without creating a duplicate detection, use 삭제 with the old ID.

키는 이 파생 디텍션과 그 베이스 디텍션 간의 연결이며, 상속이 적용되어야 함을 나타냅니다. CreatedBy detection field

By default, detections uploaded in the CLI workflow (i.e., with PAT or via the REST API) are shown on the 디텍션(Detections) list page in the Panther Console as created by Panther:

A table with headers and one row is shown. A header/row value pair (Created By / Panther) is circled.

If you'd like to customize the Created By value for a detection uploaded in the CLI workflow, you can add a CreatedBy key to your detection's YAML file. The value of CreatedBy can be:

  • A Panther user's email address: in the Console, the Created By field will show the associated user.

  • A Panther user's unique ID: in the Console, the Created By field will show the associated user.

  • An arbitrary text value: in the Panther Console, the provided value will be displayed with (External) appended to it.

    A table with headers and four row values is shown. A "Created By" column with the values in the first three rows is circled.

키는 이 파생 디텍션과 그 베이스 디텍션 간의 연결이며, 상속이 적용되어야 함을 나타냅니다. CreatedBy key can be used in definitions for Python rules, scheduled rules, correlation rules, simple detections, and policies.

If you download a detection from the Panther Console:

  • If it was created in the Panther Console, it will not contain CreatedBy.

  • If it was uploaded in the CLI workflow:

    • With CreatedBy, it will contain CreatedBy.

    • Without CreatedBy, it will not contain CreatedBy.

삭제: Deleting Rules, Policies, or Saved Queries

While panther_analysis_tool upload --path <directory> will upload everything from <directory>, it will not delete anything in your Panther instance if you simply remove a local file from <directory>. Instead, you can use the panther_analysis_tool delete command to explicitly delete detections from your Panther instance. To delete a specific detection, you can run the following command:

This will interactively ask you for a confirmation before it deletes the detection. If you would like to delete without confirming, you can use the following command:

You can delete up to 1000 detections at once with PAT.

update-custom-schemas: Creating or updating custom schemas

다음을 사용하세요 update-custom-schemas to create or update custom schemas.

circle-exclamation

명령별로 필요한 권한

Below is a mapping of permissions required for each command.

Command
Required permission(s)

check-connection

Read Panther Settings Info

test (when testing detections that use 인라인 필터(Inline Filters)arrow-up-right)

Bulk Upload OR Bulk Upload Validate OR View Rules

benchmark

Read Panther Metrics

validate

Bulk Upload Validate OR Bulk Upload

upload

Bulk Upload

삭제

Manage Policies Manage Rules Manage Saved Searches

update-custom-schemas

View Log Sources Manage Log Sources

PAT command options

Each PAT command has options (also known as flags), which you can view by running $ pat <command> -h.

chevron-rightExample output of pat test -hhashtag

옵션이 여러 인수를 받는 경우 각 값을 옵션과 함께 개별적으로 전달해야 합니다. 예를 들어 두 개의 인수를 전달하려면 --valid-table-names:

  • 올바른 예: --valid-table-names table1 --valid-table-names table2

  • 잘못된 예: --valid-table-names table1 table2

다중 인수 옵션이 다음 형식의 값을 허용하는 경우 KEY=VALUE1,VALUE2 (예: --filter), 각 항목은 플래그에 대해 개별적으로 전달되어야 합니다(그러나 인수 값은 여전히 쉼표로 구분된 배열로 표현될 수 있음). 예를 들면:

  • 올바른 예: --filter AnalysisType=policy,rule --filter Severity=High

  • 잘못된 예: --filter AnalysisType=policy,rule Severity=High

--filter: PAT 명령 필터링

키는 이 파생 디텍션과 그 베이스 디텍션 간의 연결이며, 상속이 적용되어야 함을 나타냅니다. test, zip, upload, 및 release 모든 명령은 필터링을 지원합니다. 필터링은 --filter 플래그에 필터 목록을 지정된 형식으로 전달하여 동작합니다 KEY=VALUE1,VALUE2. 키는 정책이나 룰의 유효한 필드일 수 있습니다. 필터를 사용할 때는 지정된 각 필터와 일치하는 분석 타입만 고려됩니다.

예를 들어 다음 명령은 다음을 가진 항목만 테스트합니다 : 이것이 정책의 Severity 가 High인 경우:

다음 명령은 : 이것이 정책 OR 룰, 그리고 Severity 가 High인 항목을 테스트합니다:

글로벌 분석 타입을 참조하는 정책이나 룰을 작성할 때는 필터에 이를 포함해야 합니다. 필터 값으로 빈 문자열을 포함할 수 있으며, 이는 해당 필드가 존재할 때만 필터가 적용됨을 의미합니다. 필터 값으로 빈 문자열을 포함할 수 있으며, 이는 해당 필드가 존재할 때만 필터가 적용됨을 의미합니다.

다음 명령은 오류를 반환합니다. 해당 정책이 global을 임포트하지만 global에 severity가 없어 필터에 의해 제외되기 때문입니다:

이 쿼리가 예상대로 작동하려면 severity 필드가 없을 수 있도록 허용해야 합니다:

필터는 zip, upload, 및 release 명령에서 필터가 작동하는 방식과 동일하게 작동합니다 test 명령.

--minimum-tests: 특정 수의 단위 테스트 요구하기

다음 플래그로 최소 단위 테스트 수를 설정할 수 있습니다 --minimum-tests 플래그. 최소 수의 테스트가 없는 디텍션은 실패로 간주됩니다. 만약 --minimum-tests 가 다음 값으로 설정되면 2 또한 최소한 하나의 테스트가 True 를 반환하고 하나가 False.

아래 예에서 각 룰 테스트는 통과했지만 올바른 테스트 커버리지가 없기 때문에 여전히 실패로 간주됩니다:

마지막 업데이트

도움이 되었나요?