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
6 changes: 4 additions & 2 deletions packages/python3-nethsec/src/nethsec/inventory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,14 @@ def fact_rpcd_users(uci: EUci):
return { 'count': count }

def fact_threat_shield(uci: EUci):
ret = { 'enabled': False, 'community': 0, 'enterprise': 0, 'geoblocking': 0 }
ret = { 'enabled': False, 'community': 0, 'enterprise': 0, 'enterprise_feeds': [], 'geoblocking': 0 }
ret['enabled'] = uci.get('banip', 'global', 'ban_enabled', default='0') == '1'
try:
feeds = uci.get_all("banip", "global", "ban_feed")
for feed in feeds:
if feed.startswith("nethesis") or feed.startswith("yoroi"):
ret['enterprise'] += 1
ret['enterprise_feeds'].append(feed)
else:
ret['community'] += 1
if 'country' in feeds:
Expand All @@ -442,7 +443,7 @@ def fact_threat_shield(uci: EUci):
return ret

def fact_adblock(uci: EUci):
ret = { 'enabled': False, 'community': 0, 'enterprise': 0 }
ret = { 'enabled': False, 'community': 0, 'enterprise': 0, 'enterprise_feeds': [] }
ret['enabled'] = uci.get('adblock', 'global', 'ts_enabled', default='0') == '1'
try:
enabled_feeds = list(uci.get_all('adblock', 'global', 'adb_sources'))
Expand All @@ -451,6 +452,7 @@ def fact_adblock(uci: EUci):
for feed in enabled_feeds:
if feed.startswith("nethesis") or feed.startswith("yoroi"):
ret['enterprise'] += 1
ret['enterprise_feeds'].append(feed)
else:
ret['community'] += 1
return ret
Expand Down
4 changes: 2 additions & 2 deletions packages/python3-nethsec/tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def test_fact_rpcd_users(tmp_path):

def test_fact_threat_shield(tmp_path):
u = _setup_db(tmp_path)
assert inventory.fact_threat_shield(u) == {"enabled": True, "community": 1, "enterprise": 1, "geoblocking": 0}
assert inventory.fact_threat_shield(u) == {"enabled": True, "community": 1, "enterprise": 1, "enterprise_feeds": ["nethesislvl3"], "geoblocking": 0}

def test_fact_ui(tmp_path):
u = _setup_db(tmp_path)
Expand Down Expand Up @@ -989,7 +989,7 @@ def test_fact_firewall_stats(tmp_path):
def test_fact_adblock(tmp_path):
u = _setup_db(tmp_path)
result = inventory.fact_adblock(u)
assert result == {"enabled": True, "community": 5, "enterprise": 2}
assert result == {"enabled": True, "community": 5, "enterprise": 2, "enterprise_feeds": ["yoroi_susp_level2", "yoroi_malware_level1"]}

# Tests for info_* helper functions

Expand Down
Loading