zowe / zowe-cli

Zowe CLI
Eclipse Public License 2.0
114 stars 86 forks source link

ProfileInfo API may create extraneous base profile when updating credentials #2275

Open t1m0thyj opened 1 month ago

t1m0thyj commented 1 month ago

Actual Behavior When ProfileInfo.updateProperty is used to update user & password in a nested profile inside Project Config, an unexpected base profile may be created.

Expected Behavior The ProfileInfo API should not create a new profile when asked to update properties inside an existing profile.

Steps to Reproduce

  1. Create a Global Config with flat structure that includes base profile (e.g. result of zowe config init)
  2. Create a Project Config with nested zosmf profile (e.g. lpar1.zosmf) and w/o base profile
  3. Use the ProfileInfo API to update user & password in the nested zosmf profile:
    const { ProfileInfo } = require("@zowe/imperative");
    (async () => {
        const profInfo = new ProfileInfo("zowe");
        await profInfo.readProfilesFromDisk();
        const upd = { profileName: "lpar1.zosmf", profileType: "zosmf" };
        await profInfo.updateProperty({ ...upd, property: "user", value: "abc", setSecure: true });
        await profInfo.updateProperty({ ...upd, property: "password", value: "def", setSecure: true });
    })();
  4. Notice that a new base profile gets created in Project Config which contains only a user property:
    "base": {
      "properties": {},
      "secure": [
        "user"
      ]
    }
github-actions[bot] commented 1 month ago

Thank you for creating a bug report. We will investigate the bug and evaluate its impact on the product. If you haven't already, please ensure you have provided steps to reproduce the bug and as much context as possible.