Skip to content

Commit

Permalink
Hide displaying password (use ******) in the config list command
Browse files Browse the repository at this point in the history
  • Loading branch information
gvensan committed Feb 1, 2024
1 parent 6db4f34 commit bdf44b8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stm",
"version": "0.0.26",
"version": "0.0.27",
"description": "Solace Try-Me Command Line Tool",
"keywords": [
"solace",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/checkparams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const checkConnectionParamsExists = (url: string | undefined, vpn :string
}

if (!password) {
Logger.logError("required option '--password <PASS>' not specified")
Logger.logError("required option '--password <PASSWORD>' not specified")
Logger.logError('exiting...')
process.exit(1)
}
Expand Down
5 changes: 0 additions & 5 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ export const saveConfig = (data: any) => {
writeFile(filePath, data)
if (!fileExists(filePath)) Logger.logSuccess(`saved configuration to '${decoratePath(configFile)}' successfully`)
else Logger.logSuccess(`${updated ? 'updated configuration' : 'initialized configuration with default command settings'} on '${decoratePath(configFile)}' successfully`)
// if (!updated)
// Logger.logHint(
// `\nThe initialized configuration points to a local broker running on 'localhost:8080' and the default settings for broker, username and password for messaging and semp operations. You can modify the settings with 'save' option when executing commands.\n` +
// `\nThe configuration is pre-populated with command configurations with default settings for messaging operations like publish, receive, request and reply. It also comes with a sample resource management commands for creating queue, acl-profile, client-profile and client-name. These management commands can be modified to update or delete resources.\n` +
// `\nThe command settings can be updated, copied to a new command and referred to by name during the execution. Be sure to checkou the help (-h, --help) for basic options, more help (-hm, --help-examples) for advanced options and command examples (-he, --help-examples) on the CLI commands.`)
} catch (error: any) {
Logger.logDetailedError('file write failed', error.toString())
if (error.cause?.message) Logger.logDetailedError(``, `${error.cause?.message}`)
Expand Down
10 changes: 5 additions & 5 deletions src/utils/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ export const listConfig = (options:StmConfigOptions, optionsSource: any) => {
count++
table.addRow(config.connection.command, config.connection.command.toUpperCase(),
config.connection.url, config.connection.vpn, config.connection.username,
config.connection.password)
"******")
table.addRow(config.sempconnection.command, config.sempconnection.command.toUpperCase(),
config.sempconnection.sempUrl, config.sempconnection.sempVpn, config.sempconnection.sempUsername,
config.sempconnection.sempPassword)
"******")
table.setJustify(false);
console.log(table.toString());

Expand All @@ -163,11 +163,11 @@ export const listConfig = (options:StmConfigOptions, optionsSource: any) => {
if (typeof selected.topic !== 'object' || (typeof selected.topic === 'object' && selected.topic.length === 1)) {
table.addRow((selected.command.toUpperCase() !== lastOp ? selected.command.toUpperCase() : ''),
selected.name, JSON.stringify(selected.topic), config.connection.url,
config.connection.vpn, config.connection.username + '/' + config.connection.password)
config.connection.vpn, config.connection.username + '/' + "******")
} else {
table.addRow((selected.command.toUpperCase() !== lastOp ? selected.command.toUpperCase() : ''),
selected.name, '[ ', config.connection.url,
config.connection.vpn, config.connection.username + '/' + config.connection.password)
config.connection.vpn, config.connection.username + '/' + "******")
for (var i=0; i<selected.topic.length; i++) {
table.addRow('', '', ' "' + selected.topic[i] + (i === selected.topic.length-1 ? '"' : '",'), '', '', '');
}
Expand Down Expand Up @@ -198,7 +198,7 @@ export const listConfig = (options:StmConfigOptions, optionsSource: any) => {
table.addRow((selected.command.toUpperCase() !== lastOp ? selected.command.toUpperCase() : ''),
selected.operation.toUpperCase(), selected.name,
config.sempconnection.sempUrl, config.sempconnection.sempVpn,
config.sempconnection.sempUsername + '/' + config.sempconnection.sempPassword)
config.sempconnection.sempUsername + '/' + "******")
lastOp = selected.command.toUpperCase();
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/utils/visualize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const visualize = async (options: MessageClientOptions) => {
const config = loadCommandFromConfig('connection', options);
const url = new URL(config.url);
console.log(config.url, '\n', url);
console.log(url.hostname, config.url.substring(config.url.lastIndexOf(':')+1), config.username, config.password);
console.log(url.hostname, config.url.substring(config.url.lastIndexOf(':')+1), config.username, "******");
var publicDir = __dirname.substring(0, __dirname.lastIndexOf('solace-tryme-cli') + 16);

const express = require('express');
Expand Down

0 comments on commit bdf44b8

Please sign in to comment.