From 8ccee53604af9b785d54078d9445b2a923fae4bf Mon Sep 17 00:00:00 2001 From: Dhrumil Mistry <56185972+dmdhrumilmistry@users.noreply.github.com> Date: Sun, 4 Feb 2024 01:46:22 +0530 Subject: [PATCH] api fixes --- src/.env.sample | 3 +++ src/offat/api/app.py | 6 +++--- src/offat/api/jobs.py | 5 ++--- src/offat/parsers/__init__.py | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 src/.env.sample diff --git a/src/.env.sample b/src/.env.sample new file mode 100644 index 0000000..859d8f9 --- /dev/null +++ b/src/.env.sample @@ -0,0 +1,3 @@ +REDIS_HOST=localhost +REDIS_PORT=6379 +AUTH_SECRET_KEY=E8f_3pHCgScOxTvyYFa1LKeJWLa4KtPKLY.FyLzesj66nHxQ5h1qhCFMQJJ_9eUL56EL3._XbYrYY8c5.foTV_yYHKcySPzBwv8FxIA1p03RFEinbex4EYZ9YvhacAiW diff --git a/src/offat/api/app.py b/src/offat/api/app.py index 416b240..0880b42 100644 --- a/src/offat/api/app.py +++ b/src/offat/api/app.py @@ -3,7 +3,7 @@ from offat.api.jobs import scan_api from offat.api.models import CreateScanModel from offat.logger import logger -from os import uname, environ +# from os import uname, environ logger.info('Secret Key: %s', auth_secret_key) @@ -17,8 +17,8 @@ async def root(): return { "name": "OFFAT API", - "project": "https://github.com/dmdhrumilmistry/offat", - "license": "https://github.com/dmdhrumilmistry/offat/blob/main/LICENSE", + "project": "https://github.com/OWASP/offat", + "license": "https://github.com/OWASP/offat/blob/main/LICENSE", } diff --git a/src/offat/api/jobs.py b/src/offat/api/jobs.py index 117a369..1dd69ba 100644 --- a/src/offat/api/jobs.py +++ b/src/offat/api/jobs.py @@ -1,20 +1,19 @@ from sys import exc_info from offat.api.models import CreateScanModel from offat.tester.tester_utils import generate_and_run_tests -from offat.parsers import OpenAPIParser +from offat.parsers import create_parser from offat.logger import logger def scan_api(body_data: CreateScanModel): try: - api_parser = OpenAPIParser(fpath_or_url=None, spec=body_data.openAPI) + api_parser = create_parser(fpath_or_url=None, spec=body_data.openAPI) results = generate_and_run_tests( api_parser=api_parser, regex_pattern=body_data.regex_pattern, req_headers=body_data.req_headers, rate_limit=body_data.rate_limit, - delay=body_data.delay, test_data_config=body_data.test_data_config, ) return results diff --git a/src/offat/parsers/__init__.py b/src/offat/parsers/__init__.py index 5deb40c..ab044cb 100644 --- a/src/offat/parsers/__init__.py +++ b/src/offat/parsers/__init__.py @@ -3,10 +3,10 @@ from .parser import BaseParser -def create_parser(fpath_or_url: str) -> SwaggerParser | OpenAPIv3Parser: +def create_parser(fpath_or_url: str, spec: dict = None) -> SwaggerParser | OpenAPIv3Parser: '''returns parser based on doc file''' - parser = BaseParser(file_or_url=fpath_or_url) + parser = BaseParser(file_or_url=fpath_or_url, spec=spec) if parser.is_v3: - return OpenAPIv3Parser(file_or_url=fpath_or_url) + return OpenAPIv3Parser(file_or_url=fpath_or_url, spec=spec) - return SwaggerParser(fpath_or_url=fpath_or_url) + return SwaggerParser(fpath_or_url=fpath_or_url, spec=spec)