-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-3155] LSCC security checks at validation time
This change set checks that - upon cc deploy and upgrade - the tx complies with the instantiation policy specified in the cc packge (for deploy) and in the cc info in the ledger (for upgrade). The committer code is essentially performing again the checks that lscc performs at proposal time, to ensure that no one can circumvent instantiation policies. Furthermore, we validate the read-write set of a cc deploy/upgrade and make sure that it is consistent with the invocation arguments. Finally, we make sure that LSCC deploy/upgrade transactions do not contain writes to namespaces other than LSCC's and the chaincode that is being deployed/upgraded. Change-Id: Id11fc359a8c77fa58c8a966a7c324075944ae22b Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
- Loading branch information
Showing
7 changed files
with
1,395 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package ledger | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hyperledger/fabric/common/ledger" | ||
) | ||
|
||
type MockQueryExecutor struct { | ||
// State keeps all namepspaces | ||
State map[string]map[string][]byte | ||
} | ||
|
||
func NewMockQueryExecutor(state map[string]map[string][]byte) *MockQueryExecutor { | ||
return &MockQueryExecutor{ | ||
State: state, | ||
} | ||
} | ||
|
||
func (m *MockQueryExecutor) GetState(namespace string, key string) ([]byte, error) { | ||
ns := m.State[namespace] | ||
if ns == nil { | ||
return nil, fmt.Errorf("Could not retrieve namespace %s", namespace) | ||
} | ||
|
||
return ns[key], nil | ||
} | ||
|
||
func (m *MockQueryExecutor) GetStateMultipleKeys(namespace string, keys []string) ([][]byte, error) { | ||
return nil, nil | ||
|
||
} | ||
|
||
func (m *MockQueryExecutor) GetStateRangeScanIterator(namespace string, startKey string, endKey string) (ledger.ResultsIterator, error) { | ||
return nil, nil | ||
|
||
} | ||
|
||
func (m *MockQueryExecutor) ExecuteQuery(namespace, query string) (ledger.ResultsIterator, error) { | ||
return nil, nil | ||
} | ||
|
||
func (m *MockQueryExecutor) Done() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.