Skip to content

Commit

Permalink
Merge pull request #73 from OWASP/72-feature-output-filter
Browse files Browse the repository at this point in the history
FEATURE: do not store errored requests into output file
  • Loading branch information
dmdhrumilmistry authored Apr 4, 2024
2 parents 708deca + dc86ea7 commit 231000c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/offat/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def start():
action='store_true',
help='Enable SSL Verification',
)
parser.add_argument(
'-cf',
'--capture-failed',
dest='capture_failed',
action='store_true',
help='Captures failed requests due to any exceptions into output file',
)
args = parser.parse_args()

# convert req headers str to dict
Expand Down Expand Up @@ -146,6 +153,7 @@ def start():
test_data_config=test_data_config,
proxies=args.proxies_list,
ssl=args.ssl,
capture_failed=args.capture_failed,
)


Expand Down
11 changes: 10 additions & 1 deletion src/offat/report/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,21 @@ def save_report(report_path: str | None, report_file_content: str | Table | None

@staticmethod
def generate_report(
results: list[dict], report_format: str | None, report_path: str | None
results: list[dict],
report_format: str | None,
report_path: str | None,
capture_failed: bool = False,
):
"""main function used to generate report"""
if report_path:
report_format = report_path.split('.')[-1]

# do not store errored results if `capture_failed` is False
if not capture_failed:
results = list(
filter(lambda result: result.get('error', True) == False, results)
)

formatted_results = ReportGenerator.handle_report_format(
results=results, report_format=report_format
)
Expand Down
1 change: 1 addition & 0 deletions src/offat/tester/tester_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def generate_and_run_tests(
proxies: list[str] | None = None,
test_data_config: dict | None = None,
ssl: bool = False,
capture_failed: bool = False,
):
'''
Generates and runs tests for provied OAS/Swagger file.
Expand Down

0 comments on commit 231000c

Please sign in to comment.