From 1dc39621998457ab09765520f6cce4e266eaa8db Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sat, 5 Oct 2019 07:03:41 -0400 Subject: changed some of blocked files logging --- src/sanitychecks.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/sanitychecks.cpp b/src/sanitychecks.cpp index 5f9705b8..185b1f9c 100644 --- a/src/sanitychecks.cpp +++ b/src/sanitychecks.cpp @@ -14,7 +14,7 @@ enum class SecurityZone Untrusted = 4, }; -QString toString(SecurityZone z) +QString toCodeName(SecurityZone z) { switch (z) { @@ -24,10 +24,17 @@ QString toString(SecurityZone z) case SecurityZone::Trusted: return "Trusted"; case SecurityZone::Internet: return "Internet"; case SecurityZone::Untrusted: return "Untrusted"; - default: return QString("unknown (%1)").arg(static_cast(z)); + default: return "Unknown"; } } +QString toString(SecurityZone z) +{ + return QString("%1 (%2)") + .arg(toCodeName(z)) + .arg(static_cast(z)); +} + bool isZoneBlocked(SecurityZone z) { return (z == SecurityZone::Internet || z == SecurityZone::Untrusted); @@ -46,18 +53,18 @@ bool isFileBlocked(const QFileInfo& fi) return false; } - log::debug("file '{}' has an ADS for {}", path, adsPath); + log::debug("'{}' has an ADS for {}", path, adsPath); - QSettings qs(adsPath, QSettings::IniFormat); + const QSettings qs(adsPath, QSettings::IniFormat); if (!qs.contains(key)) { - log::debug("but key '{}' is not found", key); + log::debug("'{}': key '{}' not found", adsPath, key); return false; } const auto v = qs.value(key); if (v.isNull()) { - log::debug("but key '{}' is null", key); + log::debug("'{}': key '{}' is null", adsPath, key); return false; } @@ -65,25 +72,16 @@ bool isFileBlocked(const QFileInfo& fi) const auto z = static_cast(v.toInt(&ok)); if (!ok) { - log::debug( - "but key '{}' is not an int (value is '{}')", - key, v); - + log::debug("'{}': key '{}' is not an int (value is '{}')", adsPath, key, v); return false; } if (!isZoneBlocked(z)) { - log::debug( - "but zone id is {}, {}, which is fine", - static_cast(z), toString(z)); - + log::debug("'{}': zone id is {}, which is fine", adsPath, toString(z)); return false; } - log::warn( - "file '{}' is blocked (zone id is {}, {})", - path, static_cast(z), toString(z)); - + log::warn("'{}': file is blocked (zone id is {})", path, toString(z)); return true; } @@ -141,7 +139,8 @@ void checkMissingFiles() const auto dir = QCoreApplication::applicationDirPath(); for (const auto& name : files) { - const QFileInfo file(dir + QDir::separator() + name); + const QFileInfo file(dir + "/" + name); + if (!file.exists()) { log::warn( "'{}' seems to be missing, an antivirus may have deleted it", @@ -168,6 +167,8 @@ void checkNahimic(const env::Environment& e) void sanityChecks(const env::Environment& e) { + log::debug("running sanity checks"); + checkBlocked(); checkMissingFiles(); checkNahimic(e); -- cgit v1.3.1