Beispiel #1
0
    def test_review_from_file(self):
        dirname = os.path.dirname(__file__)
        path_to_report = os.path.join(dirname, "test_db", "example_report.json")
        with open(path_to_report) as insecure:
            input_vulns = read_vulnerabilities(insecure)

        vulns = safety.review(input_vulns)
        self.assertEqual(len(vulns), 3)
Beispiel #2
0
def review(full_report, bare, file):
    if full_report and bare:
        click.secho("Can't choose both --bare and --full-report/--short-report", fg="red")
        sys.exit(-1)

    try:
        input_vulns = read_vulnerabilities(file)
    except JSONDecodeError:
        click.secho("Not a valid JSON file", fg="red")
        sys.exit(-1)

    vulns = safety.review(input_vulns)
    output_report = report(vulns=vulns, full=full_report, bare_report=bare)
    click.secho(output_report, nl=False if bare and not vulns else True)