Skip to content

Commit

Permalink
Hot fix: Be more bulletproof about domain names
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Jun 4, 2021
1 parent 36c73bc commit 233dc03
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions infracheck/checks/tls-docker-network
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,24 @@ class TlsDockerNetworkCheck(object):
domain_sep = sep[1].split(',')

for domain in domain_sep:
domain = self.purify_domain_name(domain)

if not domain:
print(f' Warning: Empty domain in {container} ')
continue

domains.append((domain, 443))

elif self.param_type == ParamTypes.LABEL.value:
domain_sep = container.attrs['Config']['Labels'][self.param_name].split(',')

for domain in domain_sep:
domain = self.purify_domain_name(domain)

if not domain:
print(f' Warning: Empty domain in {container} ')
continue

domains.append((domain, 443))

except KeyError as err:
Expand All @@ -118,6 +130,14 @@ class TlsDockerNetworkCheck(object):
def is_debug_mode() -> bool:
return os.getenv('DEBUG', 'false').lower() == 'true'

@staticmethod
def purify_domain_name(domain: str) -> str:
"""
Strip quotes and blank characters - who knows what docker daemon returns, and what were defined in containers
"""

return domain.strip('"\'').strip()


if __name__ == '__main__':
app = TlsDockerNetworkCheck(
Expand Down

0 comments on commit 233dc03

Please sign in to comment.