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

Secure value censorship refactor #2424

Merged
merged 25 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
267280e
Commit first set of changes (broken)
awharn Jan 17, 2025
e0e0929
Fix tests and logic
awharn Jan 22, 2025
7c4ad2c
Make imports more specific
awharn Jan 22, 2025
68fb52e
Add tests
awharn Jan 24, 2025
aeb7e91
Add more tests, fix envQuery defect, handle multiple option definitions
awharn Jan 30, 2025
7f172f6
Rearrange code a bit
awharn Feb 3, 2025
28e3d8c
Merge remote-tracking branch 'origin/master' into secure-value-censor…
awharn Feb 3, 2025
d0553d0
Fix test coverage
awharn Feb 3, 2025
64af500
Try to increase coverage
awharn Feb 3, 2025
d15e823
handleSchema tests
awharn Feb 3, 2025
dcad7cb
Add additional tests
awharn Feb 3, 2025
01d643a
Refactor and update tests
awharn Feb 5, 2025
2a4aab7
Refactor code to optimize for config property duplication
awharn Feb 6, 2025
b5dd0f0
Fix tests
awharn Feb 6, 2025
6e44d21
Get tests to pass
awharn Feb 6, 2025
ea53f38
Make some code smells and add changelog
awharn Feb 6, 2025
2925884
Small changelog tweak
awharn Feb 6, 2025
1f427d1
Fix #2430, move environment variable, and update tests
awharn Feb 7, 2025
5e1a7e5
Merge remote-tracking branch 'origin/master' into secure-value-censor…
awharn Feb 10, 2025
7f37123
Fix broken Copy system tests
awharn Feb 10, 2025
83f29aa
Combine imports
awharn Feb 10, 2025
8b713e8
Update changelog
awharn Feb 10, 2025
348b65d
Make most of Trae's requested changes
awharn Feb 14, 2025
9884e5a
Merge remote-tracking branch 'origin/master' into secure-value-censor…
awharn Feb 18, 2025
94364f5
Merge branch 'master' into secure-value-censor-refactor
zFernand0 Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ describe("TargetProfileHandler", () => {
api: {
layers: { get: jest.fn() },
profiles: { get: getProfileMock },
secure: { secureFields: jest.fn().mockReturnValue([]) }
secure: { findSecure: jest.fn().mockReturnValue([]), securePropsForProfile: jest.fn().mockReturnValue([]) }
},
exists: true
exists: true,
mProperties: { profiles: {} }
},
envVariablePrefix: "ZOWE",
loadedConfig: {}
Expand Down
12 changes: 12 additions & 0 deletions packages/imperative/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

All notable changes to the Imperative package will be documented in this file.

## Recent Changes

- BugFix: Fixed inconsistent behavior with the `ZOWE_SHOW_SECURE_ARGS` environment variable continuing to mask secure properties when it should not. [#2430](https://github.com/zowe/zowe-cli/issues/2430)
- Enhancement: Added the `Censor` class, consolidating all sensitive data hiding logic into one class. [#2424](https://github.com/zowe/zowe-cli/pull/2424)
- Enhancement: Added the `showSecureArgs` environment variable to the `EnvironmentalVariableSettings` class to allow extenders to determine if they should mask secure values. [#2424](https://github.com/zowe/zowe-cli/pull/2424)
- Deprecated: The `LoggerUtils` class has been deprecated. Use the `Censor` class instead. [#2424](https://github.com/zowe/zowe-cli/pull/2424)
- Deprecated: The `CliUtils.CENSOR_RESPONSE` property has been deprecated. Use the `Censor.CENSOR_RESPONSE` property instead. [#2424](https://github.com/zowe/zowe-cli/pull/2424)
- Deprecated: The `CliUtils.CENSORED_OPTIONS` property has been deprecated. Use the `Censor.CENSORED_OPTIONS` property instead. [#2424](https://github.com/zowe/zowe-cli/pull/2424)
- Deprecated: The `CliUtils.censorCLIArgs` function has been deprecated. Use the `Censor.censorCLIArgs` function instead. [#2424](https://github.com/zowe/zowe-cli/pull/2424)
- Deprecated: The `CliUtils.censorYargsArguments` function has been deprecated. Use the `Censor.censorYargsArguments` function instead. [#2424](https://github.com/zowe/zowe-cli/pull/2424)

## `8.13.0`

- Format fix: `DeferredPromise` and `DeferredPromise.unit.test` comment format changed to match standard.

## `8.11.0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ Object {
"key": "IMP_INTEGRATION_TESTING_PROMPT_PHRASE",
"value": undefined,
},
"showSecureArgs": Object {
"key": "IMP_INTEGRATION_TESTING_SHOW_SECURE_ARGS",
"value": "FALSE",
},
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("imperative-test-cli test masking command", () => {
TestLogger.info(`Working directory: ${TEST_ENVIRONMENT.workingDir}`);
runCliScript(__dirname + "/../config/init/__scripts__/init_config.sh", TEST_ENVIRONMENT.workingDir, ["--no-prompt"]);
runCliScript(__dirname + "/../config/set/__scripts__/set_secure.sh", TEST_ENVIRONMENT.workingDir,
["profiles.secured.profiles.secure_profile.properties.info", "secret"]);
["profiles.secured.properties.info", "secret"]);
});

const _logPrefix = (_log: string, level: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export const MaskingDefinition: ICommandDefinition = {
summary: "Test imperative masking",
type: "command",
handler: __dirname + "/Masking.handler",
profile: {
optional: ["secured"]
},
positionals: [{
name: "test-argument",
name: "info",
description: "test argument",
type: "string",
required: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ import { IHandlerParameters, ICommandHandler, Imperative } from "../../../../../
export default class MaskingHandler implements ICommandHandler {
public async process(params: IHandlerParameters) {
// Issue various log messages to the console logger
params.response.console.log("Test-Masking: console logger: log message: " + params.arguments.testArgument);
params.response.console.error("Test-Masking: console logger: error message: " + params.arguments.testArgument);
params.response.console.errorHeader("Test-Masking: console logger: errorHeader message: " + params.arguments.testArgument);
params.response.console.prompt("Test-Masking: console logger: prompt message: " + params.arguments.testArgument);
params.response.console.log("Test-Masking: console logger: log message: " + params.arguments.info);
params.response.console.error("Test-Masking: console logger: error message: " + params.arguments.info);
params.response.console.errorHeader("Test-Masking: console logger: errorHeader message: " + params.arguments.info);
params.response.console.prompt("Test-Masking: console logger: prompt message: " + params.arguments.info);

// Issue various log messages to the imperative logger
Imperative.api.imperativeLogger.trace("Test-Masking: imperative logger: trace message: " + params.arguments.testArgument);
Imperative.api.imperativeLogger.debug("Test-Masking: imperative logger: debug message: " + params.arguments.testArgument);
Imperative.api.imperativeLogger.info("Test-Masking: imperative logger: info message: " + params.arguments.testArgument);
Imperative.api.imperativeLogger.warn("Test-Masking: imperative logger: warn message: " + params.arguments.testArgument);
Imperative.api.imperativeLogger.error("Test-Masking: imperative logger: error message: " + params.arguments.testArgument);
Imperative.api.imperativeLogger.fatal("Test-Masking: imperative logger: fatal message: " + params.arguments.testArgument);
Imperative.api.imperativeLogger.trace("Test-Masking: imperative logger: trace message: " + params.arguments.info);
Imperative.api.imperativeLogger.debug("Test-Masking: imperative logger: debug message: " + params.arguments.info);
Imperative.api.imperativeLogger.info("Test-Masking: imperative logger: info message: " + params.arguments.info);
Imperative.api.imperativeLogger.warn("Test-Masking: imperative logger: warn message: " + params.arguments.info);
Imperative.api.imperativeLogger.error("Test-Masking: imperative logger: error message: " + params.arguments.info);
Imperative.api.imperativeLogger.fatal("Test-Masking: imperative logger: fatal message: " + params.arguments.info);

// Issue various log messages to the app logger
Imperative.api.appLogger.trace("Test-Masking: app logger: trace message: " + params.arguments.testArgument);
Imperative.api.appLogger.debug("Test-Masking: app logger: debug message: " + params.arguments.testArgument);
Imperative.api.appLogger.info("Test-Masking: app logger: info message: " + params.arguments.testArgument);
Imperative.api.appLogger.warn("Test-Masking: app logger: warn message: " + params.arguments.testArgument);
Imperative.api.appLogger.error("Test-Masking: app logger: error message: " + params.arguments.testArgument);
Imperative.api.appLogger.fatal("Test-Masking: app logger: fatal message: " + params.arguments.testArgument);
Imperative.api.appLogger.trace("Test-Masking: app logger: trace message: " + params.arguments.info);
Imperative.api.appLogger.debug("Test-Masking: app logger: debug message: " + params.arguments.info);
Imperative.api.appLogger.info("Test-Masking: app logger: info message: " + params.arguments.info);
Imperative.api.appLogger.warn("Test-Masking: app logger: warn message: " + params.arguments.info);
Imperative.api.appLogger.error("Test-Masking: app logger: error message: " + params.arguments.info);
Imperative.api.appLogger.fatal("Test-Masking: app logger: fatal message: " + params.arguments.info);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ export const config: IImperativeConfig = {
info: {
type: "string",
includeInTemplate: true,
optionDefinition: {...infoOption, required: true}
optionDefinition: infoOption
},
secret: {
type: "string",
secure: true,
optionDefinition: {...secretOption, required: true}
optionDefinition: secretOption
}
}
}
Expand Down
Loading
Loading