@@ -35,42 +35,42 @@ export class CommandLineAutoApprover extends Disposable {
35
35
this . _denyListCommandLineRegexes = denyListCommandLine ;
36
36
}
37
37
38
- isCommandAutoApproved ( command : string , shell : string , os : OperatingSystem ) : boolean {
38
+ isCommandAutoApproved ( command : string , shell : string , os : OperatingSystem ) : { isAutoApproved : boolean ; reason : string } {
39
39
// Check the deny list to see if this command requires explicit approval
40
40
for ( const regex of this . _denyListRegexes ) {
41
41
if ( this . _commandMatchesRegex ( regex , command , shell , os ) ) {
42
- return false ;
42
+ return { isAutoApproved : false , reason : `Command ' ${ command } ' is denied by deny list rule: ${ regex . source } ` } ;
43
43
}
44
44
}
45
45
46
46
// Check the allow list to see if the command is allowed to run without explicit approval
47
47
for ( const regex of this . _allowListRegexes ) {
48
48
if ( this . _commandMatchesRegex ( regex , command , shell , os ) ) {
49
- return true ;
49
+ return { isAutoApproved : true , reason : `Command ' ${ command } ' is approved by allow list rule: ${ regex . source } ` } ;
50
50
}
51
51
}
52
52
53
53
// TODO: LLM-based auto-approval https://github.com/microsoft/vscode/issues/253267
54
54
55
55
// Fallback is always to require approval
56
- return false ;
56
+ return { isAutoApproved : false , reason : `Command ' ${ command } ' requires explicit approval (no matching allow list rule found)` } ;
57
57
}
58
58
59
- isCommandLineAutoApproved ( commandLine : string ) : boolean {
59
+ isCommandLineAutoApproved ( commandLine : string ) : { isAutoApproved : boolean ; reason : string } {
60
60
// Check the deny list first to see if this command line requires explicit approval
61
61
for ( const regex of this . _denyListCommandLineRegexes ) {
62
62
if ( regex . test ( commandLine ) ) {
63
- return false ;
63
+ return { isAutoApproved : false , reason : `Command line ' ${ commandLine } ' is denied by deny list rule: ${ regex . source } ` } ;
64
64
}
65
65
}
66
66
67
67
// Check if the full command line matches any of the allow list command line regexes
68
68
for ( const regex of this . _allowListCommandLineRegexes ) {
69
69
if ( regex . test ( commandLine ) ) {
70
- return true ;
70
+ return { isAutoApproved : true , reason : `Command line ' ${ commandLine } ' is approved by allow list rule: ${ regex . source } ` } ;
71
71
}
72
72
}
73
- return false ;
73
+ return { isAutoApproved : false , reason : `Command line ' ${ commandLine } ' requires explicit approval (no matching allow list rule found)` } ;
74
74
}
75
75
76
76
private _commandMatchesRegex ( regex : RegExp , command : string , shell : string , os : OperatingSystem ) : boolean {
0 commit comments