Skip to content

Commit a2400f1

Browse files
committed
Fix % escaping in deployment info and user roles
- Escape % signs in roles string to prevent printf format errors - Remove tmux session info from user roles to clean audit logs - Strip tmux session data when capturing deployment user info These changes prevent display errors when user roles contain % characters and improve audit log readability by removing tmux session noise from user identification.
1 parent d3eacd9 commit a2400f1

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

lib/Genesis/Commands/Info.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ sub information {
139139
$deployment->succeeded ? 'G' : 'R',
140140
$deployment->action eq 'deploy' ? ' deployment' : 'termination',
141141
$deployment->succeeded ? 'succeeded' : 'failed ',
142-
$roles_string,
142+
$roles_string =~ s/%/%%/gr, # Escape % signs in the roles string
143143
$deployment->lookup('kit.id')
144144
);
145145
$prefix = "[[ >>";

lib/Genesis/Env/Deployment.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ sub user_colorized_roles {
299299
sprintf(
300300
"#%s{%s}",
301301
$user_color_map->{$_} // 'y', # Default to yellow if not defined
302-
$user_info->{$_}
302+
$user_info->{$_} =~ s/ \(tmux\(\d*\)[^\)]*\)//gr
303303
)
304304
} @used_roles;
305305

lib/Genesis/Env/DeploymentManager.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ sub _base_deployment_content {
424424
lines(run({stderr => '/dev/null'},'who', '-mH'))
425425
)->[1];
426426
my $user = $user_data->[0] // $ENV{USER};
427+
delete($user_data->[3]) if $user_data->[3] =~ /^tmux\(/; # Remove tmux session name if present)'
427428
$user .= (" ".$user_data->[3]) if $user_data->[3];
428429
$base->{user} = {
429430
shell => $user,

0 commit comments

Comments
 (0)