Skip to content

Commit

Permalink
vendor_update plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Sep 18, 2023
1 parent 12b89f7 commit 1395dd9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion front/plugins/vendor_update/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Overview

Plugin to run regular database cleanup tasks. It is strongly recommended to have an hourly or at least daily schedule running.
A plugin to retrieve a MAC and vendor database to identify vendors for devices.

### Usage

Expand Down
3 changes: 2 additions & 1 deletion pialert/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
apiPath = pialertPath + '/front/api/'
fullConfPath = pialertPath + confPath
fullDbPath = pialertPath + dbPath
vendorsPath = '/usr/share/arp-scan/ieee-oui.txt'
vendorsPath6 = '/usr/share/arp-scan/ieee-oui.txt'
vendorsPath9 = '/usr/share/arp-scan/ieee-iab.txt'



Expand Down
18 changes: 13 additions & 5 deletions pialert/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from helper import timeNowTZ, get_setting, get_setting_value,resolve_device_name_dig, resolve_device_name_pholus
from scanners.internet import check_IP_format, get_internet_IP
from logger import mylog, print_log
from const import vendorsPath
from const import vendorsPath6, vendorsPath9

#-------------------------------------------------------------------------------

Expand Down Expand Up @@ -328,14 +328,22 @@ def query_MAC_vendor (pMAC):
return -2 # return -2 if ignored MAC

# Search vendor in HW Vendors DB
mac_start_string = mac[0:6]
mac_start_string6 = mac[0:6]
mac_start_string9 = mac[0:9]

try:
with open(vendorsPath, 'r') as f:
with open(vendorsPath6, 'r') as f:
for line in f:
if line.startswith(mac_start_string):
if line.startswith(mac_start_string6):
vendor = line.split(' ', 1)[1].strip()
mylog('debug', [f"[Vendor Check] Found '{vendor}' for '{pMAC}'"])
mylog('debug', [f"[Vendor Check] Found '{vendor}' for '{pMAC}' in {vendorsPath6}"])
return vendor

with open(vendorsPath9, 'r') as f:
for line in f:
if line.startswith(mac_start_string9):
vendor = line.split(' ', 1)[1].strip()
mylog('debug', [f"[Vendor Check] Found '{vendor}' for '{pMAC}' in {vendorsPath9}"])
return vendor

return -1 # MAC address not found in the database
Expand Down
3 changes: 3 additions & 0 deletions pialert/initialise.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def importConfigs (db):

# Header
updateState("Import config", showSpinner = True)

# remove all plugin langauge strings
sql.execute("DELETE FROM Plugins_Language_Strings;")

mylog('debug', ['[Import Config] importing config file'])
conf.mySettings = [] # reset settings
Expand Down

0 comments on commit 1395dd9

Please sign in to comment.