Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions synology_dsm/api/core/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def update(self, raw_data):

@property
def checks(self):
"""Gets the checklist."""
"""Gets the checklist by check category."""
return self._data.get("items", {})

@property
Expand All @@ -43,5 +43,13 @@ def progress(self):

@property
def status(self):
"""Gets the last scan status (safe, ...)."""
"""Gets the last scan status (safe, danger, info, outOfDate, risk, warning)."""
return self._data.get("sysStatus")

@property
def status_by_check(self):
"""Gets the last scan status per check."""
status = {}
for category in self.checks:
status[category] = self.checks[category]["failSeverity"]
return status
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
DSM_6_CORE_UTILIZATION,
DSM_6_CORE_UTILIZATION_ERROR_1055,
DSM_6_CORE_SECURITY,
DSM_6_CORE_SECURITY_UPDATE_OUTOFDATE,
DSM_6_STORAGE_STORAGE_DS213_PLUS_SHR1_2DISKS_2VOLS,
DSM_6_STORAGE_STORAGE_DS918_PLUS_RAID5_3DISKS_1VOL,
DSM_6_STORAGE_STORAGE_DS1819_PLUS_SHR2_8DISKS_1VOL,
Expand Down Expand Up @@ -183,6 +184,8 @@ def _execute_request(self, method, url, params, **kwargs):
return API_SWITCHER[self.dsm_version]["DSM_NETWORK"]

if SynoCoreSecurity.API_KEY in url:
if self.error:
return DSM_6_CORE_SECURITY_UPDATE_OUTOFDATE
return API_SWITCHER[self.dsm_version]["CORE_SECURITY"]

if SynoCoreUtilization.API_KEY in url:
Expand Down
5 changes: 4 additions & 1 deletion tests/api_data/dsm_6/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
DSM_6_CORE_UTILIZATION,
DSM_6_CORE_UTILIZATION_ERROR_1055,
)
from .core.const_6_core_security import DSM_6_CORE_SECURITY
from .core.const_6_core_security import (
DSM_6_CORE_SECURITY,
DSM_6_CORE_SECURITY_UPDATE_OUTOFDATE,
)
from .dsm.const_6_dsm_info import DSM_6_DSM_INFORMATION
from .dsm.const_6_dsm_network import DSM_6_DSM_NETWORK
from .storage.const_6_storage_storage import (
Expand Down
103 changes: 103 additions & 0 deletions tests/api_data/dsm_6/core/const_6_core_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,106 @@
},
"success": True,
}

DSM_6_CORE_SECURITY_UPDATE_OUTOFDATE = {
"data": {
"items": {
"malware": {
"category": "malware",
"fail": {
"danger": 0,
"info": 0,
"outOfDate": 0,
"risk": 0,
"warning": 0,
},
"failSeverity": "safe",
"progress": 100,
"runningItem": "",
"total": 3,
"waitNum": 0,
},
"network": {
"category": "network",
"fail": {
"danger": 0,
"info": 0,
"outOfDate": 0,
"risk": 0,
"warning": 0,
},
"failSeverity": "safe",
"progress": 100,
"runningItem": "",
"total": 4,
"waitNum": 0,
},
"securitySetting": {
"category": "securitySetting",
"fail": {
"danger": 0,
"info": 0,
"outOfDate": 0,
"risk": 0,
"warning": 0,
},
"failSeverity": "safe",
"progress": 100,
"runningItem": "",
"total": 0,
"waitNum": 0,
},
"systemCheck": {
"category": "systemCheck",
"fail": {
"danger": 0,
"info": 0,
"outOfDate": 0,
"risk": 0,
"warning": 0,
},
"failSeverity": "safe",
"progress": 100,
"runningItem": "",
"total": 6,
"waitNum": 0,
},
"update": {
"category": "update",
"fail": {
"danger": 0,
"info": 0,
"outOfDate": 1,
"risk": 0,
"warning": 0,
},
"failSeverity": "outOfDate",
"progress": 100,
"runningItem": "",
"total": 4,
"waitNum": 0,
},
"userInfo": {
"category": "userInfo",
"fail": {
"danger": 0,
"info": 0,
"outOfDate": 0,
"risk": 0,
"warning": 0,
},
"failSeverity": "safe",
"progress": 100,
"runningItem": "",
"total": 6,
"waitNum": 0,
},
},
"lastScanTime": "1590717640",
"startTime": "",
"success": True,
"sysProgress": 100,
"sysStatus": "outOfDate",
},
"success": True,
}
Loading