Skip to content

Commit f949050

Browse files
authored
Merge pull request #7672 from nextcloud/backport/6977/log-censor
[stable12] Added additional methods for removal of sensitive info
2 parents 9ed0f50 + 903d7fc commit f949050

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

lib/private/Log.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ class Log implements ILogger {
6969
'loginWithPassword',
7070
'updatePrivateKeyPassword',
7171
'validateUserPass',
72+
'loginWithToken',
73+
'\{closure\}',
7274

7375
// TokenProvider
7476
'getToken',
@@ -96,6 +98,10 @@ class Log implements ILogger {
9698
'bind',
9799
'areCredentialsValid',
98100
'invokeLDAPMethod',
101+
102+
// Encryption
103+
'storeKeyPair',
104+
'setupUser',
99105
];
100106

101107
/**

tests/lib/LoggerTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,32 @@ public function testDetecttryLogin($user, $password) {
138138
}
139139
}
140140

141+
/**
142+
* @dataProvider userAndPasswordData
143+
*/
144+
public function testDetectclosure($user, $password) {
145+
$a = function($user, $password) {
146+
throw new \Exception('test');
147+
};
148+
149+
try {
150+
$a($user, $password);
151+
} catch (\Exception $e) {
152+
$this->logger->logException($e);
153+
}
154+
$logLines = $this->getLogs();
155+
156+
foreach($logLines as $logLine) {
157+
$log = explode('\n', $logLine);
158+
unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0
159+
$logLine = implode('\n', $log);
160+
161+
$this->assertNotContains($user, $logLine);
162+
$this->assertNotContains($password, $logLine);
163+
$this->assertContains('{closure}(*** sensitive parameters replaced ***)', $logLine);
164+
}
165+
}
166+
141167
public function dataGetLogClass() {
142168
return [
143169
['file', \OC\Log\File::class],

0 commit comments

Comments
 (0)