提交 fa92051d 编写于 作者: J Jason Song

fix potential data inconsistency issue

上级 13de50bf
......@@ -84,6 +84,12 @@ public class ItemController {
throw new NotFoundException("item not found for itemId " + itemId);
}
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
// In case someone constructs an attack scenario
if (namespace == null || namespace.getId() != managedEntity.getNamespaceId()) {
throw new BadRequestException("Invalid request, item and namespace do not match!");
}
Item entity = BeanUtils.transform(Item.class, itemDTO);
ConfigChangeContentBuilder builder = new ConfigChangeContentBuilder();
......
......@@ -113,7 +113,7 @@ public class ItemController {
NamespaceDTO namespace = namespaceService.loadNamespaceBaseInfo(appId, Env.valueOf(env), clusterName, namespaceName);
// In case someone constructs an attack scenario
if (item.getNamespaceId() != namespace.getId()) {
if (namespace == null || item.getNamespaceId() != namespace.getId()) {
throw new BadRequestException("Invalid request, item and namespace do not match!");
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册