Skip to content

Commit

Permalink
exclude docker tmp interface names
Browse files Browse the repository at this point in the history
  • Loading branch information
joente committed Dec 18, 2023
1 parent 9637a7d commit c56622f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions lib/check/interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from asyncsnmplib.mib.mib_index import MIB_INDEX
from collections import Counter
from libprobe.asset import Asset
Expand Down Expand Up @@ -75,6 +76,10 @@
'cplane'
)

ExcludeIfMatch = (
re.compile('^docker[0-9a-f]{7}$'),
)

# Address and prefixes matching these prefixes will be absolutely filtered
ReservedAddresses = (
'00:00:01:00:00:01', # Problematic XEROX CORPORATION MACs
Expand Down Expand Up @@ -136,6 +141,13 @@
)


def should_exclude_name(name: str) -> bool:
return (
any(name.startswith(e) for e in ExcludedIfDescStartsWith) or
any(e in name for e in ExcludedIfDescContains) or
any(r.match(name) for r in ExcludeIfMatch))


async def check_interface(
asset: Asset,
asset_config: dict,
Expand Down Expand Up @@ -170,9 +182,7 @@ async def check_interface(
raise CheckException(
f'Missing ifDesc OID for creating an interface name{suggest}')

if not include_all and (
any(name.startswith(e) for e in ExcludedIfDescStartsWith) or
any(e in name for e in ExcludedIfDescContains)):
if not include_all and should_exclude_name(name):
continue

idx = counts[name]
Expand Down
2 changes: 1 addition & 1 deletion lib/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version string. Examples:
# '3.0.0'
# '3.0.0-alpha9'
__version__ = '3.0.6'
__version__ = '3.0.7-alpha0'

0 comments on commit c56622f

Please sign in to comment.