@@ -858,6 +858,124 @@ describe('Function Execute API Route', () => {
858858 expect ( JSON . stringify ( data ) ) . toContain ( 'files/report-secret-value.txt' )
859859 } )
860860
861+ it ( 'classifies a binary export exact-empty when no secret was in scope' , async ( ) => {
862+ envFlagsMock . isRemoteSandboxEnabled = true
863+ mockExecuteInSandbox . mockResolvedValueOnce ( {
864+ result : 'done' ,
865+ stdout : '' ,
866+ sandboxId : 'sandbox-123' ,
867+ exportedFiles : { '/home/user/small.jpg' : '/9j/4AAQ' } ,
868+ } )
869+
870+ const response = await POST (
871+ createMockRequest ( 'POST' , {
872+ code : 'print("done")' ,
873+ language : 'python' ,
874+ workspaceId : 'workspace-1' ,
875+ outputs : {
876+ files : [
877+ {
878+ path : 'files/small.jpg' ,
879+ sandboxPath : '/home/user/small.jpg' ,
880+ mimeType : 'image/jpeg' ,
881+ } ,
882+ ] ,
883+ } ,
884+ } )
885+ )
886+
887+ expect ( response . status ) . toBe ( 200 )
888+ expect ( mockWriteWorkspaceFileByPath ) . toHaveBeenCalledWith (
889+ expect . objectContaining ( { secretProvenance : { status : 'exact' , entries : [ ] } } )
890+ )
891+ } )
892+
893+ it ( 'keeps a binary export unknown when files were mounted without a provenance envelope' , async ( ) => {
894+ envFlagsMock . isRemoteSandboxEnabled = true
895+ mockExecuteInSandbox . mockResolvedValueOnce ( {
896+ result : 'done' ,
897+ stdout : '' ,
898+ sandboxId : 'sandbox-123' ,
899+ exportedFiles : { '/home/user/small.jpg' : '/9j/4AAQ' } ,
900+ } )
901+
902+ const response = await POST (
903+ createMockRequest ( 'POST' , {
904+ code : 'print("done")' ,
905+ language : 'python' ,
906+ workspaceId : 'workspace-1' ,
907+ _sandboxFiles : [ { path : '/home/user/in.bin' , content : 'mounted bytes' } ] ,
908+ outputs : {
909+ files : [
910+ {
911+ path : 'files/small.jpg' ,
912+ sandboxPath : '/home/user/small.jpg' ,
913+ mimeType : 'image/jpeg' ,
914+ } ,
915+ ] ,
916+ } ,
917+ } )
918+ )
919+
920+ expect ( response . status ) . toBe ( 200 )
921+ expect ( mockWriteWorkspaceFileByPath ) . toHaveBeenCalledWith (
922+ expect . objectContaining ( { secretProvenance : { status : 'unknown' } } )
923+ )
924+ } )
925+
926+ it ( 'keeps a binary export unknown when a mounted input file carried a secret' , async ( ) => {
927+ envFlagsMock . isRemoteSandboxEnabled = true
928+ mockExecuteInSandbox . mockResolvedValueOnce ( {
929+ result : 'done' ,
930+ stdout : '' ,
931+ sandboxId : 'sandbox-123' ,
932+ exportedFiles : { '/home/user/small.jpg' : '/9j/4AAQ' } ,
933+ } )
934+
935+ const response = await POST (
936+ createMockRequest (
937+ 'POST' ,
938+ {
939+ code : 'print("done")' ,
940+ language : 'python' ,
941+ workspaceId : 'workspace-1' ,
942+ outputs : {
943+ files : [
944+ {
945+ path : 'files/small.jpg' ,
946+ sandboxPath : '/home/user/small.jpg' ,
947+ mimeType : 'image/jpeg' ,
948+ } ,
949+ ] ,
950+ } ,
951+ [ PRIVATE_SECRET_PROVENANCE_FIELD ] : {
952+ version : 1 ,
953+ complete : true ,
954+ selections : [
955+ {
956+ key : MOUNTED_WORKSPACE_FILES_PROVENANCE_KEY ,
957+ provenance : {
958+ version : 1 ,
959+ complete : true ,
960+ entries : [ { encryptedValue : 'encrypted:mounted-secret' } ] ,
961+ scope : { userId : 'user-123' , workspaceId : 'workspace-1' } ,
962+ } ,
963+ } ,
964+ ] ,
965+ } ,
966+ } ,
967+ {
968+ [ PRIVATE_SECRET_PROVENANCE_HEADER ] : PRIVATE_SECRET_PROVENANCE_BUNDLE_V1 ,
969+ }
970+ )
971+ )
972+
973+ expect ( response . status ) . toBe ( 200 )
974+ expect ( mockWriteWorkspaceFileByPath ) . toHaveBeenCalledWith (
975+ expect . objectContaining ( { secretProvenance : { status : 'unknown' } } )
976+ )
977+ } )
978+
861979 it ( 'marks binary exports unknown without failing the Function execution' , async ( ) => {
862980 envFlagsMock . isRemoteSandboxEnabled = true
863981 mockExecuteInSandbox . mockResolvedValueOnce ( {
0 commit comments