@@ -258,11 +258,17 @@ for (const { testPrefix, featureFlags } of [
258258 t . true ( output . includes ( `No secrets detected in build output or repo code!` ) )
259259 } )
260260
261- // Enhanced secret scanning
261+ // Enhanced secret scanning with enhanced_secret_scan_impacts_builds enabled
262262
263263 test ( testPrefix + 'secrets scanning, enhanced scan should not run when disabled' , async ( t ) => {
264264 const { requests } = await new Fixture ( './fixtures/src_scanning_disabled' )
265- . withFlags ( { debug : false , enhancedSecretScan : true , deployId : 'test' , token : 'test' , featureFlags } )
265+ . withFlags ( {
266+ debug : false ,
267+ enhancedSecretScan : true ,
268+ deployId : 'test' ,
269+ token : 'test' ,
270+ featureFlags : { ...featureFlags , enhanced_secret_scan_impacts_builds : true } ,
271+ } )
266272 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
267273 t . true ( requests . length === 0 )
268274 } )
@@ -278,7 +284,7 @@ for (const { testPrefix, featureFlags } of [
278284 enhancedSecretScan : true ,
279285 deployId : 'test' ,
280286 token : 'test' ,
281- featureFlags,
287+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
282288 } )
283289 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
284290
@@ -293,11 +299,11 @@ for (const { testPrefix, featureFlags } of [
293299 const { requests } = await new Fixture ( './fixtures/src_scanning_likely_enhanced_scan_secrets_disabled' )
294300 . withFlags ( {
295301 debug : false ,
296- explicitSecretKeys : '' ,
302+ explicitSecretKeys : 'ENV_VAR_1 ' ,
297303 enhancedSecretScan : true ,
298304 deployId : 'test' ,
299305 token : 'test' ,
300- featureFlags,
306+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
301307 } )
302308 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
303309 t . true ( requests . length === 1 )
@@ -316,7 +322,7 @@ for (const { testPrefix, featureFlags } of [
316322 enhancedSecretScan : true ,
317323 deployId : 'test' ,
318324 token : 'test' ,
319- featureFlags,
325+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
320326 } )
321327 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
322328
@@ -337,7 +343,7 @@ for (const { testPrefix, featureFlags } of [
337343 enhancedSecretScan : false ,
338344 deployId : 'test' ,
339345 token : 'test' ,
340- featureFlags,
346+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
341347 } )
342348 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
343349
@@ -353,7 +359,7 @@ for (const { testPrefix, featureFlags } of [
353359 enhancedSecretScan : true ,
354360 deployId : 'test' ,
355361 token : 'test' ,
356- featureFlags,
362+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
357363 } )
358364 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
359365
@@ -367,7 +373,13 @@ for (const { testPrefix, featureFlags } of [
367373
368374 test ( testPrefix + 'secrets scanning, should not find secrets in files without known prefixes' , async ( t ) => {
369375 const { requests } = await new Fixture ( './fixtures/src_scanning_no_likely_enhanced_scan_secrets' , featureFlags )
370- . withFlags ( { debug : false , enhancedSecretScan : true , deployId : 'test' , token : 'test' } )
376+ . withFlags ( {
377+ debug : false ,
378+ enhancedSecretScan : true ,
379+ deployId : 'test' ,
380+ token : 'test' ,
381+ featureFlags : { ...featureFlags , enhanced_secret_scan_impacts_builds : true } ,
382+ } )
371383 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
372384
373385 t . true ( requests . length === 1 )
@@ -389,7 +401,7 @@ for (const { testPrefix, featureFlags } of [
389401 enhancedSecretScan : true ,
390402 deployId : 'test' ,
391403 token : 'test' ,
392- featureFlags,
404+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
393405 } )
394406 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
395407
@@ -414,7 +426,7 @@ for (const { testPrefix, featureFlags } of [
414426 enhancedSecretScan : true ,
415427 deployId : 'test' ,
416428 token : 'test' ,
417- featureFlags,
429+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
418430 } )
419431 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
420432
@@ -443,7 +455,7 @@ for (const { testPrefix, featureFlags } of [
443455 enhancedSecretScan : true ,
444456 deployId : 'test' ,
445457 token : 'test' ,
446- featureFlags,
458+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
447459 } )
448460 . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
449461
@@ -463,12 +475,108 @@ for (const { testPrefix, featureFlags } of [
463475 debug : false ,
464476 explicitSecretKeys : '' ,
465477 enhancedSecretScan : true ,
466- featureFlags,
478+ featureFlags : { ... featureFlags , enhanced_secret_scan_impacts_builds : true } ,
467479 } )
468480 . runBuildProgrammatic ( )
469481 // Severity code of 2 is user error
470482 t . is ( severityCode , 2 )
471483 } )
484+
485+ // enhanced scanning enabled, but without impact to builds
486+
487+ test (
488+ testPrefix +
489+ 'secrets scanning, should not log enhanced scan info when enhanced_secret_scan_impacts_builds is false' ,
490+ async ( t ) => {
491+ const { output } = await new Fixture ( './fixtures/src_scanning_likely_enhanced_scan_secrets' )
492+ . withFlags ( {
493+ debug : false ,
494+ enhancedSecretScan : true ,
495+ featureFlags : { ...featureFlags , enhanced_secret_scan_impacts_builds : false } ,
496+ deployId : 'test' ,
497+ token : 'test' ,
498+ } )
499+ . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
500+
501+ const normalizedOutput = normalizeOutput ( output )
502+ t . false ( normalizedOutput . includes ( 'detected as a likely secret' ) )
503+ } ,
504+ )
505+
506+ test (
507+ testPrefix +
508+ 'secrets scanning, should not fail build when enhanced scan finds likely secrets but enhanced_secret_scan_impacts_builds is false' ,
509+ async ( t ) => {
510+ const { severityCode } = await new Fixture ( './fixtures/src_scanning_likely_enhanced_scan_secrets' )
511+ . withFlags ( {
512+ debug : false ,
513+ enhancedSecretScan : true ,
514+ featureFlags : { ...featureFlags , enhanced_secret_scan_impacts_builds : false } ,
515+ } )
516+ . runBuildProgrammatic ( )
517+
518+ // Severity code of 0 means success, 2 would be user error
519+ t . is ( severityCode , 0 )
520+ } ,
521+ )
522+
523+ test (
524+ testPrefix +
525+ 'secrets scanning, should not log omit values message when enhanced_secret_scan_impacts_builds is false' ,
526+ async ( t ) => {
527+ const { output } = await new Fixture ( './fixtures/src_scanning_likely_enhanced_scan_secrets_omitted' )
528+ . withFlags ( {
529+ debug : false ,
530+ enhancedSecretScan : true ,
531+ featureFlags : { ...featureFlags , enhanced_secret_scan_impacts_builds : false } ,
532+ deployId : 'test' ,
533+ token : 'test' ,
534+ } )
535+ . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
536+
537+ t . false ( normalizeOutput ( output ) . includes ( 'ENHANCED_SECRETS_SCAN_OMIT_VALUES' ) )
538+ } ,
539+ )
540+
541+ test (
542+ testPrefix + 'secrets scanning, should run enhanced scan in passive mode when explicit keys are present' ,
543+ async ( t ) => {
544+ const { requests } = await new Fixture ( './fixtures/src_scanning_env_vars_set_non_empty' )
545+ . withFlags ( {
546+ debug : false ,
547+ explicitSecretKeys : 'ENV_VAR_1' ,
548+ enhancedSecretScan : true ,
549+ featureFlags : { ...featureFlags , enhanced_secret_scan_impacts_builds : false } ,
550+ deployId : 'test' ,
551+ token : 'test' ,
552+ } )
553+ . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
554+
555+ t . true ( requests . length === 1 )
556+ const request = requests [ 0 ]
557+ t . is ( request . url , '/api/v1/deploys/test/validations_report' )
558+ t . truthy ( request . body . secrets_scan . scannedFilesCount )
559+ t . truthy ( request . body . secrets_scan . enhancedSecretsScanMatches )
560+ } ,
561+ )
562+
563+ test (
564+ testPrefix + 'secrets scanning, should not run enhanced scan in passive mode when no explicit keys' ,
565+ async ( t ) => {
566+ const { requests } = await new Fixture ( './fixtures/src_scanning_likely_enhanced_scan_secrets' )
567+ . withFlags ( {
568+ debug : false ,
569+ explicitSecretKeys : '' ,
570+ enhancedSecretScan : true ,
571+ featureFlags : { ...featureFlags , enhanced_secret_scan_impacts_builds : false } ,
572+ deployId : 'test' ,
573+ token : 'test' ,
574+ } )
575+ . runBuildServer ( { path : '/api/v1/deploys/test/validations_report' } )
576+
577+ t . true ( requests . length === 0 )
578+ } ,
579+ )
472580 ; ( featureFlags . secret_scanning_minimal_chunks ? test : test . skip ) (
473581 testPrefix + 'does not crash if line in scanned file exceed available memory' ,
474582 async ( t ) => {
0 commit comments