이 문서에서는 YARA-L로 규칙을 작성하기 위해 Google Security Operations에서 추천하는 권장사항에 대해 설명합니다.
0 값 필터링
필드가 규칙을 실행할 이벤트에서 자동으로 생략될 수 있습니다. 필드가 생략되면 기본적으로 0 값으로 지정됩니다.
예를 들어 생략된 문자열 값은 기본적으로 ""입니다.
둘 다 생략된 2개 필드를 동일시 하는 경우 둘 다 기본적으로 0 값으로 지정될 수 있습니다. 그러면 둘 다 0 값을 포함하기 때문에 2개 필드가 일치하는 의도치 않은 일치 결과로 이어질 수 있습니다. 명시적으로 0 값을 지정하여 이 동작을 방지할 수 있습니다.
예를 들어 2개 필드에 따라 2개 이벤트를 동일시하는 규칙이 있으면 이러한 필드가 모두 비어 있을 때 두 필드가 일치할 가능성이 있습니다.
$e1.field1 = $e2.field2
데이터에 e1.field1 및 e2.field2가 모두 생략되었으면 "" = ""이 true이므로, 일치가 발생합니다.
다음 비교 표현식은 e1.field1 및 e2.field2가 데이터를 포함하지 않기 때문에 일치가 발생하지 않도록 보장합니다.
$e1.field1 = $e2.field2
$e1.field != ""
이벤트 유형 필터 추가
다음 예시에서는 각 UDM 이벤트의 IP 주소를 참조 목록과 비교하여 많은 리소스를 사용하는지 확인합니다.
events:// For every UDM event, check if the target.ip is listed in// the suspicious_ip_addresses reference list.$e.target.ipin%suspicious_ip_addresses
YARA-L 규칙이 특정 이벤트 유형의 UDM 이벤트에서만 감지하는 경우 이벤트 유형 필터를 추가하면 규칙에서 평가해야 하는 이벤트 수를 줄여 규칙을 최적화할 수 있습니다.
events:// For every UDM event of type NETWORK_DNS, check if the target.ip is// listed in the suspicious_ip_addresses reference list.$e.metadata.event_type="NETWORK_DNS"
$e.target.ipin%suspicious_ip_addresses
이 필터를 이벤트 섹션의 시작 부분에 추가합니다. 또한 정규식 또는 다른 비교 이전에 일치 필터를 배치해야 합니다. 필터는 규칙에 표시된 순서대로 적용됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-09-02(UTC)"],[[["YARA-L rules in Google Security Operations should filter out zero values to avoid unintended matches caused by omitted fields defaulting to zero."],["When creating rules that depend on enriched data, it's crucial to implement null checks to handle potential zero or null values before the enrichment process is complete."],["Adding event type filters to the beginning of the events section in YARA-L rules optimizes performance by reducing the number of events that the rule needs to evaluate."],["Equality filters should be placed before regex or other comparisons in the events section, as filters are applied in the order they appear."],["Google Security Operations has a large community library for YARA-L rules."]]],[]]