Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #107 from RedHatProductSecurity/revert-back-to-all…
Browse files Browse the repository at this point in the history
…-profile-default

Revert back to all profile default
  • Loading branch information
JimFuller-RedHat authored Mar 19, 2023
2 parents 550ab34 + 2c87fb1 commit fe9e60a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
18 changes: 14 additions & 4 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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/[email protected]"
> griffon service products-contain-component is-svg --search-all
```

Which unfixed CVE are affecting a component ?
> griffon service component-flaws --affectedness AFFECTED webkitgtk
Expand Down
4 changes: 3 additions & 1 deletion griffon/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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
Expand All @@ -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"
18 changes: 15 additions & 3 deletions griffon/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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]"
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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]"
Expand Down
3 changes: 2 additions & 1 deletion griffon/static/default_griffonrc
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit fe9e60a

Please sign in to comment.