@@ -84,13 +84,15 @@ function getCliFilePath() : string {
8484 * @param policy - The policy to use for scanning (default: "mdc")
8585 * @param outputPath - The output SARIF file path
8686 * @param successfulExitCodes - The exit codes that are considered successful. Defaults to [0]. All others will throw an Error.
87+ * @param additionalArgs - Optional additional CLI arguments to append to the command
8788 */
8889async function scan (
8990 scanType : string ,
9091 target : string ,
9192 policy : string = 'mdc' ,
9293 outputPath ?: string ,
93- successfulExitCodes : number [ ] = null
94+ successfulExitCodes : number [ ] = null ,
95+ additionalArgs : string [ ] = [ ]
9496) : Promise < void > {
9597
9698 if ( ! outputPath ) {
@@ -105,6 +107,12 @@ async function scan(
105107 '--defender-output' , outputPath
106108 ] ;
107109
110+ // Append additional arguments if provided
111+ if ( additionalArgs && additionalArgs . length > 0 ) {
112+ args = args . concat ( additionalArgs ) ;
113+ tl . debug ( `Appending additional arguments: ${ additionalArgs . join ( ' ' ) } ` ) ;
114+ }
115+
108116 await runDefenderCli ( args , successfulExitCodes ) ;
109117}
110118
@@ -114,14 +122,16 @@ async function scan(
114122 * @param policy - The policy to use for scanning (default: "mdc")
115123 * @param outputPath - The output SARIF file path
116124 * @param successfulExitCodes - The exit codes that are considered successful. Defaults to [0]. All others will throw an Error.
125+ * @param additionalArgs - Optional additional CLI arguments to append to the command
117126 */
118127export async function scanDirectory (
119128 directoryPath : string ,
120129 policy : string = 'mdc' ,
121130 outputPath ?: string ,
122- successfulExitCodes : number [ ] = null
131+ successfulExitCodes : number [ ] = null ,
132+ additionalArgs : string [ ] = [ ]
123133) : Promise < void > {
124- await scan ( 'fs' , directoryPath , policy , outputPath , successfulExitCodes ) ;
134+ await scan ( 'fs' , directoryPath , policy , outputPath , successfulExitCodes , additionalArgs ) ;
125135}
126136
127137/**
@@ -130,14 +140,16 @@ export async function scanDirectory(
130140 * @param policy - The policy to use for scanning (default: "mdc")
131141 * @param outputPath - The output SARIF file path
132142 * @param successfulExitCodes - The exit codes that are considered successful. Defaults to [0]. All others will throw an Error.
143+ * @param additionalArgs - Optional additional CLI arguments to append to the command
133144 */
134145export async function scanImage (
135146 imageName : string ,
136147 policy : string = 'mdc' ,
137148 outputPath ?: string ,
138- successfulExitCodes : number [ ] = null
149+ successfulExitCodes : number [ ] = null ,
150+ additionalArgs : string [ ] = [ ]
139151) : Promise < void > {
140- await scan ( 'image' , imageName , policy , outputPath , successfulExitCodes ) ;
152+ await scan ( 'image' , imageName , policy , outputPath , successfulExitCodes , additionalArgs ) ;
141153}
142154
143155/**
@@ -170,7 +182,7 @@ async function runDefenderCli(inputArgs: string[], successfulExitCodes: number[]
170182
171183 if ( systemDebug == 'true' ) {
172184 // Add verbose logging if system debug is enabled
173- tool . arg ( '--verbose ' ) ;
185+ tool . arg ( '--defender-debug ' ) ;
174186 }
175187
176188 } catch ( error ) {
@@ -203,6 +215,4 @@ async function runDefenderCli(inputArgs: string[], successfulExitCodes: number[]
203215 } catch ( error ) {
204216 tl . setResult ( tl . TaskResult . Failed , error ) ;
205217 }
206- }
207-
208- // Authentication is handled automatically by the scan commands, so no separate auth function is needed
218+ }
0 commit comments