-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from Santandersecurityresearch/dev
Adds CLI tool
- Loading branch information
Showing
14 changed files
with
374 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*.pyc | ||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
docs/_static/* | ||
!docs/_static/.keep | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
.DS_Store | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# jetbrains | ||
.idea/ | ||
|
||
# junit reports folder | ||
reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
################################################## | ||
# Santander UK Security Engineering team. | ||
################################################## | ||
# MIT License Copyright (c) 2021 Grupo Santander | ||
################################################## | ||
# Author: Javier Dominguez Ruiz (@javixeneize) | ||
# Version: 1.0 | ||
################################################## | ||
|
||
import corsair_scan.corsair_scan as corsair | ||
import click | ||
import json | ||
import sys | ||
|
||
|
||
def get_data_from_file(filename): | ||
try: | ||
with open(filename) as f: | ||
try: | ||
data = json.loads(f.read()) | ||
if type(data) == dict: | ||
datalist = [] | ||
datalist.append(data) | ||
return datalist | ||
else: | ||
return data | ||
except json.decoder.JSONDecodeError: | ||
print('Error. The format does not appear to be correct, please review') | ||
sys.exit(2) | ||
except FileNotFoundError: | ||
print('Error. File not found') | ||
sys.exit(2) | ||
|
||
|
||
@click.command() | ||
@click.argument('file', required=True) | ||
@click.option('-nv', '--noverify', 'verify', help='Skips security certificate check', is_flag=True, default=True) | ||
@click.option('-r', '--report', 'report', help='Saves the report in a JSON file') | ||
def run_cli_scan(file, verify, report): | ||
"""Corsair CLI requires as parameter a file in JSON format with the data to run the scan. | ||
This data can be a single request, or a list of requests""" | ||
data = get_data_from_file(file) | ||
corsair_report = corsair.corsair_scan(data, verify) | ||
if corsair_report.get('report'): | ||
if report: | ||
with open(report, 'w') as file: | ||
file.write(json.dumps(corsair_report)) | ||
print("Report generated in {}".format(report)) | ||
else: | ||
print(corsair_report) | ||
else: | ||
print("There was an error running corsair. Please check the input data is correct") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
validators>=0.14.3 | ||
requests>=2.23.0 | ||
urllib3>=1.25.9 | ||
tldextract>=2.2.3 | ||
urllib3>=1.26.4 | ||
tldextract>=2.2.3 | ||
click>=7.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
validators>=0.14.3 | ||
requests>=2.23.0 | ||
urllib3>=1.25.9 | ||
urllib3>=1.26.4 | ||
mock>=4.0.2 | ||
pytest==3.8.2 | ||
pytest-cov==2.5.1 | ||
pytest==6.2.4 | ||
pytest-cov==2.12.0 | ||
wheel | ||
tldextract>=2.2.3 | ||
flake8==3.7.9 | ||
bandit==1.6.2 | ||
safety==1.8.7 | ||
bump2version==1.0.0 | ||
twine==3.1.1 | ||
flake8==3.9.2 | ||
bandit==1.7.0 | ||
safety==1.10.3 | ||
bump2version==1.0.1 | ||
twine==3.4.1 | ||
click>=7.1.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
35428a7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No weaknesses detected by Fortify Commit Scan in the changed file(s) - keep up the secure coding!
And be sure to incorporate a comprehensive Fortify Static scan (covering 800+ vulnerability categories and advanced detection algorithms) and a Fortify Dynamic scan into your CI/CD pipeline.