[libcalamares] Add Redacted logging
- this was an internal class for logging commands, let's lift it up to the Logger framework where it might be more generally useful (or not .. everything needs special-casing for actual redaction).
This commit is contained in:
parent
f0104af1c3
commit
85debfc69b
@ -228,4 +228,28 @@ toString( const QVariant& v )
|
||||
}
|
||||
}
|
||||
|
||||
QDebug&
|
||||
operator<<( QDebug& s, const Redacted& l )
|
||||
{
|
||||
// Special case logging: don't log the (encrypted) password.
|
||||
if ( l.list.contains( "usermod" ) )
|
||||
{
|
||||
for ( const auto& item : l.list )
|
||||
if ( item.startsWith( "$6$" ) )
|
||||
{
|
||||
s << "<password>";
|
||||
}
|
||||
else
|
||||
{
|
||||
s << item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s << l.list;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace Logger
|
||||
|
@ -207,6 +207,25 @@ public:
|
||||
const QVariantMap& map;
|
||||
};
|
||||
|
||||
/** @brief When logging commands, don't log everything.
|
||||
*
|
||||
* The command-line arguments to some commands may contain the
|
||||
* encrypted password set by the user. Don't log that password,
|
||||
* since the log may get posted to bug reports, or stored in
|
||||
* the target system.
|
||||
*/
|
||||
struct Redacted
|
||||
{
|
||||
Redacted( const QStringList& l )
|
||||
: list( l )
|
||||
{
|
||||
}
|
||||
|
||||
const QStringList& list;
|
||||
};
|
||||
|
||||
QDebug& operator<<( QDebug& s, const Redacted& l );
|
||||
|
||||
/**
|
||||
* @brief Formatted logging of a pointer
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user