Skip to content

Commit 4704b92

Browse files
author
Prabhu Subramanian
committed
Enhance log for promoting risk audit
1 parent 834018a commit 4704b92

File tree

4 files changed

+34
-37
lines changed

4 files changed

+34
-37
lines changed

depscan/cli.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import sys
77

8+
from rich.panel import Panel
89
from vdb.lib import config as config
910
from vdb.lib import db as dbLib
1011
from vdb.lib.gha import GitHubSource
@@ -23,7 +24,7 @@
2324
from depscan.lib.bom import create_bom, get_pkg_list
2425
from depscan.lib.config import license_data_dir
2526
from depscan.lib.license import build_license_data, bulk_lookup
26-
from depscan.lib.logger import LOG
27+
from depscan.lib.logger import LOG, console
2728

2829
at_logo = """
2930
___ _____ _ _
@@ -266,18 +267,30 @@ def main():
266267
reports_dir, "license-" + project_type + ".json"
267268
)
268269
analyse_licenses(project_type, licenses_results, license_report_file)
269-
if args.risk_audit and project_type in risk_audit_map.keys():
270-
LOG.info(
271-
f"Performing package risk audit for {src_dir} of type {project_type}"
272-
)
273-
LOG.debug(f"No of packages {len(pkg_list)}. This will take a while ...")
274-
try:
275-
risk_results = risk_audit(project_type, pkg_list, risk_report_file)
276-
analyse_pkg_risks(project_type, risk_results, risk_report_file)
277-
except Exception as e:
278-
LOG.error("Risk audit was not successful")
279-
LOG.error(e)
280-
risk_results = None
270+
if project_type in risk_audit_map.keys():
271+
if args.risk_audit:
272+
console.print(
273+
Panel(
274+
f"Performing OSS Risk Audit for packages from {src_dir}\nNo of packages [bold]{len(pkg_list)}[/bold]. This will take a while ...",
275+
title="OSS Risk Audit",
276+
expand=False,
277+
)
278+
)
279+
try:
280+
risk_results = risk_audit(project_type, pkg_list, risk_report_file)
281+
analyse_pkg_risks(project_type, risk_results, risk_report_file)
282+
except Exception as e:
283+
LOG.error("Risk audit was not successful")
284+
LOG.error(e)
285+
risk_results = None
286+
else:
287+
console.print(
288+
Panel(
289+
"Depscan supports OSS Risk audit for this project.\nTo enable set the environment variable [bold]ENABLE_OSS_RISK=true[/bold]",
290+
title="New Feature",
291+
expand=False,
292+
)
293+
)
281294
if project_type in type_audit_map.keys():
282295
LOG.info(
283296
"Performing remote audit for {} of type {}".format(

depscan/lib/analysis.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,15 @@
11
# -*- coding: utf-8 -*-
22

33
import json
4-
import logging
54

65
from rich import box
7-
from rich.console import Console
8-
from rich.logging import RichHandler
96
from rich.panel import Panel
107
from rich.table import Table
11-
from rich.theme import Theme
128

139
from depscan.lib import config as config
10+
from depscan.lib.logger import LOG, console
1411
from depscan.lib.utils import max_version
1512

16-
custom_theme = Theme({"info": "cyan", "warning": "purple4", "danger": "bold red"})
17-
console = Console(
18-
log_time=False,
19-
log_path=False,
20-
theme=custom_theme,
21-
width=200,
22-
color_system="256",
23-
force_terminal=True,
24-
)
25-
26-
logging.basicConfig(
27-
level=logging.INFO,
28-
format="%(message)s",
29-
datefmt="[%X]",
30-
handlers=[RichHandler(console=console, show_path=False, enable_link_path=False)],
31-
)
32-
LOG = logging.getLogger(__name__)
33-
3413

3514
def print_results(project_type, results, pkg_aliases, sug_version_dict, scoped_pkgs):
3615
"""Pretty print report summary"""

depscan/lib/logger.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222

2323
custom_theme = Theme({"info": "cyan", "warning": "purple4", "danger": "bold red"})
2424
console = Console(
25-
log_time=False, log_path=False, theme=custom_theme, width=140, color_system="256"
25+
log_time=False,
26+
log_path=False,
27+
theme=custom_theme,
28+
width=200,
29+
color_system="256",
30+
force_terminal=True,
2631
)
2732

2833
logging.basicConfig(

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="appthreat-depscan",
8-
version="1.11.1",
8+
version="1.11.2",
99
author="Team AppThreat",
1010
author_email="[email protected]",
1111
description="Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.",

0 commit comments

Comments
 (0)