Files
sigma-rules/detection_rules/schemas/registry_package.py
T
Justin Ibarra fc9dfde2c4 Generate an integrations package from a release (#983)
* Generate an integrations package files during a release build
2021-03-09 13:30:12 -09:00

48 lines
1.6 KiB
Python

# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
"""Definitions for packages destined for the registry."""
from dataclasses import dataclass, field
from typing import Dict, List, Type
from marshmallow import Schema, validate
from marshmallow_dataclass import class_schema
from .definitions import ConditionSemVer, SemVer
@dataclass
class RegistryPackageManifest:
"""Base class for registry packages."""
conditions: Dict[str, ConditionSemVer]
version: SemVer
categories: List[str] = field(default_factory=lambda: ['security'])
description: str = 'Rules for the detection engine in the Security application.'
format_version: SemVer = field(metadata=dict(validate=validate.Equal('1.0.0')), default='1.0.0')
icons: list = field(default_factory=list)
internal: bool = True
license: str = 'basic'
name: str = 'detection_rules'
owner: Dict[str, str] = field(default_factory=lambda: dict(github='elastic/protections'))
policy_templates: list = field(default_factory=list)
release: str = 'experimental'
screenshots: list = field(default_factory=list)
title: str = 'Detection rules'
type: str = 'integration'
@classmethod
def get_schema(cls) -> Type[Schema]:
return class_schema(cls)
@classmethod
def from_dict(cls, obj: dict) -> 'RegistryPackageManifest':
return cls.get_schema()().load(obj)
def asdict(self) -> dict:
return self.get_schema()().dump(self)