File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 /**
Original file line number Diff line number Diff 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],
You can’t perform that action at this time.
0 commit comments