Merge pull request #7673 from nextcloud/backport/6977/log-censor-11

[stable11]  Added additional methods for removal of sensitive info
This commit is contained in:
Roeland Jago Douma 2018-01-03 12:54:42 +01:00 committed by GitHub
commit e2bfc14bd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View file

@ -68,6 +68,8 @@ class Log implements ILogger {
'loginWithPassword',
'updatePrivateKeyPassword',
'validateUserPass',
'loginWithToken',
'\{closure\}',
// TokenProvider
'getToken',
@ -90,6 +92,10 @@ class Log implements ILogger {
//LoginController
'tryLogin',
'confirmPassword',
// Encryption
'storeKeyPair',
'setupUser',
];
/**

View file

@ -138,6 +138,32 @@ class LoggerTest extends TestCase {
}
}
/**
* @dataProvider userAndPasswordData
*/
public function testDetectclosure($user, $password) {
$a = function($user, $password) {
throw new \Exception('test');
};
try {
$a($user, $password);
} catch (\Exception $e) {
$this->logger->logException($e);
}
$logLines = $this->getLogs();
foreach($logLines as $logLine) {
$log = explode('\n', $logLine);
unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0
$logLine = implode('\n', $log);
$this->assertNotContains($user, $logLine);
$this->assertNotContains($password, $logLine);
$this->assertContains('{closure}(*** sensitive parameters replaced ***)', $logLine);
}
}
public function dataGetLogClass() {
return [
['file', \OC\Log\File::class],