Skip to content

Commit

Permalink
api fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmdhrumilmistry committed Feb 3, 2024
1 parent 3269026 commit 8ccee53
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REDIS_HOST=localhost
REDIS_PORT=6379
AUTH_SECRET_KEY=E8f_3pHCgScOxTvyYFa1LKeJWLa4KtPKLY.FyLzesj66nHxQ5h1qhCFMQJJ_9eUL56EL3._XbYrYY8c5.foTV_yYHKcySPzBwv8FxIA1p03RFEinbex4EYZ9YvhacAiW
6 changes: 3 additions & 3 deletions src/offat/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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",
}


Expand Down
5 changes: 2 additions & 3 deletions src/offat/api/jobs.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/offat/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 8ccee53

Please sign in to comment.