From aa954dc84cd5e022594f06cc1c8ce7206b985d63 Mon Sep 17 00:00:00 2001 From: Kota Kanbe Date: Thu, 14 Jan 2021 08:12:35 +0900 Subject: [PATCH] fix(scan): kindness msg when no-cache err on dnf mod list (#1128) --- scan/redhatbase.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scan/redhatbase.go b/scan/redhatbase.go index 17d8c9ac..4e6102b3 100644 --- a/scan/redhatbase.go +++ b/scan/redhatbase.go @@ -710,7 +710,10 @@ func (o *redhatBase) detectEnabledDnfModules() ([]string, error) { cmd := `dnf --cacheonly --color=never --quiet module list --enabled` r := o.exec(util.PrependProxyEnv(cmd), noSudo) if !r.isSuccess() { - return nil, xerrors.Errorf("Failed to dnf module list: %s, cmd: %s", r, cmd) + if strings.Contains(r.Stdout, "Cache-only enabled but no cache") { + return nil, xerrors.Errorf("sudo yum check-update to make local cache before scanning: %s", r) + } + return nil, xerrors.Errorf("Failed to dnf module list: %s", r) } return o.parseDnfModuleList(r.Stdout) }