wso2 / micro-integrator

The cloud-native configuration driven runtime that helps developers implement composite microservices.
https://wso2.com/integration/
Apache License 2.0
198 stars 215 forks source link

[migration-service] When it is encrypted on cipher tool and no secure vault encrypted entries are found, FileNotFoundException occurs. #1916

Open isuruuy429 opened 4 years ago

isuruuy429 commented 4 years ago

Steps to reproduce:

  1. Encrypt password from cipher tool. (An encrypted example as below in deployment.toml file)
    
    [[datasource]]
    id = "WSO2CarbonDB"
    url= "jdbc:mysql://localhost:3306/userdb2"
    username="root"
    password= "$secret{db_password}"
    driver="com.mysql.jdbc.Driver"
    pool_options.maxActive=50
    pool_options.maxWait = 60000
    pool_options.testOnBorrow = true

[realm_manager] data_source = "WSO2CarbonDB"

[internal_apis.file_user_store] enable = false

[user_store] class = "org.wso2.micro.integrator.security.user.core.jdbc.JDBCUserStoreManager" type = "database" read_only = false

[secrets] db_password = "FnbXlcr4DhbOQ31xJFdTT/1jBnAN61Q7dYxcGMC7GIhppAEwRFOCNichtbHy/Wj6+OfKiZ2ywq685dUml10f37WoBfKVzVcLE/PePIloraXQuK6sQ6U8Ar0QJGwQHMfSDQhfIO5savwmiocOZX+/9kyd2GIUS6Kw8R0U24EgccKie0vRLmsLsZ4E6fGlfiJEYejQ5F6i8Y7H9HG8b3fyK0T3UzjTdE0M+pjNWKRRfPkjlaGhMPzLm4vWQPR6R5AUaHpoMc8rz+S5zjoYadPtfX2Rj2eUw5mVEKg4VuPZUOlnUr2mhK3i0csjycpCa4i/dZPkT26O/cV7aTbC9WBvKA=="


2. Decrypt it as described in https://github.com/wso2/micro-integrator/tree/master/migration/migration-service

**Expected**: No stack trace to be printed. A WARN log is suggested. 
**Actual**: 

[2020-07-23 15:39:56,252] INFO {org.wso2.mi.migration.internal.MIMigrationServiceComponent} - Initiating WSO2 MI password migration [2020-07-23 15:39:56,261] ERROR {org.wso2.mi.migration.utils.MigrationIOUtils} - Error while reading /Users/isuruuy/Desktop/RND/EI7/Q2/mi-release/rc/wso2mi-1.1.0/registry/config/repository/components/secure-vault/secure-vault.properties java.io.FileNotFoundException: /Users/isuruuy/Desktop/RND/EI7/Q2/mi-release/rc/wso2mi-1.1.0/registry/config/repository/components/secure-vault/secure-vault.properties (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.(FileInputStream.java:138) at java.io.FileInputStream.(FileInputStream.java:93) at org.wso2.mi.migration.utils.MigrationIOUtils.getProperties(MigrationIOUtils.java:67) at org.wso2.mi.migration.migrate.PasswordMigrationClient.(PasswordMigrationClient.java:56) at org.wso2.mi.migration.internal.MIMigrationServiceComponent.migratePasswords(MIMigrationServiceComponent.java:60) at org.wso2.mi.migration.internal.MIMigrationServiceComponent.activate(MIMigrationServiceComponent.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260) at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146) at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:345) at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620) at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197) at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473) at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217) at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816) at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783) at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89) at java.lang.Thread.run(Thread.java:748)

[2020-07-23 15:39:56,263] WARN {org.wso2.mi.migration.utils.MigrationIOUtils} - Migration directory does not exists in path /Users/isuruuy/Desktop/RND/EI7/Q2/mi-release/rc/wso2mi-1.1.0/migration [2020-07-23 15:39:56,264] INFO {org.wso2.mi.migration.utils.MigrationIOUtils} - Created directory /Users/isuruuy/Desktop/RND/EI7/Q2/mi-release/rc/wso2mi-1.1.0/migration [2020-07-23 15:39:56,269] INFO {org.wso2.mi.migration.migrate.PasswordMigrationClient} - Decrypted secrets were written to /Users/isuruuy/Desktop/RND/EI7/Q2/mi-release/rc/wso2mi-1.1.0/migration/cipher-text-decrypted.properties [2020-07-23 15:39:56,270] INFO {org.wso2.mi.migration.internal.MIMigrationServiceComponent} - Successfully completed password migration

tishan89 commented 3 years ago

@sachithKay Did you start any work on this?

sachithKay commented 3 years ago

@tishan89 this has not been started.