diff --git a/docs/tutorial.md b/docs/tutorial.md index c194951..cf27bd2 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -13,7 +13,8 @@ The griffon dotfile (_~/.griffonrc_) allows the user to configure operation of g [default] format = text history_log = ~/.griffon/history.log -default_profile = latest +profile = latest +verbosity = 0 [client] sfm2_api_url = http://localhost:5600 @@ -107,7 +108,6 @@ Commands: report-entities Generate Entity report (with counts). ``` - #### Check what Products a Component is shipped in To find what Products a component exists in @@ -120,15 +120,19 @@ Use regex expressions > griffon service products-contain-component "^webkitgtk(\d)$" Use of -v (up to -vvvv) to get more information +```commandline > griffon service products-contain-component "^webkitgtk(\d)" > griffon -v service products-contain-component "^webkitgtk(\d)" > griffon -vv service products-contain-component "^webkitgtk(\d)" > griffon -vvv service products-contain-component "^webkitgtk(\d)" > griffon -vvvv service products-contain-component "^webkitgtk(\d)" +``` Find what Products a component exists in, searching both root components and all dependencies +```commandline > griffon service products-contain-component webkitgtk --search-all > griffon service products-contain-component github.com/go-redis/redis/v8/internal/hscan --search-all +``` Find Products that contain Component searching both latest components and related_url > griffon service products-contain-component webkitgtk --search-latest --search-related-url @@ -147,7 +151,7 @@ To add (missing) affects on a flaw, supply sfm flaw id and set flaw mode to 'add To replace affects on a flaw (and overwrite any existing) supply sfm flaw id and set flaw mode to 'replace: > griffon service products-contain-component -s IPMItool --sfm2-flaw-id 2009389 --flaw-mode replace -#### Retrieving product and component manifests +#### Retrieving Product and Component manifests Retrieve a Product latest root Components > griffon service product-components rhel-9.0.0.z @@ -161,11 +165,13 @@ Retrieve a spdx json formatted Product manifest Retrieve a specific component manifest > griffon service component-manifest --purl "pkg:oci/ubi8-minimal-container@sha256:7679eaafa608171dd159a91529804d06fa0fbc16a2ea7f046a592a5d8e22c649?repository_url=registry.redhat.io/ubi8-minimal&tag=8.8-315" --spdx-json -#### Retrieving product and component summaries +#### Retrieving Product and Component summaries Retrieve a Product summary +```commandline > griffon service product-summary -s rhel-7.6.z > griffon --format json service product-summary -s rhel-7.6.z +``` Retrieve Component summary > griffon service component-summary python-marshmallow @@ -268,8 +274,10 @@ Commands: #### go_vuln Search go vulnerability database +```commandline > griffon plugins go_vuln get --id GO-2022-0189 > griffon plugins go_vuln get --cve-id CVE-2018-16873 +``` #### osv Search osv.dev @@ -292,8 +300,10 @@ Given a CVE ID, what components are affected? What products + version + stream contain a given component (e.g. full text search)? +```commandline > griffon service products-contain-component --purl "pkg:rpm/curl@7.15.5" > griffon service products-contain-component is-svg --search-all +``` Which unfixed CVE are affecting a component ? > griffon service component-flaws --affectedness AFFECTED webkitgtk diff --git a/griffon/cli.py b/griffon/cli.py index fa3bdea..f4b407f 100644 --- a/griffon/cli.py +++ b/griffon/cli.py @@ -109,6 +109,7 @@ def plugins_grp(ctx): "-v", "verbose", count=True, + default=griffon_config.getint("default", "verbosity"), help="Verbose output, more detailed search results, can be used multiple times (e.g. -vvv).", ) # noqa @click.option("--no-progress-bar", is_flag=True, help="Disable progress bar.") @@ -117,7 +118,7 @@ def plugins_grp(ctx): "--profile", "profile", type=click.Choice(["cloud", "openshift", "middleware", "latest", "all"]), - default=griffon_config.get("default", "default_profile"), + default=griffon_config.get("default", "profile"), help="Activate profile, defined in .griffonrc.", ) @click.pass_context @@ -140,6 +141,7 @@ def cli(ctx, debug, format, verbose, no_progress_bar, no_color, profile): ctx.obj["NO_PROGRESS_BAR"] = no_progress_bar ctx.obj["NO_COLOR"] = no_color ctx.obj["PROFILE"] = profile + ctx.obj["SHORT_VERSION_VALUES"] = True cli.help = "Red Hat Product Security CLI" diff --git a/griffon/output.py b/griffon/output.py index 124bdee..5302819 100644 --- a/griffon/output.py +++ b/griffon/output.py @@ -79,6 +79,12 @@ def component_type_style(type): return f"[{color}]{type}[/{color}]" +def output_version(ctx, version): + if version.startswith("sha256") and ctx.obj["SHORT_VERSION_VALUES"]: + return f"sha256 ...{version[-8:]}" + return version + + def text_output_product_summary(ctx, output, format, exclude_products): ordered_results = sorted(output["results"], key=lambda d: d["name"]) @@ -236,7 +242,9 @@ def text_output_products_contain_component(ctx, output, format, exclude_products root_component = "root component" if sources: source_purl = PackageURL.from_string(sources[0]["purl"]) - root_component = f"{source_purl.name}-{source_purl.version}" + root_component = ( + f"{source_purl.name}-{output_version(ctx,source_purl.version)}" + ) dep_name = name.replace(component_name, f"[b]{component_name}[/b]") dep = f"[white]({dep_name}, {item['type'].lower()})[/white]" @@ -274,7 +282,9 @@ def text_output_products_contain_component(ctx, output, format, exclude_products root_component = "root component" if sources: source_purl = PackageURL.from_string(sources[0]["purl"]) - root_component = f"{source_purl.name}-{source_purl.version}" + root_component = ( + f"{source_purl.name}-{output_version(ctx,source_purl.version)}" + ) dep_name = nvr.replace(component_name, f"[b]{component_name}[/b]") dep = f"[white]({dep_name}, {item['type'].lower()})[/white]" related_url = related_url.replace( @@ -314,7 +324,9 @@ def text_output_products_contain_component(ctx, output, format, exclude_products root_component = "root component" if sources: source_purl = PackageURL.from_string(sources[0]["purl"]) - root_component = f"{source_purl.name}-{source_purl.version}" + root_component = ( + f"{source_purl.name}-{output_version(ctx,source_purl.version)}" + ) upstream = "" if item["upstream_purl"]: upstream = f"[cyan]{item['upstream_purl']}[/cyan]" diff --git a/griffon/static/default_griffonrc b/griffon/static/default_griffonrc index 77e5586..52f371f 100644 --- a/griffon/static/default_griffonrc +++ b/griffon/static/default_griffonrc @@ -1,7 +1,8 @@ [default] format = text history_log = ~/.griffon/history.log -default_profile = latest +profile = all +verbosity = 0 [client] sfm2_api_url = http://localhost:5600