Skip to content

Commit

Permalink
Resolving an issue with invalid macaddr (#166)
Browse files Browse the repository at this point in the history
* Resolving an issue with invalid macaddr

Signed-off-by: DerekRushton <[email protected]>

* Expanded on the comment.

Signed-off-by: DerekRushton <[email protected]>

---------

Signed-off-by: DerekRushton <[email protected]>
  • Loading branch information
DerekRushton authored Jul 16, 2024
1 parent 57c0f1d commit 13ce271
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion connectors/qualys/connector/data_handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import re
from html2text import html2text
from car_framework.context import context
from car_framework.data_handler import BaseDataHandler
Expand Down Expand Up @@ -253,7 +254,9 @@ def handle_macaddress(self, obj):
for interface in network_interface['list']:
res = self.copy_fields(obj, )
key = interface['HostAssetInterface'].get('macAddress', "")
if not key:
#Added a check on the mac address to ensure it's a valid format.
#If performance issues show up, we can match on only not "null", but this covers additional cases.
if not key or not re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", key.lower()):
continue
res['_key'] = key
res['interface'] = interface['HostAssetInterface'].get('interfaceName', "")
Expand Down
11 changes: 10 additions & 1 deletion connectors/qualys/tests/mock_api/host_asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
"hostname": "EC2AMZ",
"address": "fe80:0:0:0:f558:672:7853:f978",
"interfaceName": "AWS PV Network Device #0",
"macAddress": "77:71:7D:72:77:77"
"macAddress": "77:77:77:77:77:77"
}
},
{
"HostAssetInterface": {
"gatewayAddress": "177.77.77.7",
"hostname": "EC2AMZ",
"address": "fe80:0:0:0:f558:672:7853:f978",
"interfaceName": "AWS PV Network Device #0",
"macAddress": "null"
}
}]
},
Expand Down

0 comments on commit 13ce271

Please sign in to comment.