@@ -78,6 +78,7 @@ public function execute_remote_command(...$commands)
7878 $ customType = data_get ($ single_command , 'type ' );
7979 $ ignore_errors = data_get ($ single_command , 'ignore_errors ' , false );
8080 $ append = data_get ($ single_command , 'append ' , true );
81+ $ command_hidden = data_get ($ single_command , 'command_hidden ' , false );
8182 $ this ->save = data_get ($ single_command , 'save ' );
8283 if ($ this ->server ->isNonRoot ()) {
8384 if (str ($ command )->startsWith ('docker exec ' )) {
@@ -102,7 +103,7 @@ public function execute_remote_command(...$commands)
102103
103104 while ($ attempt < $ maxRetries && ! $ commandExecuted ) {
104105 try {
105- $ this ->executeCommandWithProcess ($ command , $ hidden , $ customType , $ append , $ ignore_errors );
106+ $ this ->executeCommandWithProcess ($ command , $ hidden , $ customType , $ append , $ ignore_errors, $ command_hidden );
106107 $ commandExecuted = true ;
107108 } catch (\RuntimeException |DeploymentException $ e ) {
108109 $ lastError = $ e ;
@@ -152,10 +153,14 @@ public function execute_remote_command(...$commands)
152153 /**
153154 * Execute the actual command with process handling
154155 */
155- private function executeCommandWithProcess ($ command , $ hidden , $ customType , $ append , $ ignore_errors )
156+ private function executeCommandWithProcess ($ command , $ hidden , $ customType , $ append , $ ignore_errors, $ command_hidden = false )
156157 {
158+ if ($ command_hidden && isset ($ this ->application_deployment_queue )) {
159+ $ this ->application_deployment_queue ->addLogEntry ('[CMD]: ' .$ this ->redact_sensitive_info ($ command ), hidden: true );
160+ }
161+
157162 $ remote_command = SshMultiplexingHelper::generateSshCommand ($ this ->server , $ command );
158- $ process = Process::timeout (config ('constants.ssh.command_timeout ' ))->idleTimeout (3600 )->start ($ remote_command , function (string $ type , string $ output ) use ($ command , $ hidden , $ customType , $ append ) {
163+ $ process = Process::timeout (config ('constants.ssh.command_timeout ' ))->idleTimeout (3600 )->start ($ remote_command , function (string $ type , string $ output ) use ($ command , $ hidden , $ customType , $ append, $ command_hidden ) {
159164 $ output = str ($ output )->trim ();
160165 if ($ output ->startsWith ('╔ ' )) {
161166 $ output = "\n" .$ output ;
@@ -165,9 +170,9 @@ private function executeCommandWithProcess($command, $hidden, $customType, $appe
165170 $ sanitized_output = sanitize_utf8_text ($ output );
166171
167172 $ new_log_entry = [
168- 'command ' => $ this ->redact_sensitive_info ($ command ),
173+ 'command ' => $ command_hidden ? null : $ this ->redact_sensitive_info ($ command ),
169174 'output ' => $ this ->redact_sensitive_info ($ sanitized_output ),
170- 'type ' => $ customType ?? $ type === 'err ' ? 'stderr ' : 'stdout ' ,
175+ 'type ' => $ customType ?? ( $ type === 'err ' ? 'stderr ' : 'stdout ' ) ,
171176 'timestamp ' => Carbon::now ('UTC ' ),
172177 'hidden ' => $ hidden ,
173178 'batch ' => static ::$ batch_counter ,
0 commit comments