Skip to content

Commit 0c878c2

Browse files
authored
Saimon/ransom malware protection (#309)
1 parent b317a8a commit 0c878c2

File tree

5 files changed

+184
-3
lines changed

5 files changed

+184
-3
lines changed

cterasdk/edge/antivirus.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import logging
2+
from .enum import Mode
3+
from .base_command import BaseCommand
4+
5+
6+
logger = logging.getLogger('cterasdk.edge')
7+
8+
9+
class Antivirus(BaseCommand):
10+
"""Edge Filer Antivirus APIs"""
11+
12+
def __init__(self, edge):
13+
super().__init__(edge)
14+
self.settings = Settings(self._edge)
15+
16+
def enable(self):
17+
"""
18+
Enable Bit Defender antivirus.
19+
"""
20+
logger.info('Enabling antivirus.')
21+
response = self._edge.api.put('/config/av/realtime/mode', Mode.Enabled)
22+
logger.info('Antivirus enabled.')
23+
return response
24+
25+
def disable(self):
26+
"""
27+
Disable Bit Defender antivirus.
28+
"""
29+
logger.info('Disabling antivirus.')
30+
response = self._edge.api.put('/config/av/realtime/mode', Mode.Disabled)
31+
logger.info('Antivirus disabled.')
32+
return response
33+
34+
def update(self):
35+
"""
36+
Check for updates.
37+
"""
38+
return self._edge.api.execute('/config/av/updates', 'updatenow')
39+
40+
def status(self):
41+
"""
42+
Get Status.
43+
"""
44+
return self._edge.api.get('/status/av')
45+
46+
47+
class Settings(BaseCommand):
48+
49+
def get(self):
50+
"""
51+
Get antivirus settings.
52+
"""
53+
return self._edge.api.get('/config/av/updates')
54+
55+
def update(self, schedule, disabled=False):
56+
"""
57+
Update antivirus settings.
58+
59+
:param cterasdk.edge.types.AntivirusUpdateSchedule schedule: Antivirus update schedule
60+
:param bool,optional disabled: Enable or disable automatic updates, defaults to ``False``
61+
"""
62+
settings = self.get()
63+
settings.mode = Mode.Disabled if disabled is True else Mode.Enabled
64+
settings.schedule = schedule
65+
return self._edge.api.put('/config/av/updates', settings)

cterasdk/edge/types.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,41 @@ def __init__(self, size, usage):
313313

314314
self.dedup = dedup
315315
self.savings = f"{savings:.2%}"
316+
317+
318+
class AntivirusUpdateSchedule(Object):
319+
"""
320+
Edge Filer Antivirus Update Schedule
321+
"""
322+
323+
@staticmethod
324+
def daily(hour, minute):
325+
"""
326+
Daily update.
327+
328+
:param int hour: Hour
329+
:param int minute: Minute
330+
"""
331+
return AntivirusUpdateSchedule(mode='daily', daily=Object(hour=hour, minute=minute))
332+
333+
@staticmethod
334+
def weekly(day, hour, minute):
335+
"""
336+
Weekly update.
337+
338+
:param cterasdk.common.enum.DayOfWeek day: Day
339+
:param int hour: Hour
340+
:param int minute: Minute
341+
"""
342+
return AntivirusUpdateSchedule(mode='weekly', weekly=Object(day=day, hour=hour, minute=minute))
343+
344+
@staticmethod
345+
def monthly(day, hour, minute):
346+
"""
347+
Monthly update.
348+
349+
:param int day: Day
350+
:param int hour: Hour
351+
:param int minute: Minute
352+
"""
353+
return AntivirusUpdateSchedule(mode='monthly', monthly=Object(day=day, hour=hour, minute=minute))

cterasdk/objects/synchronous/edge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ...lib.session.edge import Session
77

88
from ...edge import (
9-
afp, aio, array, audit, backup, cache, cli, config, connection, ctera_migrate,
9+
afp, aio, antivirus, array, audit, backup, cache, cli, config, connection, ctera_migrate,
1010
dedup, directoryservice, drive, files, firmware, ftp, groups, licenses, login,
1111
logs, mail, network, nfs, ntp, power, remote, rsync, ransom_protect, services,
1212
shares, shell, smb, snmp, ssh, ssl, support, sync, syslog, taskmgr, telnet,
@@ -75,6 +75,7 @@ def __init__(self, host=None, port=None, https=True, Portal=None, *, base=None):
7575
self._ctera_clients = Clients(self, Portal)
7676
self.afp = afp.AFP(self)
7777
self.aio = aio.AIO(self)
78+
self.antivirus = antivirus.Antivirus(self)
7879
self.array = array.Array(self)
7980
self.audit = audit.Audit(self)
8081
self.backup = backup.Backup(self)

docs/source/UserGuides/Edge/Configuration.rst

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,80 @@ Diagnostics
10201020
10211021
edge.network.iperf('192.168.1.145', protocol=edge_enum.IPProtocol.UDP) # Use UDP
10221022
1023+
1024+
Antivirus
1025+
=========
1026+
1027+
.. automethod:: cterasdk.edge.antivirus.Antivirus.enable
1028+
:noindex:
1029+
1030+
.. code-block:: python
1031+
1032+
edge.antivirus.settings.enable()
1033+
1034+
.. automethod:: cterasdk.edge.antivirus.Antivirus.disable
1035+
:noindex:
1036+
1037+
.. code-block:: python
1038+
1039+
edge.antivirus.settings.disable()
1040+
1041+
.. automethod:: cterasdk.edge.antivirus.Antivirus.update
1042+
:noindex:
1043+
1044+
.. code-block:: python
1045+
1046+
edge.antivirus.settings.update()
1047+
1048+
.. automethod:: cterasdk.edge.antivirus.Antivirus.status
1049+
:noindex:
1050+
1051+
.. code-block:: python
1052+
1053+
edge.antivirus.settings.status()
1054+
1055+
.. automethod:: cterasdk.edge.antivirus.Settings.get
1056+
:noindex:
1057+
1058+
.. code-block:: python
1059+
1060+
edge.antivirus.settings.get()
1061+
1062+
.. automethod:: cterasdk.edge.antivirus.Settings.update
1063+
:noindex:
1064+
1065+
.. code-block:: python
1066+
1067+
edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.daily(5, 0)) # Daily at 5:00 am
1068+
edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.weekly(common_enum.DayOfWeek.Tuesday, 2, 15)) # Tuesdays at 2:15 am
1069+
edge.antivirus.settings.update(edge_types.AntivirusUpdateSchedule.monthly(15, 15, 30)) # Every 15th at 3:30 pm
1070+
1071+
1072+
Ransomware Protection
1073+
=====================
1074+
1075+
.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.get_configuration
1076+
:noindex:
1077+
1078+
.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.enable
1079+
:noindex:
1080+
1081+
.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.disable
1082+
:noindex:
1083+
1084+
.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.is_disabled
1085+
:noindex:
1086+
1087+
.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.modify
1088+
:noindex:
1089+
1090+
.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.incidents
1091+
:noindex:
1092+
1093+
.. automethod:: cterasdk.edge.ransom_protect.RansomProtect.details
1094+
:noindex:
1095+
1096+
10231097
Mail Server
10241098
===========
10251099

docs/source/UserGuides/Miscellaneous/Changelog.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Changelog
77
Improvements
88
^^^^^^^^^^^^
99

10-
* Support retrieving, adding, and removing Edge Filer hosts file entries
10+
* Support retrieving, adding, and removing Edge Filer hosts file entries.
11+
* Add documentation for the Edge Filer Ransomware Protection APIs.
12+
* Add support for managing the Edge Filer's Antivirus (Bit Defender).
1113

1214
Bug Fixes
1315
^^^^^^^^^
@@ -17,7 +19,8 @@ Bug Fixes
1719

1820
Related issues and pull requests on GitHub: `#306 <https://github.com/ctera/ctera-python-sdk/pull/306>`_,
1921
`#307 <https://github.com/ctera/ctera-python-sdk/pull/307>`_,
20-
`#308 <https://github.com/ctera/ctera-python-sdk/pull/308>`_
22+
`#308 <https://github.com/ctera/ctera-python-sdk/pull/308>`_,
23+
`#309 <https://github.com/ctera/ctera-python-sdk/pull/309>`_
2124

2225

2326
2.20.14

0 commit comments

Comments
 (0)