Skip to content

Commit

Permalink
Merge pull request #55 from OWASP/dev
Browse files Browse the repository at this point in the history
Dev RELEASE: v0.15.3
  • Loading branch information
dmdhrumilmistry authored Feb 9, 2024
2 parents da33ef2 + f462e22 commit 66ac015
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 183 deletions.
5 changes: 5 additions & 0 deletions src/offat/parsers/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module to parse OAS v3 documentation JSON/YAML files.
'''
from .parser import BaseParser
from ..logger import logger


class InvalidOpenAPIv3File(Exception):
Expand All @@ -27,6 +28,10 @@ def __init__(self, file_or_url: str, spec: dict | None = None) -> None:
def _populate_hosts(self):
servers = self.specification.get('servers', [])
hosts = []
if not servers:
logger.error('Invalid Server Url: Server URLs are missing in spec file')
raise InvalidOpenAPIv3File('Server URLs Not Found in spec file')

for server in servers:
host = server.get('url', '').removeprefix(
'https://').removeprefix('http://').removesuffix('/')
Expand Down
2 changes: 1 addition & 1 deletion src/offat/parsers/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _populate_hosts(self):
host = self.specification.get('host')
if not host:
logger.error('Invalid Host: Host is missing')
raise ValueError('Host Not Found in spec file')
raise InvalidSwaggerFile('Host Not Found in spec file')
hosts = [host]
self.hosts = hosts
self.host = self.hosts[0]
Expand Down
Loading

0 comments on commit 66ac015

Please sign in to comment.