From d4b5649885c688e756f115dce66a7cdc955091c4 Mon Sep 17 00:00:00 2001 From: Gregory Haskins Date: Fri, 17 Feb 2017 12:05:10 -0500 Subject: [PATCH] [FAB-2341] Fix validation logic with empty CodePackage The recently added platform::ValidateDeploymentSpec did not account for the possibility that the CodePackage may be optional under certain scenarios. This patch fixes this by checking for this condition and handling gracefully. Fixes FAB-2341 Change-Id: I83791dbf04c420e42b087805de668f0405b0214a Signed-off-by: Greg Haskins --- core/chaincode/platforms/golang/platform.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/chaincode/platforms/golang/platform.go b/core/chaincode/platforms/golang/platform.go index 5cfa11a18fb..9bafc806538 100644 --- a/core/chaincode/platforms/golang/platform.go +++ b/core/chaincode/platforms/golang/platform.go @@ -98,6 +98,11 @@ func (goPlatform *Platform) ValidateSpec(spec *pb.ChaincodeSpec) error { func (goPlatform *Platform) ValidateDeploymentSpec(cds *pb.ChaincodeDeploymentSpec) error { + if cds.CodePackage == nil || len(cds.CodePackage) == 0 { + // Nothing to validate if no CodePackage was included + return nil + } + // FAB-2122: Scan the provided tarball to ensure it only contains source-code under // /src/$packagename. We do not want to allow something like ./pkg/shady.a to be installed under // $GOPATH within the container. Note, we do not look deeper than the path at this time