Skip to content

Commit 5f7d4da

Browse files
author
Jason Yellick
committed
[FAB-4560] Config updates with no effect validate
The config update logic validates that a config update is not empty, and that any modifications made are validly signed. However, it is possible that if the config update is not empty, but it has no effect on the configuration (ie, the read and write sets are equal), then the configuration will still apply, without any signatures, because there are no modifications made to be validated. This CR adds an explicit check which disallows update sets which do not modify at least on configuration element. Change-Id: If2be92aaf3a917ac7dbd617226594331d619e09d Signed-off-by: Jason Yellick <[email protected]>
1 parent fcda9a9 commit 5f7d4da

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

common/configtx/update.go

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func ComputeDeltaSet(readSet, writeSet map[string]comparable) map[string]compara
5555
}
5656

5757
func (cm *configManager) verifyDeltaSet(deltaSet map[string]comparable, signedData []*cb.SignedData) error {
58+
if len(deltaSet) == 0 {
59+
return fmt.Errorf("Delta set was empty. Update would have no effect.")
60+
}
61+
5862
for key, value := range deltaSet {
5963
existing, ok := cm.current.configMap[key]
6064
if !ok {

common/configtx/update_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ func TestVerifyDeltaSet(t *testing.T) {
118118

119119
assert.Error(t, cm.verifyDeltaSet(deltaSet, nil), "Policy evaluation should have failed")
120120
})
121+
122+
t.Run("Empty delta set", func(t *testing.T) {
123+
err := (&configManager{}).verifyDeltaSet(map[string]comparable{}, nil)
124+
assert.Error(t, err, "Empty delta set should be rejected")
125+
assert.Contains(t, err.Error(), "Delta set was empty. Update would have no effect.")
126+
})
121127
}
122128

123129
func TestPolicyForItem(t *testing.T) {

0 commit comments

Comments
 (0)