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

How to access a root untyped profile using profInfo.getAllProfiles? #2185

Open
davidkjackson54 opened this issue Jun 26, 2024 · 7 comments
Open
Labels
bug Something isn't working priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex.

Comments

@davidkjackson54
Copy link

davidkjackson54 commented Jun 26, 2024

I have a VSCode Explorer extension where I allow the user to manage credentials.
This works fine for the instance whereby the secureArgs are present in the system profile - or defined in the default base profile.

However, there is an article from the zowe folk - https://medium.com/zowe/password-management-for-zowe-cli-profiles-c57f64d1fe88
suggesting that the preferred method is to not use the base profile but instead specify a top level root profile that is untyped.

Something like this:

SecureArgs are present in the top level but also in a system profile to allow the user to specifically enter credentials for that system.
The problem arises in that there seems to be no obvious method in a VSCode extension to get that top level untyped profile . I use profInfo.readProfilesfromDIsk followed by profInfo.getAllProfiles but you can only retrieve typed profiles.

There doesn't seem to be any way of retrieving that top level untyped profile - or indeed know if such a top level profile exists.
Equally how do I update an untyped profile as profInfo.,updateProperty takes in propOpts one of which iso the profile name - so won't work for an untyped profile.

{
    "$schema": "./zowe.schema.json",
    "profiles": {
     "D001": {
       "properties": {
         "host": "myHost",
          "protocol": "https",
          "rejectUnauthorized": false,
       },
       **"secure": [
         "user",
         "password"
       ],**
       "profiles": {
           "u830all": {
             "type": "zmf",
             "properties": {            
               "port": 9990
             }
         },
           "u830dp": {
             "type": "zmf",
             "properties": {
              "port": 9991
             },
             **"secure": [
                "user",
               "password"
             ]**
          }
        }
       }
     }
  }
@davidkjackson54 davidkjackson54 added bug Something isn't working new The issue wasn't triaged yet labels Jun 26, 2024
Copy link

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.

@JTonda JTonda added priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex. and removed new The issue wasn't triaged yet labels Jul 1, 2024
@t1m0thyj
Copy link
Member

@davidkjackson54 Thanks for reporting this!

We plan to enhance the updateProperty method so that it supports typeless profiles. Even if getAllProfiles returns only typed profiles, this makes it possible to update credentials that are inherited and have a jsonLoc pointing to a higher-level typeless profile:

await profInfo.updateProperty({ profileName: "D001", profileType: null, property: "password", value: "XXX" });

@davidkjackson54
Copy link
Author

davidkjackson54 commented Jul 16, 2024

Sadly that isn’t going to help in any great way.
It is still not going to retrieve the existing secure values already stored.
Are you saying that you will NOT enhance secureFields to optionally retrieve the secure args and the argType? As that solves the problems quite easily.
As it stands zowe config secure — gc is very basic and doesn’t offer the user any display of existing args and does no validation of what is entered so a user can enter any value to the Userid prompt and it is accepted regardless.

For the VSCode user I want to offer a webview that shows the existing values and allow the user to over type.

@t1m0thyj
Copy link
Member

Are you saying that you will NOT enhance secureFields to optionally retrieve the secure args and the argType?

Would the desired behavior be a method that returns an array of all secure fields defined in the following format?

{
  argName: 'password',
  dataType: 'string',
  argValue: undefined,
  argLoc: {
    locType: 1,
    osLoc: [ '/Users/Timothy/Projects/zowe/zowe-cli/zowe.config.json' ],
    jsonLoc: 'profiles.D001.properties.password'
  },
  inSchema: true,
  secure: true
}

@davidkjackson54
Copy link
Author

If we use secureFields and we are provided the argValue, argType and argName - that would suffice.
With that, we can present existing values and allow the user to overtype and then we can put the updates path values back into the vault in the same manner that zowe config secure —gc does currently.

I will be able to validate that an entered value is correct - if it is argType user I can ensure that it is a valid TSO format. If for example rejectunauthorized were a secure field and therefore presented by secureFields , I can ensure that the field is treated as a Boolean and validated as such.
I don’t thing much more would be necessary beyond that.

@t1m0thyj
Copy link
Member

t1m0thyj commented Jul 17, 2024

There seem to be 3 related fixes/enhancements which should probably be tracked as separate issues:

@davidkjackson54
Copy link
Author

I think that probably makes sense .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex.
Projects
Status: Medium Priority
Development

No branches or pull requests

3 participants