You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Potential misbehavior: When a ContractDefinition is created with an accessPolicyId, contractPolicyId and an empty Criterion list, this ContractDefinition is applied to all Assets and results in a Catalog with ContractOffers that each link the Policy with the contractPolicyId and every single Asset.
Catalog with 0 ContractOffers as the ContractDefinition is invalid and does not point to a single Asset.
Observed Behavior
Catalog with 50 ContractOffers, each Asset linking to the same Policy from the ContractDefinition.
As a result: 50 ContractOffers (empty Criterion list) and 50 registered Assets result in 50x50 ContractOffers in the Catalog.
Possible Implementation
The method queryAssets(AssetSelectorExpression expression) in AssetIndex implementations currently only checks for null objects and the AssetSelectorExpression.SELECT_ALL expression. Filtering should be aborted when the criteria list is empty:
@OverridepublicStream<Asset> queryAssets(AssetSelectorExpressionexpression) {
Objects.requireNonNull(expression, "AssetSelectorExpression can not be null!");
// select everything ONLY if the special constant is usedif (expression == AssetSelectorExpression.SELECT_ALL) {
returnqueryAssets(QuerySpec.none());
}
// don't continue if no criteria existvarcriteria = expression.getCriteria();
if (criteria == null || criteria.isEmpty()) {
returnStream.empty();
}
returnqueryAssets(QuerySpec.Builder.newInstance().filter(expression.getCriteria()).build());
}
juliapampus
changed the title
Potential Bug: Empty criteria list in ContractDefinition results in valid data offers
Bug: Empty criteria list in AssetSelectorExpression results in valid data offers
Sep 26, 2022
Is this still valid? empty criteria list stands for "select all", if we want to avoid this behavior for any reason a validation could be added, but I'd say that this can be closed
Bug Report
Describe the Bug
Potential misbehavior: When a
ContractDefinition
is created with anaccessPolicyId
,contractPolicyId
and an emptyCriterion
list, thisContractDefinition
is applied to allAssets
and results in aCatalog
withContractOffers
that each link thePolicy
with thecontractPolicyId
and every singleAsset
.Example:
Policy
ContractDefinition
(accessPolicyId
,contractPolicyId
, emptyCriterion
list)Assets
Expected Behavior
Catalog
with 0ContractOffers
as theContractDefinition
is invalid and does not point to a singleAsset
.Observed Behavior
Catalog
with 50ContractOffers
, eachAsset
linking to the samePolicy
from theContractDefinition
.As a result: 50
ContractOffers
(emptyCriterion
list) and 50 registeredAssets
result in 50x50ContractOffers
in theCatalog
.Possible Implementation
The method
queryAssets(AssetSelectorExpression expression)
inAssetIndex
implementations currently only checks for null objects and theAssetSelectorExpression.SELECT_ALL
expression. Filtering should be aborted when the criteria list is empty:InMemoryAssetIndexTest:
The text was updated successfully, but these errors were encountered: