File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed
Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ private function getEnvData(): array
5151 }
5252
5353 $ request = $ _REQUEST ;
54- $ request = $ this ->removeSensitiveData ($ request );
54+ $ request = $ this ->redactSensitiveData ($ request );
5555
5656 $ envData = [
5757 'creator_id ' => $ user ?->getId(),
@@ -66,14 +66,23 @@ private function getEnvData(): array
6666 }
6767
6868 /**
69- * Remove password value from GraphQL variables well-known structure.
69+ * Redact sensitive values from the entire data structure.
7070 */
71- protected function removeSensitiveData (array $ request ): array
71+ private function redactSensitiveData (array $ request ): array
7272 {
73- unset($ request ['password ' ]);
74- foreach ($ request as &$ r ) {
75- if (is_array ($ r )) {
76- $ r = $ this ->removeSensitiveData ($ r );
73+ foreach ($ request as $ key => &$ value ) {
74+ if (in_array ($ key , [
75+ 'password ' ,
76+ 'passwordConfirmation ' ,
77+ 'password_rep ' ,
78+ 'cpass ' ,
79+ 'npass1 ' ,
80+ 'npass2 ' ,
81+ 'password ' ,
82+ ], true )) {
83+ $ value = '***REDACTED*** ' ;
84+ } elseif (is_array ($ value )) {
85+ $ value = $ this ->redactSensitiveData ($ value );
7786 }
7887 }
7988
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ public function testProcess(): void
4747 'variables ' => [
4848 'other ' => [
4949 'password ' => 'sensitive ' ,
50+ 'passwordConfirmation ' => 'sensitive ' ,
51+ 'npass2 ' => [123 ],
5052 'foo ' => 123 ,
5153 ],
5254 ],
@@ -66,8 +68,12 @@ public function testProcess(): void
6668 self ::assertIsString ($ actual ['url ' ]);
6769 self ::assertIsString ($ actual ['referer ' ]);
6870 self ::assertSame ([
71+ 'password ' => '***REDACTED*** ' ,
6972 'variables ' => [
7073 'other ' => [
74+ 'password ' => '***REDACTED*** ' ,
75+ 'passwordConfirmation ' => '***REDACTED*** ' ,
76+ 'npass2 ' => '***REDACTED*** ' ,
7177 'foo ' => 123 ,
7278 ],
7379 ],
You can’t perform that action at this time.
0 commit comments