Skip to content

Commit

Permalink
Merge pull request #51 from OWASP/dev
Browse files Browse the repository at this point in the history
Dev RELEASE: v0.15.2
  • Loading branch information
dmdhrumilmistry authored Feb 3, 2024
2 parents 5f913f1 + ab53460 commit da33ef2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/offat/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
from requests import get as http_get
from json import loads as json_load, JSONDecodeError
from .openapi import OpenAPIv3Parser
from .swagger import SwaggerParser
from .parser import BaseParser
from ..utils import is_valid_url


def create_parser(fpath_or_url: str, spec: dict = None) -> SwaggerParser | OpenAPIv3Parser:
'''returns parser based on doc file'''
if fpath_or_url and is_valid_url(fpath_or_url):
res = http_get(fpath_or_url)
if res.status_code != 200:
raise ValueError(
f"server returned status code {res.status_code} offat expects 200 status code"
)
try:
spec = json_load(res.text)
fpath_or_url = None
except JSONDecodeError as e:
raise ValueError("Invalid json data spec file url")

parser = BaseParser(file_or_url=fpath_or_url, spec=spec)
if parser.is_v3:
return OpenAPIv3Parser(file_or_url=fpath_or_url, spec=spec)
Expand Down
7 changes: 3 additions & 4 deletions src/offat/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from json import loads as json_load, dumps as json_dumps, JSONDecodeError
# from pkg_resources import get_distribution
from pkg_resources import get_distribution
from os.path import isfile
from re import compile, match
from yaml import safe_load, YAMLError
from .logger import logger
from re import compile, match


def get_package_version():
Expand All @@ -15,8 +15,7 @@ def get_package_version():
Returns:
String: current package version
'''
# return get_distribution('offat').version
return 3
return get_distribution('offat').version


def read_yaml(file_path: str) -> dict:
Expand Down
18 changes: 17 additions & 1 deletion src/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "offat"
version = "0.15.1"
version = "0.15.2"
description = "Offensive API tester tool automates checks for common API vulnerabilities"
authors = ["Dhrumil Mistry <dhrumil.mistry@owasp.org>"]
license = "MIT"
Expand All @@ -18,6 +18,7 @@ python-dotenv = {version = "^1.0.0", optional = true}
rich = "^13.7.0"
aiolimiter = "^1.1.0"
openapi-spec-validator = "^0.7.1"
setuptools = "^69.0.3"

[tool.poetry.extras]
api = ["fastapi", "uvicorn", "redis", "rq", "python-dotenv"]
Expand Down

0 comments on commit da33ef2

Please sign in to comment.