@@ -126,8 +126,9 @@ class UnityEditor {
126
126
}
127
127
128
128
const editorArgs = [ ...args ] ;
129
+ const redactedArgs = redactSensitiveArgs ( editorArgs ) ;
129
130
130
- console . debug ( `Executing Unity Editor command: ${ unityPath } ${ editorArgs . join ( " " ) } ` ) ;
131
+ console . debug ( `Executing Unity Editor command: ${ unityPath } ${ redactedArgs . join ( " " ) } ` ) ;
131
132
132
133
return await executeCommand ( unityPath , editorArgs , options ) ;
133
134
} catch ( error ) {
@@ -621,4 +622,39 @@ class UnityEditor {
621
622
}
622
623
}
623
624
625
+ /**
626
+ * Redacts sensitive arguments from the command line arguments.
627
+ *
628
+ * @param argv - The array of command line arguments
629
+ * @param sensitiveKeys - The keys that should be redacted
630
+ * @returns - The array of arguments with sensitive information redacted
631
+ * @internal
632
+ */
633
+ function redactSensitiveArgs ( argv : string [ ] , sensitiveKeys : string [ ] = [ "password" , "token" , "secret" ] ) : string [ ] {
634
+ const redacted = [ ...argv ] ;
635
+
636
+ for ( let i = 0 ; i < redacted . length ; i ++ ) {
637
+ const arg = redacted [ i ] ;
638
+
639
+ if ( arg . startsWith ( "--" ) || arg . startsWith ( "-" ) ) {
640
+ const key = arg . replace ( / ^ - - ? / , "" ) ;
641
+ if ( sensitiveKeys . includes ( key . toLowerCase ( ) ) ) {
642
+ if ( i + 1 < redacted . length && ! redacted [ i + 1 ] . startsWith ( "-" ) ) {
643
+ redacted [ i + 1 ] = "[REDACTED]" ;
644
+ }
645
+ }
646
+ } else {
647
+ const match = arg . match ( / ^ - - ? ( [ ^ = ] + ) = ( .+ ) $ / ) ;
648
+ if ( match ) {
649
+ const key = match [ 1 ] ;
650
+ if ( sensitiveKeys . includes ( key . toLowerCase ( ) ) ) {
651
+ redacted [ i ] = `--${ key } =[REDACTED]` ;
652
+ }
653
+ }
654
+ }
655
+ }
656
+
657
+ return redacted ;
658
+ }
659
+
624
660
export default UnityEditor ;
0 commit comments