This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Advanced malware protection v1 (#199)
- Loading branch information
1 parent
9ee248b
commit 0a38068
Showing
4 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
catalystwan/endpoints/configuration/policy/definition/amp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
|
||
# mypy: disable-error-code="empty-body" | ||
|
||
from uuid import UUID | ||
|
||
from catalystwan.endpoints import APIEndpoints, delete, get, post, put | ||
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints | ||
from catalystwan.models.policy.definition.amp import ( | ||
AdvancedMalwareProtectionPolicy, | ||
AdvancedMalwareProtectionPolicyEditPayload, | ||
AdvancedMalwareProtectionPolicyGetResponse, | ||
) | ||
from catalystwan.models.policy.policy_definition import ( | ||
PolicyDefinitionEditResponse, | ||
PolicyDefinitionId, | ||
PolicyDefinitionInfo, | ||
PolicyDefinitionPreview, | ||
) | ||
from catalystwan.typed_list import DataSequence | ||
|
||
|
||
class ConfigurationPolicyAMPDefinition(APIEndpoints, PolicyDefinitionEndpoints): | ||
@post("/template/policy/definition/advancedMalwareProtection") | ||
def create_policy_definition(self, payload: AdvancedMalwareProtectionPolicy) -> PolicyDefinitionId: | ||
... | ||
|
||
@delete("/template/policy/definition/advancedMalwareProtection/{id}") | ||
def delete_policy_definition(self, id: UUID) -> None: | ||
... | ||
|
||
@put("/template/policy/definition/advancedMalwareProtection/{id}") | ||
def edit_policy_definition( | ||
self, id: UUID, payload: AdvancedMalwareProtectionPolicyEditPayload | ||
) -> PolicyDefinitionEditResponse: | ||
... | ||
|
||
@get("/template/policy/definition/advancedMalwareProtection", "data") | ||
def get_definitions(self) -> DataSequence[PolicyDefinitionInfo]: | ||
... | ||
|
||
@get("/template/policy/definition/advancedMalwareProtection/{id}") | ||
def get_policy_definition(self, id: UUID) -> AdvancedMalwareProtectionPolicyGetResponse: | ||
... | ||
|
||
@post("/template/policy/definition/advancedMalwareProtection/preview") | ||
def preview_policy_definition(self, payload: AdvancedMalwareProtectionPolicy) -> PolicyDefinitionPreview: | ||
... | ||
|
||
@get("/template/policy/definition/advancedMalwareProtection/preview/{id}") | ||
def preview_policy_definition_by_id(self, id: UUID) -> PolicyDefinitionPreview: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
|
||
from typing import List, Literal, Optional | ||
|
||
from annotated_types import Ge, Le | ||
from pydantic import BaseModel, ConfigDict, Field | ||
from typing_extensions import Annotated | ||
|
||
from catalystwan.models.common import IntStr | ||
from catalystwan.models.policy.policy_definition import ( | ||
PolicyDefinitionBase, | ||
PolicyDefinitionGetResponse, | ||
PolicyDefinitionId, | ||
) | ||
|
||
FileReputationServer = Literal["nam", "eur", "apjc"] | ||
FileAnalysisServer = Literal["", "nam", "eur"] | ||
AlertsLogLevel = Literal["", "info", "warning", "critical"] # hack | ||
AMPPolicyType = Literal["security", "unified"] | ||
FileAnalysisFileTypes = Literal[ | ||
"pdf", "ms-exe", "new-office", "rtf", "mdb", "mscab", "msole2", "wri", "xlw", "flv", "swf" | ||
] | ||
|
||
VpnId = Annotated[ | ||
IntStr, | ||
Ge(0), | ||
Le(65530), | ||
] | ||
|
||
|
||
class AdvancedMalwareProtectionDefinition(BaseModel): | ||
model_config = ConfigDict(populate_by_name=True) | ||
match_all_vpn: bool = Field(validation_alias="matchAllVpn", serialization_alias="matchAllVpn") | ||
file_reputation_cloud_server: FileReputationServer = Field( | ||
validation_alias="fileReputationCloudServer", serialization_alias="fileReputationCloudServer" | ||
) | ||
file_reputation_est_server: FileReputationServer = Field( | ||
validation_alias="fileReputationEstServer", serialization_alias="fileReputationEstServer" | ||
) | ||
file_reputation_alert: AlertsLogLevel = Field( | ||
validation_alias="fileReputationAlert", serialization_alias="fileReputationAlert" | ||
) | ||
file_analysis_enabled: Optional[bool] = Field( | ||
default=False, validation_alias="fileAnalysisEnabled", serialization_alias="fileAnalysisEnabled" | ||
) | ||
file_analysis_file_types: List[FileAnalysisFileTypes] = Field( | ||
default=[], validation_alias="fileAnalysisFileTypes", serialization_alias="fileAnalysisFileTypes" | ||
) | ||
file_analysis_alert: AlertsLogLevel = Field( | ||
default="", validation_alias="fileAnalysisAlert", serialization_alias="fileAnalysisAlert" | ||
) | ||
file_analysis_cloud_server: FileAnalysisServer = Field( | ||
default="", validation_alias="fileAnalysisCloudServer", serialization_alias="fileAnalysisCloudServer" | ||
) | ||
target_vpns: List[VpnId] = Field(default=[], validation_alias="targetVpns", serialization_alias="targetVpns") | ||
|
||
|
||
class AdvancedMalwareProtectionPolicy(PolicyDefinitionBase): | ||
type: Literal["advancedMalwareProtection"] = "advancedMalwareProtection" | ||
mode: AMPPolicyType | ||
definition: AdvancedMalwareProtectionDefinition | ||
|
||
|
||
class AdvancedMalwareProtectionPolicyEditPayload(AdvancedMalwareProtectionPolicy, PolicyDefinitionId): | ||
pass | ||
|
||
|
||
class AdvancedMalwareProtectionPolicyGetResponse(AdvancedMalwareProtectionPolicy, PolicyDefinitionGetResponse): | ||
pass |