Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev RELEASE: v0.15.2 #51

Merged
merged 4 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading