@@ -1047,3 +1047,79 @@ ENV FOO=bar
10471047 }, nil )
10481048 require .NoError (t , err )
10491049}
1050+
1051+ // https://github.com/moby/buildkit/issues/3562
1052+ func testDuplicatePlatformProvenance (t * testing.T , sb integration.Sandbox ) {
1053+ integration .CheckFeatureCompat (t , sb , integration .FeatureProvenance )
1054+ ctx := sb .Context ()
1055+
1056+ c , err := client .New (ctx , sb .Address ())
1057+ require .NoError (t , err )
1058+ defer c .Close ()
1059+
1060+ f := getFrontend (t , sb )
1061+
1062+ dockerfile := []byte (`FROM alpine` )
1063+ dir , err := integration .Tmpdir (
1064+ t ,
1065+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
1066+ )
1067+ require .NoError (t , err )
1068+
1069+ _ , err = f .Solve (sb .Context (), c , client.SolveOpt {
1070+ FrontendAttrs : map [string ]string {
1071+ "attest:provenance" : "mode=max" ,
1072+ "platform" : "linux/amd64,linux/amd64" ,
1073+ },
1074+ LocalDirs : map [string ]string {
1075+ dockerui .DefaultLocalNameDockerfile : dir ,
1076+ dockerui .DefaultLocalNameContext : dir ,
1077+ },
1078+ }, nil )
1079+ require .NoError (t , err )
1080+ }
1081+
1082+ // https://github.com/moby/buildkit/issues/3928
1083+ func testDockerIgnoreMissingProvenance (t * testing.T , sb integration.Sandbox ) {
1084+ integration .CheckFeatureCompat (t , sb , integration .FeatureProvenance )
1085+ c , err := client .New (sb .Context (), sb .Address ())
1086+ require .NoError (t , err )
1087+ defer c .Close ()
1088+
1089+ dockerfile := []byte (`FROM alpine` )
1090+ dirDockerfile , err := integration .Tmpdir (
1091+ t ,
1092+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
1093+ )
1094+ require .NoError (t , err )
1095+ dirContext , err := integration .Tmpdir (t )
1096+ require .NoError (t , err )
1097+
1098+ frontend := func (ctx context.Context , c gateway.Client ) (* gateway.Result , error ) {
1099+ // remove the directory to simulate the case where the context
1100+ // directory does not exist, and either no validation checks were run,
1101+ // or they passed erroneously
1102+ if err := os .RemoveAll (dirContext ); err != nil {
1103+ return nil , err
1104+ }
1105+
1106+ res , err := c .Solve (ctx , gateway.SolveRequest {
1107+ Frontend : "dockerfile.v0" ,
1108+ })
1109+ if err != nil {
1110+ return nil , err
1111+ }
1112+ return res , nil
1113+ }
1114+
1115+ _ , err = c .Build (sb .Context (), client.SolveOpt {
1116+ FrontendAttrs : map [string ]string {
1117+ "attest:provenance" : "mode=max" ,
1118+ },
1119+ LocalDirs : map [string ]string {
1120+ dockerui .DefaultLocalNameDockerfile : dirDockerfile ,
1121+ dockerui .DefaultLocalNameContext : dirContext ,
1122+ },
1123+ }, "" , frontend , nil )
1124+ require .NoError (t , err )
1125+ }
0 commit comments