Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<fix>[encrypt]: recover iam2 attarbute data #1328

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MatheMatrix
Copy link
Member

@MatheMatrix MatheMatrix commented Mar 3, 2023

remove conver need to recover data

Resolves: ZSTAC-50892

Change-Id: I63646164716f736d64677969636a6d726d767764

Summary by CodeRabbit

  • 新功能

    • 在应用程序中增加了搜索功能,包括搜索栏和搜索结果展示。
  • 样式更新

    • 为搜索栏添加了新的样式设计。

DELIMITER ;

call attributeMailToInformation();
DROP PROCEDURE IF EXISTS attributeMailToInformation;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a brief code review:

  1. The patch will modify the table "LicenseHistoryVO" by adding a new column "capacity" which is of type int(10) and not null.
  2. It will also create a new table "IAM2VirtualIDInformationVO" with columns "uuid", "phone" and "mail". The "uuid" column is the primary key and have a foreign key reference to the "IAM2VirtualIDVO" table.
  3. Create two stored procedures called "attributePhoneToInformation" and "attributeMailToInformation". These procedures will loop through the "IAM2VirtualIDAttributeVO" table and populate the newly created "IAM2VirtualIDInformationVO" table with values from the "value" column.

In terms of potential bugs, I would recommend checking that all the data types match in the foreign key reference. Additionally, make sure that the "uuid" column is properly indexed for both tables.

Finally, it may be worth considering adding a timestamp column to the "IAM2VirtualIDInformationVO" table to keep track of when the rows were inserted or updated.

remove conver need to  recover data

Resolves: ZSTAC-50892

Change-Id: I63646164716f736d64677969636a6d726d767764
DELIMITER ;

call attributeMailToInformation();
DROP PROCEDURE IF EXISTS attributeMailToInformation;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the review:

  1. The code should be checked to make sure that it adheres to the database's best practices and coding standards.
  2. The foreign key should be checked to make sure that it is correctly referencing the primary key of the other table.
  3. The cursor should be checked to make sure it is properly handling errors and that all data is being handled safely.
  4. The stored procedures should be checked to ensure that they are properly constructed and that they are not introducing any potential security risks.
  5. The code should also be checked for optimization opportunities and for any unnecessary or redundant code.

@MatheMatrix
Copy link
Member Author

MatheMatrix commented Dec 3, 2023

@coderabbitai

Copy link

coderabbitai bot commented Dec 3, 2023

This is an invalid command. Please refer to the list of valid keywords below.

CodeRabbit Commands
  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

@MatheMatrix
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented Dec 3, 2023

概述

本次更新主要涉及数据库架构的修改和存储过程的添加,以及Java代码中加密实体处理逻辑的增强。数据库层面,LicenseHistoryVO表经历了结构调整,新增了IAM2VirtualIDInformationVO表。Java层面,EncryptFacadeImpl类增加了多个处理加密实体的方法,并引入了事务注解。测试代码也相应地进行了更新,以适应这些变化。

变更

文件路径 变更摘要
conf/db/upgrade/.../__schema.sql 修改了LicenseHistoryVO表,新增了IAM2VirtualIDInformationVO表和相关存储过程。
core/src/main/java/.../EncryptFacadeImpl.java 增加了处理加密实体的方法,引入了@Transactional注解。
test/src/test/groovy/.../HostPasswordEncryptCase.groovy 增加了密码字段的加密和解密逻辑。

诗歌

🐰🎉

更新来临,代码跳跃,
数据库变,安全加固,
加密新篇,兔子欢喜,
代码之舞,绘春秋。


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 139097d and f9bbed5.
Files selected for processing (3)
  • conf/db/upgrade/V4.5.3__schema.sql (1 hunks)
  • core/src/main/java/org/zstack/core/encrypt/EncryptFacadeImpl.java (2 hunks)
  • test/src/test/groovy/org/zstack/test/integration/kvm/host/HostPasswordEncryptCase.groovy (2 hunks)
Additional comments: 12
conf/db/upgrade/V4.5.3__schema.sql (6)
  • 1-3: 请确认所有与LicenseHistoryVO表交互的代码都已更新,以适应userName列的修改和新添加的capacity列。

  • 5-10: 请验证IAM2VirtualIDVO表及其uuid列是否存在,并确保它们适合作为外键关系。

  • 14-42: 请确认attributePhoneToInformation存储过程在正确的上下文中被调用,并且IAM2VirtualIDAttributeVO表存在且包含预期的列。

  • 45-73: 请确认attributeMailToInformation存储过程在正确的上下文中被调用,并且IAM2VirtualIDAttributeVO表存在且包含预期的列。

  • 41-42: 请确认是否有意在调用attributePhoneToInformation存储过程后立即将其删除。这通常意味着存储过程只用一次。

  • 72-73: 请确认是否有意在调用attributeMailToInformation存储过程后立即将其删除。这通常意味着存储过程只用一次。

core/src/main/java/org/zstack/core/encrypt/EncryptFacadeImpl.java (6)
  • 369-382: @Transactional 注解已经被添加到 removeConvertRecoverData 方法。请确保所有数据库操作都符合预期,以维护数据一致性。

  • 384-393: start 方法已经被修改,包括了新的方法调用。请确保这些方法调用的顺序和逻辑符合预期的初始化流程。

  • 277-324: 新添加的 handleNewAddedEncryptEntity 方法包含处理新加密实体的逻辑。请确保这个方法的实现与加密恢复过程的要求一致。

  • 326-343: 新添加的 collectEncryptEntityMetadata 方法包含收集元数据的逻辑。请验证这个方法的实现是否有助于简化恢复过程中的数据转换。

  • 345-358: 新添加的 createIfNotExists 方法包含创建不存在的元数据的逻辑。请确保这个方法的实现与元数据创建的要求一致。

  • 360-366: 新添加的 updateEncryptDataStateIfExists 方法包含更新加密状态的逻辑。请确保这个方法的实现与加密状态更新的要求一致。

Comment on lines 3 to 11
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.zstack.core.Platform;
import org.zstack.core.cloudbus.CloudBus;
import org.zstack.core.componentloader.PluginRegistry;
import org.zstack.core.config.GlobalConfig;
import org.zstack.core.config.GlobalConfigBeforeUpdateExtensionPoint;
import org.zstack.core.config.GlobalConfigUpdateExtensionPoint;
import org.zstack.core.config.*;
import org.zstack.core.convert.PasswordConverter;
import org.zstack.core.db.DatabaseFacade;
import org.zstack.core.db.SQLBatch;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用通配符导入 (org.zstack.core.config.*) 可能会导致命名空间冲突,并且降低了代码的可读性。建议明确列出所需的类。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants