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

ConfigSecure.securePropsForProfile may return properties for wrong profile #1893

Closed
t1m0thyj opened this issue Apr 19, 2022 · 1 comment
Closed
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

@t1m0thyj
Copy link
Member

correction, it's this.mConfig.api.secure.securePropsForProfile instead of ConfigUtils.getActiveProfileName that causes an issue.

it still happens to me after syncing with next this morning. i dont get an issue using @t1m0thyj's sample profile with lpar1.zosmf and lpar2.zosmf, but i do get an issue with lpar1.zosmf and lpar1.zosmf2 as in my example.

two instances of zosmf on the sample lpar2 don't make sense, but i the lpar higher level is an arbitrary construction.

Here is the code with trace messages added:

    public securePropsForProfile(profileName: string) {
        console.log(`>>>> entry <<<<`)
        const profilePath = this.mConfig.api.profiles.expandPath(profileName);
        console.log(`profilePath: ${profilePath}`)
        const secureProps = [];
        for (const propPath of this.secureFields()) {
            console.log(`propPath: ${propPath}`)
            const pathSegments = propPath.split(".");  // profiles.XXX.properties.YYY
            // eslint-disable-next-line @typescript-eslint/no-magic-numbers
            if (profilePath.startsWith(pathSegments.slice(0, -2).join("."))) {
                secureProps.push(pathSegments.pop());
            }
        }
        console.log(`secureProps ${secureProps}`)
        console.log(`>>>> exit <<<<`)
        return secureProps;
    }

here's the command i run and output I see:

C:\dev\systems\ca11>zowe jobs list jobs --show-inputs-only --zosmf-p lpar1.zosmf2
>>>> entry <<<<
profilePath: profiles.lpar1.profiles.zosmf2
propPath: profiles.lpar1.profiles.zosmf.properties.host
propPath: profiles.my_base.properties.user
propPath: profiles.my_base.properties.password
secureProps host
>>>> exit <<<<
>>>> entry <<<<
profilePath: profiles.my_base
propPath: profiles.lpar1.profiles.zosmf.properties.host
propPath: profiles.my_base.properties.user
propPath: profiles.my_base.properties.password
secureProps user,password
>>>> exit <<<<

it looks like zosmf2 becomes zosmf in ConfigProfiles.expandPath

Originally posted by @dkelosky in zowe/imperative#721 (comment)

@t1m0thyj t1m0thyj added 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. labels Nov 29, 2022
@awharn awharn transferred this issue from zowe/imperative Nov 13, 2023
@t1m0thyj t1m0thyj moved this to Medium Priority in Zowe CLI Squad Dec 26, 2023
@adam-wolfe adam-wolfe mentioned this issue Jan 4, 2024
26 tasks
@adam-wolfe adam-wolfe mentioned this issue Apr 19, 2024
23 tasks
@t1m0thyj
Copy link
Member Author

t1m0thyj commented Apr 25, 2024

Fixed by #2016

Tested with the sample profiles provided by @dkelosky

        "lpar1": {
            "properties": {
                "host": "usilca11.lvn.broadcom.net"
            },
            "profiles": {
                "zosmf": {
                    "type": "zosmf",
                    "properties": {
                        "port": 1443
                    },
                    "secure": [
                        "host"
                    ]
                },
                "zosmf2": {
                    "type": "zosmf",
                    "properties": {
                        "port": 1443
                    },
                    "secure": []
                },

Old Output

$ zowe jobs list jobs --show-inputs-only --zosmf-p lpar1.zosmf2
>>>> entry <<<<
profilePath: profiles.lpar1.profiles.zosmf2
propPath: profiles.lpar1.profiles.zosmf.properties.host
propPath: profiles.my_base.properties.user
propPath: profiles.my_base.properties.password
secureProps host
>>>> exit <<<<
>>>> entry <<<<
profilePath: profiles.my_base
propPath: profiles.lpar1.profiles.zosmf.properties.host
propPath: profiles.my_base.properties.user
propPath: profiles.my_base.properties.password
secureProps user,password
>>>> exit <<<<

New Output

$ zdev jobs list jobs --show-inputs-only --zosmf-p lpar1.zosmf2
>>>> entry <<<<
profilePath: profiles.lpar1.profiles.zosmf2
propPath: profiles.lpar1.profiles.zosmf.properties.host
propPath: profiles.base.properties.user
propPath: profiles.base.properties.password
secureProps 
>>>> exit <<<<
>>>> entry <<<<
profilePath: profiles.base
propPath: profiles.lpar1.profiles.zosmf.properties.host
propPath: profiles.base.properties.user
propPath: profiles.base.properties.password
secureProps user,password
>>>> exit <<<<

We still iterate over the same properties, but host is now ignored since it comes from a different profile.

@github-project-automation github-project-automation bot moved this from Medium Priority to Closed in Zowe CLI Squad Apr 25, 2024
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
None yet
Development

No branches or pull requests

1 participant