Domain models and related functionality

Interface

Criterion dataclass

Criterion()

Bases: ABC

Abstract base class for AWS Security Finding Filter criterion.

Criterions are the individual filter conditions that make up a Filter.

Methods:

  • match –

    Check if a finding value matches this criterion.

match abstractmethod
match(finding_value: TInput) -> bool

Check if a finding value matches this criterion.

Parameters:

  • finding_value
    (TInput) –

    The value from the finding to compare against the criterion

Returns:

  • bool –

    True if the finding_value matches the criterion, False otherwise

Filter dataclass

Filter(
    criterions: tuple[TFilter, ...],
    combined_comparison: Callable = any,
)

Bases: ABC

Abstract base class for an AWS Security Finding Filter.

A Filter is made up of one or more single-typed Criterions combined with a logical operation Criterions are more strictly defined than a Filter. Therefore, a filter has a criterion_type attribute to indicate which type of Criterion it contains.

Methods:

  • match –

    Check if a finding value matches the filter's criterions.

Attributes:

criterion_type abstractmethod property
criterion_type: type

The type of criterion this class relates to.

match
match(finding_value: TInput) -> bool

Check if a finding value matches the filter's criterions.

Parameters:

  • finding_value
    (TInput) –

    The value from the finding to compare against the criterions

Returns:

  • bool –

    True if the finding_value matches the combined criterions, False otherwise

Type-specific models

StringComparisons

Bases: Enum

The available string comparison operations linked to their functions.

StringCriterion dataclass

StringCriterion(Comparison: str, Value: str)

Bases: _StringLikeCriterion

Dataclass representing a SecurityHub String Criterion.

Parameters:

  • Comparison
    (str) –

    The comparison operation to use

  • Value
    (str) –

    The value to compare against

Methods:

  • __post_init__ –

    Get the comparison function based on the Comparison attribute.

  • match –

    Check if a string from a finding matches this string criterion.

__post_init__
__post_init__() -> None

Get the comparison function based on the Comparison attribute.

match
match(finding_value: str) -> bool

Check if a string from a finding matches this string criterion.

Parameters:

  • finding_value
    (str) –

    The string from the finding to compare against

Returns:

  • bool –

    True if the finding_value matches the criterion, False otherwise

StringFilter dataclass

StringFilter(
    criterions: tuple[StringCriterion, ...],
    combined_comparison: Callable = any,
)

Bases: Filter[str, StringCriterion]

Dataclass representing a SecurityHub StringFilter to be applied on a single finding attribute.

Methods:

  • __post_init__ –

    Initialize the combined comparison function based on the types of criterions.

  • match –

    Check if a finding value matches the filter's criterions.

__post_init__
__post_init__() -> None

Initialize the combined comparison function based on the types of criterions.

All criterions must be either positive or negative. Raise ValueError if mixed criterions are found.

match
match(finding_value: TInput) -> bool

Check if a finding value matches the filter's criterions.

Parameters:

  • finding_value
    (TInput) –

    The value from the finding to compare against the criterions

Returns:

  • bool –

    True if the finding_value matches the combined criterions, False otherwise

DateCriterion dataclass

DateCriterion(
    DateRange: dict[str, str] = dict(),
    End: str = "",
    Start: str = "",
)

Bases: Criterion

Dataclass representing a SecurityHub Date Criterion.

Either DateRange, or Start or End must be specified.

Parameters:

  • DateRange
    (dict[str, str], default: dict() ) –

    Optionally specify a relative date range with a 'Value' key indicating the number of days

  • End
    (str, default: '' ) –

    Optionally specify an absolute end date in ISO format

  • Start
    (str, default: '' ) –

    Optionally specify an absolute start date in ISO format

Methods:

  • __post_init__ –

    Initialize the date criterion on DateRange or Start/End.

  • match –

    Check if a datetime string from a finding matches this date criterion.

__post_init__
__post_init__() -> None

Initialize the date criterion on DateRange or Start/End.

match
match(finding_value: str) -> bool

Check if a datetime string from a finding matches this date criterion.

Parameters:

  • finding_value
    (str) –

    The string from the finding to compare against

Returns:

  • bool –

    True if the finding_value matches the criterion, False otherwise

DateFilter dataclass

DateFilter(
    criterions: tuple[DateCriterion, ...],
    combined_comparison: Callable = any,
)

Bases: Filter[str, DateCriterion]

Dataclass representing a SecurityHub DateFilter to be applied on a single finding attribute.

Methods:

  • match –

    Check if a finding value matches the filter's criterions.

match
match(finding_value: TInput) -> bool

Check if a finding value matches the filter's criterions.

Parameters:

  • finding_value
    (TInput) –

    The value from the finding to compare against the criterions

Returns:

  • bool –

    True if the finding_value matches the combined criterions, False otherwise

NumberComparisons

Bases: Enum

The available number comparison operations linked to their functions.

NumberCriterion dataclass

NumberCriterion(
    Eq: float | None = None,
    Gt: float | None = None,
    Gte: float | None = None,
    Lt: float | None = None,
    Lte: float | None = None,
)

Bases: Criterion

Dataclass representing a SecurityHub Number Criterion.

Parameters:

  • Eq
    (float, default: None ) –

    The value to compare for equality

  • Gt
    (float, default: None ) –

    The value to compare for greater than

  • Gte
    (float, default: None ) –

    The value to compare for greater than or equal to

  • Lt
    (float, default: None ) –

    The value to compare for less than

  • Lte
    (float, default: None ) –

    The value to compare for less than or equal to

Methods:

  • __post_init__ –

    Get the comparison functions based on which attributes are set.

  • match –

    Check if a number from a finding matches this number criterion.

__post_init__
__post_init__() -> None

Get the comparison functions based on which attributes are set.

match
match(finding_value: float) -> bool

Check if a number from a finding matches this number criterion.

Parameters:

  • finding_value
    (float) –

    The number from the finding to compare against

Returns:

  • bool –

    True if the finding_value matches the criterion, False otherwise

NumberFilter dataclass

NumberFilter(
    criterions: tuple[NumberCriterion, ...],
    combined_comparison: Callable = any,
)

Bases: Filter[float, NumberCriterion]

Dataclass representing a SecurityHub NumberFilter to be applied on a single finding attribute.

Methods:

  • match –

    Check if a finding value matches the filter's criterions.

match
match(finding_value: TInput) -> bool

Check if a finding value matches the filter's criterions.

Parameters:

  • finding_value
    (TInput) –

    The value from the finding to compare against the criterions

Returns:

  • bool –

    True if the finding_value matches the combined criterions, False otherwise

MapStringComparisons

Bases: Enum

The available map string comparison operations linked to their functions.

MapCriterion dataclass

MapCriterion(Comparison: str, Value: str, Key: str)

Bases: _StringLikeCriterion

Dataclass representing a SecurityHub Map Criterion.

Parameters:

  • Comparison
    (str) –

    The comparison operation to use

  • Key
    (str) –

    The key in the map to compare against

  • Value
    (str) –

    The value to compare against

Methods:

  • __post_init__ –

    Get the comparison function based on the Comparison attribute.

  • match –

    Check if a string from a map in the finding matches this string criterion.

__post_init__
__post_init__() -> None

Get the comparison function based on the Comparison attribute.

match
match(finding_value: dict[str, str]) -> bool

Check if a string from a map in the finding matches this string criterion.

Parameters:

  • finding_value
    (dict[str, str]) –

    The map from the finding to compare against

Returns:

  • bool –

    True if the finding_value matches the criterion, False otherwise

MapFilter dataclass

MapFilter(
    criterions: tuple[MapCriterion, ...],
    combined_comparison: Callable = any,
)

Bases: Filter[dict[str, str], MapCriterion]

Dataclass representing a SecurityHub MapFilter to be applied on a single finding attribute.

Methods:

  • __post_init__ –

    Initialize the combined comparison function based on the types of criterions.

  • match –

    Check if a finding value matches the filter's criterions.

__post_init__
__post_init__() -> None

Initialize the combined comparison function based on the types of criterions.

All criterions must be either positive or negative. Raise ValueError if mixed criterions are found.

match
match(finding_value: TInput) -> bool

Check if a finding value matches the filter's criterions.

Parameters:

  • finding_value
    (TInput) –

    The value from the finding to compare against the criterions

Returns:

  • bool –

    True if the finding_value matches the combined criterions, False otherwise

CidrCriterion dataclass

CidrCriterion(Cidr: str = '')

Bases: Criterion

Dataclass representing a SecurityHub Cidr Criterion.

Parameters:

  • Cidr
    (str, default: '' ) –

    The CIDR to match against

Methods:

  • match –

    Check if a CIDR string from a finding matches this CIDR criterion.

match
match(finding_value: str) -> bool

Check if a CIDR string from a finding matches this CIDR criterion.

Parameters:

  • finding_value
    (str) –

    The CIDR string from the finding to compare against

Returns:

  • bool –

    True if the finding_value matches the criterion, False otherwise

CidrFilter dataclass

CidrFilter(
    criterions: tuple[CidrCriterion, ...],
    combined_comparison: Callable = any,
)

Bases: Filter[str, CidrCriterion]

Dataclass representing a SecurityHub CidrFilter to be applied on a single finding attribute.

Methods:

  • match –

    Check if a finding value matches the filter's criterions.

match
match(finding_value: TInput) -> bool

Check if a finding value matches the filter's criterions.

Parameters:

  • finding_value
    (TInput) –

    The value from the finding to compare against the criterions

Returns:

  • bool –

    True if the finding_value matches the combined criterions, False otherwise

Factory utilities

Public functions

create_filters

create_filters(
    filters_dicts: list[dict[str, Any]],
) -> Filter

Create an AwsSecurityFindingFilters instance from a list of filters dicts.

Filters dicts must all correspond to the same AwsSecurityFindingFilters type.

Parameters:

  • filters_dicts
    (list[dict[str, Any]]) –

    The filters dicts to create the AwsSecurityFindingFilters instance from

Returns:

  • Filter –

    The created AwsSecurityFindingFilters instance

match_to_filter_type

match_to_filter_type(
    filter_dict: dict[str, Any],
) -> type[Filter]

Match a filters dict to an AwsSecurityFindingFilters type.

Parameters:

  • filter_dict
    (dict[str, Any]) –

    The filters dict to match

Returns:

  • type[Filter] –

    The matched AwsSecurityFindingFilters type

Public classes

AllFilters

Bases: Enum

Enum representing all available AwsSecurityFindingFilters types.