UNPKG

@zowe/imperative

Version:
105 lines 5.16 kB
import { Arguments } from "yargs"; import { ICensorOptions } from "./doc/ICensorOptions"; import { ICommandProfileTypeConfiguration } from "../../cmd/src/doc/profiles/definition/ICommandProfileTypeConfiguration"; import { IProfileSchema } from "../../profiles/src/doc/definition/IProfileSchema"; import { IProfileTypeConfiguration } from "../../profiles/src/doc/config/IProfileTypeConfiguration"; export declare class Censor { /********************************************************************* * Basic censorship items - list definitions & initialiazations, etc. * **********************************************************************/ private static readonly MAIN_CENSORED_OPTIONS; private static readonly MAIN_SECURE_PROMPT_OPTIONS; static readonly CENSOR_RESPONSE = "****"; static readonly NULL_SESS_OBJ_MSG = "Null session object was passed to API"; static get DEFAULT_CENSORED_OPTIONS(): string[]; static get SECURE_PROMPT_OPTIONS(): string[]; private static mCensoredOptions; static get CENSORED_OPTIONS(): string[]; private static mConfig; /** * Singleton implementation of an internal reference to the schema */ private static mSchema; /** * Helper method to get an internal reference to the loaded profiles */ static get profileSchemas(): ICommandProfileTypeConfiguration[]; /** * Helper method to set an internal reference to loaded profiles * @param _schemas - The schmas to pass in to set to the logger */ static setProfileSchemas(_schemas: IProfileTypeConfiguration[] | Map<string, IProfileSchema>): void; /**************************************************** * Helper functions for more advanced functionality * ****************************************************/ /** * Helper function to handle profile schemas when setting the censored options * @param {IProfileTypeConfiguration | ICommandProfileTypeConfiguration} profileType - the profile type configuration to iterate over */ private static handleSchema; /** * Add a censored option, including it's camelCase and kebabCase versions * @param {string} option - The option to censor */ private static addCensoredOption; /** * Specifies whether a given property path (e.g. "profiles.lpar1.properties.host") is a special value or not. * Special value: Refers to any value defined as secure in the schema definition. * These values should be already masked by the application (and/or plugin) developer. * @param prop Property path to determine if it is a special value * @returns True - if the given property is to be treated as a special value; False - otherwise */ static isSpecialValue(prop: string): boolean; /** * Identifies if a property is a secure property * @param {string} prop - The property to check * @returns {boolean} - True if the property is secure; False otherwise */ static isSecureValue(prop: string): boolean; /**************************************************************************************** * Bread and butter functions, setting up the class and performing censorship of values * ****************************************************************************************/ /** * Generate and set the list of censored options. * Attempt to source the censored options from the schema, config, and/or command being executed. * @param {ICensorOptions} censorOpts - The objects to use to gather options that should be censored */ static setCensoredOptions(censorOpts?: ICensorOptions): void; /** * Copy and censor any sensitive CLI arguments before logging/printing * @param {string[]} args - The args list to censor * @returns {string[]} */ static censorCLIArgs(args: string[]): string[]; /** * Copy and censor any sensitive CLI arguments before logging/printing * @param {string} data - the data to censor * @returns {string} - the censored data */ static censorRawData(data: string, category?: string): string; /** * Copy and censor a yargs argument object before logging * @param {yargs.Arguments} args - the args to censor * @returns {yargs.Arguments} - a censored copy of the arguments */ static censorYargsArguments(args: Arguments): Arguments; /** * Censor sensitive data from an session object or a sub-object of a session. * The intent is to create a copy of the object that is suitable for logging. * * @param sessObj - A Session object (or ISession, or availableCreds) to be censored. * * @returns - The censored object as a string. */ static censorSession(sessObj: any): string; /** * Recursively replace sensitive data in an session-related object * and any relevant sub-objects. * * @param sessObj - A Session object (or ISession, or the availableCreds) to be censored. * * @returns - The censored object as a string. */ private static replaceValsInSess; } //# sourceMappingURL=Censor.d.ts.map