@rockcarver/frodo-cli 2.0.0-17 → 2.0.0-19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/esm/cli/FrodoCommand.js +1 -1
- package/esm/cli/FrodoCommand.js.map +1 -1
- package/esm/cli/log/log-fetch.js +48 -26
- package/esm/cli/log/log-fetch.js.map +1 -1
- package/esm/cli/log/log-list.js +49 -28
- package/esm/cli/log/log-list.js.map +1 -1
- package/esm/cli/log/log-tail.js +47 -26
- package/esm/cli/log/log-tail.js.map +1 -1
- package/esm/cli/script/script-import.js +1 -1
- package/esm/cli/script/script-import.js.map +1 -1
- package/esm/ops/ScriptOps.js +46 -1
- package/esm/ops/ScriptOps.js.map +1 -1
- package/esm/ops/SecretsOps.js +3 -3
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/ServiceOps.js +1 -1
- package/esm/ops/ServiceOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +3 -3
- package/esm/ops/VariablesOps.js.map +1 -1
- package/esm/utils/ExportImportUtils.js +8 -78
- package/esm/utils/ExportImportUtils.js.map +1 -1
- package/package.json +2 -2
- package/esm/cli/theme/theme-list.e2e.test_.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0-18] - 2023-10-02
|
|
11
|
+
|
|
12
|
+
## [2.0.0-17] - 2023-09-29
|
|
13
|
+
|
|
10
14
|
## [2.0.0-16] - 2023-09-08
|
|
11
15
|
|
|
12
16
|
## [2.0.0-15] - 2023-08-17
|
|
@@ -1347,7 +1351,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1347
1351
|
- Fixed problem with adding connection profiles
|
|
1348
1352
|
- Miscellaneous bug fixes
|
|
1349
1353
|
|
|
1350
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-
|
|
1354
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-18...HEAD
|
|
1355
|
+
|
|
1356
|
+
[2.0.0-18]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-17...v2.0.0-18
|
|
1357
|
+
|
|
1358
|
+
[2.0.0-17]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-16...v2.0.0-17
|
|
1351
1359
|
|
|
1352
1360
|
[2.0.0-16]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-15...v2.0.0-16
|
|
1353
1361
|
|
package/esm/cli/FrodoCommand.js
CHANGED
|
@@ -110,7 +110,7 @@ export class FrodoCommand extends FrodoStubCommand {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
// additional help
|
|
113
|
-
this.addHelpText('after', `\nEvironment Variables:\n` + ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\n` + ` FRODO_REALM: Realm. Overrides 'realm' argument.\n` + ` FRODO_USERNAME: Username. Overrides 'username' argument.\n` + ` FRODO_PASSWORD: Password. Overrides 'password' argument.\n` + ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\n` + ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\n` + ('frodo conn save' === this.name() ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\n` + ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\n` : ``) + (this.name().startsWith('frodo
|
|
113
|
+
this.addHelpText('after', `\nEvironment Variables:\n` + ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\n` + ` FRODO_REALM: Realm. Overrides 'realm' argument.\n` + ` FRODO_USERNAME: Username. Overrides 'username' argument.\n` + ` FRODO_PASSWORD: Password. Overrides 'password' argument.\n` + ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\n` + ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\n` + ('frodo conn save' === this.name() ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\n` + ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\n` : ``) + (this.name().startsWith('frodo log') ? ` FRODO_LOG_KEY: Log API key. Overrides 'username' argument.\n` + ` FRODO_LOG_SECRET: Log API secret. Overrides 'password' argument.\n` : ``) + ` FRODO_CONNECTION_PROFILES_PATH: Use this connection profiles file instead of '~/.frodo/Connections.json'.\n` + ` FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.\n` + ` FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.\n` + ` FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.\n` + ` FRODO_MASTER_KEY: Use this master key instead of '~/.frodo/masterkey.key' file. Takes precedence over FRODO_MASTER_KEY_PATH.\n`);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrodoCommand.js","names":["state","Argument","Command","Option","fs","globalConfig","createProgressIndicator","curlirizeMessage","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","verboseMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","insecureOption","verboseOption","debugOption","curlirizeOption","defaultArgs","defaultOpts","stateMap","name","host","setHost","realm","setRealm","username","setUsername","password","setPassword","attributeName","saId","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","type","setDeploymentType","insecure","setAllowInsecureConnection","verbose","setVerbose","debug","setDebug","curlirize","setCurlirize","FrodoStubCommand","constructor","on","_error$config","_error$config2","_error$response","config","method","url","response","stack","exitCode","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","addHelpText","startsWith","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","length","Object","keys","handler","k"],"sources":["../../src/cli/FrodoCommand.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Argument, Command, Option } from 'commander';\nimport fs from 'fs';\n\nimport * as globalConfig from '../storage/StaticStorage';\nimport {\n createProgressIndicator,\n curlirizeMessage,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n verboseMessage,\n} from '../utils/Console.js';\n\nconst hostArgument = new Argument(\n '[host]',\n 'Access Management base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.'\n);\n\nconst realmArgument = new Argument(\n '[realm]',\n \"Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise.\"\n).default(\n // must check for FRODO_REALM env variable here because otherwise cli will overwrite realm with default value\n process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY,\n '\"alpha\" for Identity Cloud tenants, \"/\" otherwise.'\n);\n\nconst usernameArgument = new Argument(\n '[username]',\n 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.'\n);\n\nconst passwordArgument = new Argument('[password]', 'Password.');\n\nconst serviceAccountIdOption = new Option(\n '--sa-id <sa-id>',\n 'Service account id.'\n);\n\nconst serviceAccountJwkFileOption = new Option(\n '--sa-jwk-file <file>',\n 'File containing the JSON Web Key (JWK) associated with the the service account.'\n);\n\nconst deploymentOption = new Option(\n '-m, --type <type>',\n 'Override auto-detected deployment type. Valid values for type: \\n\\\nclassic: A classic Access Management-only deployment with custom layout and configuration. \\n\\\ncloud: A ForgeRock Identity Cloud environment. \\n\\\nforgeops: A ForgeOps CDK or CDM deployment. \\n\\\nThe detected or provided deployment type controls certain behavior like obtaining an Identity \\\nManagement admin token or not and whether to export/import referenced email templates or how \\\nto walk through the tenant admin login flow of Identity Cloud and handle MFA'\n).choices(globalConfig.DEPLOYMENT_TYPES);\n\nconst insecureOption = new Option(\n '-k, --insecure',\n 'Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability.'\n).default(false, \"Don't allow insecure connections\");\n\nconst verboseOption = new Option(\n '--verbose',\n 'Verbose output during command execution. If specified, may or may not produce additional output.'\n);\n\nconst debugOption = new Option(\n '--debug',\n 'Debug output during command execution. If specified, may or may not produce additional output helpful for troubleshooting.'\n);\n\nconst curlirizeOption = new Option(\n '--curlirize',\n 'Output all network calls in curl format.'\n);\n\nconst defaultArgs = [\n hostArgument,\n realmArgument,\n usernameArgument,\n passwordArgument,\n];\n\nconst defaultOpts = [\n serviceAccountIdOption,\n serviceAccountJwkFileOption,\n deploymentOption,\n insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: (host: string) => state.setHost(host),\n [realmArgument.name()]: (realm: string) => state.setRealm(realm),\n [usernameArgument.name()]: (username: string) => state.setUsername(username),\n [passwordArgument.name()]: (password: string) => state.setPassword(password),\n [serviceAccountIdOption.attributeName()]: (saId: string) =>\n state.setServiceAccountId(saId),\n [serviceAccountJwkFileOption.attributeName()]: (file: string) => {\n try {\n const data = fs.readFileSync(file);\n const jwk = JSON.parse(data.toString());\n state.setServiceAccountJwk(jwk);\n } catch (error) {\n printMessage(\n `Error parsing JWK from file ${file}: ${error.message}`,\n 'error'\n );\n }\n },\n [deploymentOption.attributeName()]: (type: string) =>\n state.setDeploymentType(type),\n [insecureOption.attributeName()]: (insecure: boolean) =>\n state.setAllowInsecureConnection(insecure),\n [verboseOption.attributeName()]: (verbose: boolean) =>\n state.setVerbose(verbose),\n [debugOption.attributeName()]: (debug: boolean) => state.setDebug(debug),\n [curlirizeOption.attributeName()]: (curlirize: boolean) =>\n state.setCurlirize(curlirize),\n};\n\n/**\n * Command with default options\n */\nexport class FrodoStubCommand extends Command {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string) {\n super(name);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on('unhandledRejection', (error: any) => {\n printMessage(\n `${error.config?.method ? error.config.method + ' ' : ''}${\n error.config?.url ? error.config.url : ''\n }`,\n 'error'\n );\n printMessage(error.response?.data, 'error');\n printMessage(error.stack, 'error');\n printMessage(\n `Please report this unhandled error here: https://github.com/rockcarver/frodo-cli/issues`,\n 'error'\n );\n process.exitCode = 1;\n });\n\n // other default settings\n this.helpOption('-h, --help', 'Help');\n this.showHelpAfterError();\n this.configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n });\n\n // register default handlers\n state.setPrintHandler(printMessage);\n state.setVerboseHandler(verboseMessage);\n state.setDebugHandler(debugMessage);\n state.setCurlirizeHandler(curlirizeMessage);\n state.setCreateProgressHandler(createProgressIndicator);\n state.setUpdateProgressHandler(updateProgressIndicator);\n state.setStopProgressHandler(stopProgressIndicator);\n }\n}\n\n/**\n * Command with default options\n */\nexport class FrodoCommand extends FrodoStubCommand {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string, omits: string[] = []) {\n super(name);\n\n // register default arguments\n for (const arg of defaultArgs) {\n if (!omits.includes(arg.name())) this.addArgument(arg);\n }\n\n // register default options\n for (const opt of defaultOpts) {\n if (!omits.includes(opt.name())) this.addOption(opt);\n }\n\n // additional help\n this.addHelpText(\n 'after',\n `\\nEvironment Variables:\\n` +\n ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\\n` +\n ` FRODO_REALM: Realm. Overrides 'realm' argument.\\n` +\n ` FRODO_USERNAME: Username. Overrides 'username' argument.\\n` +\n ` FRODO_PASSWORD: Password. Overrides 'password' argument.\\n` +\n ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\\n` +\n ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\\n` +\n ('frodo conn save' === this.name()\n ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\\n`\n : ``) +\n (this.name().startsWith('frodo logs')\n ? ` FRODO_LOG_KEY: Log API key. Overrides 'username' argument.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides 'password' argument.\\n`\n : ``) +\n ` FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.\\n` +\n ` FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.\\n` +\n ` FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.\\n` +\n ` FRODO_MASTER_KEY: Use this master key instead of '~/.frodo/masterkey.key' file. Takes precedence over FRODO_MASTER_KEY_PATH.\\n`\n );\n }\n\n /**\n *\n * @param args\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleDefaultArgsAndOpts(...args: any) {\n const command = args.pop();\n const options = args.pop();\n\n // handle arguments first\n for (const [i, v] of command.args.entries()) {\n if (!command._args[i]) {\n printMessage(\n `${command.args.length} arguments supplied but command only supports ${command._args.length}.`,\n 'warn'\n );\n break;\n }\n const arg = command._args[i].name();\n // handle only default arguments\n if (Object.keys(stateMap).includes(arg)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default argument '${arg}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[arg];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default argument '${arg}'.`\n );\n }\n }\n\n // handle options\n for (const [k, v] of Object.entries(options)) {\n // handle only default options\n if (Object.keys(stateMap).includes(k)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default option '${k}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[k];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default option '${k}'.`\n );\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAOC,EAAE,MAAM,IAAI;AAEnB,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SACEC,uBAAuB,EACvBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,EACvBC,cAAc,QACT,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIZ,QAAQ,CAC/B,QAAQ,EACR,iIACF,CAAC;AAED,MAAMa,aAAa,GAAG,IAAIb,QAAQ,CAChC,SAAS,EACT,yFACF,CAAC,CAACc,OAAO;AACP;AACAC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIb,YAAY,CAACc,iBAAiB,EACzD,oDACF,CAAC;AAED,MAAMC,gBAAgB,GAAG,IAAInB,QAAQ,CACnC,YAAY,EACZ,gHACF,CAAC;AAED,MAAMoB,gBAAgB,GAAG,IAAIpB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;AAEhE,MAAMqB,sBAAsB,GAAG,IAAInB,MAAM,CACvC,iBAAiB,EACjB,qBACF,CAAC;AAED,MAAMoB,2BAA2B,GAAG,IAAIpB,MAAM,CAC5C,sBAAsB,EACtB,iFACF,CAAC;AAED,MAAMqB,gBAAgB,GAAG,IAAIrB,MAAM,CACjC,mBAAmB,EACnB;AACF;AACA;AACA;AACA;AACA;AACA,6EACA,CAAC,CAACsB,OAAO,CAACpB,YAAY,CAACqB,gBAAgB,CAAC;AAExC,MAAMC,cAAc,GAAG,IAAIxB,MAAM,CAC/B,gBAAgB,EAChB,4LACF,CAAC,CAACY,OAAO,CAAC,KAAK,EAAE,kCA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,CAAC,CAACtE,IAAI,CAAC,CAAC;MACnC;MACA,IAAI2E,MAAM,CAACC,IAAI,CAAC7E,QAAQ,CAAC,CAAC4D,QAAQ,CAACD,GAAG,CAAC,EAAE;QACvCpF,YAAY,CACT,qEAAoEoF,GAAI,IAC3E,CAAC;QACD;QACA,MAAMmB,OAAY,GAAG9E,QAAQ,CAAC2D,GAAG,CAAC;QAClCmB,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLjG,YAAY,CACT,yEAAwEoF,GAAI,IAC/E,CAAC;MACH;IACF;;IAEA;IACA,KAAK,MAAM,CAACoB,CAAC,EAAEP,CAAC,CAAC,IAAII,MAAM,CAACH,OAAO,CAACH,OAAO,CAAC,EAAE;MAC5C;MACA,IAAIM,MAAM,CAACC,IAAI,CAAC7E,QAAQ,CAAC,CAAC4D,QAAQ,CAACmB,CAAC,CAAC,EAAE;QACrCxG,YAAY,CACT,mEAAkEwG,CAAE,IACvE,CAAC;QACD;QACA,MAAMD,OAAY,GAAG9E,QAAQ,CAAC+E,CAAC,CAAC;QAChCD,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLjG,YAAY,CACT,uEAAsEwG,CAAE,IAC3E,CAAC;MACH;IACF;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"FrodoCommand.js","names":["state","Argument","Command","Option","fs","globalConfig","createProgressIndicator","curlirizeMessage","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","verboseMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","insecureOption","verboseOption","debugOption","curlirizeOption","defaultArgs","defaultOpts","stateMap","name","host","setHost","realm","setRealm","username","setUsername","password","setPassword","attributeName","saId","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","type","setDeploymentType","insecure","setAllowInsecureConnection","verbose","setVerbose","debug","setDebug","curlirize","setCurlirize","FrodoStubCommand","constructor","on","_error$config","_error$config2","_error$response","config","method","url","response","stack","exitCode","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","addHelpText","startsWith","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","length","Object","keys","handler","k"],"sources":["../../src/cli/FrodoCommand.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Argument, Command, Option } from 'commander';\nimport fs from 'fs';\n\nimport * as globalConfig from '../storage/StaticStorage';\nimport {\n createProgressIndicator,\n curlirizeMessage,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n verboseMessage,\n} from '../utils/Console.js';\n\nconst hostArgument = new Argument(\n '[host]',\n 'Access Management base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.'\n);\n\nconst realmArgument = new Argument(\n '[realm]',\n \"Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise.\"\n).default(\n // must check for FRODO_REALM env variable here because otherwise cli will overwrite realm with default value\n process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY,\n '\"alpha\" for Identity Cloud tenants, \"/\" otherwise.'\n);\n\nconst usernameArgument = new Argument(\n '[username]',\n 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.'\n);\n\nconst passwordArgument = new Argument('[password]', 'Password.');\n\nconst serviceAccountIdOption = new Option(\n '--sa-id <sa-id>',\n 'Service account id.'\n);\n\nconst serviceAccountJwkFileOption = new Option(\n '--sa-jwk-file <file>',\n 'File containing the JSON Web Key (JWK) associated with the the service account.'\n);\n\nconst deploymentOption = new Option(\n '-m, --type <type>',\n 'Override auto-detected deployment type. Valid values for type: \\n\\\nclassic: A classic Access Management-only deployment with custom layout and configuration. \\n\\\ncloud: A ForgeRock Identity Cloud environment. \\n\\\nforgeops: A ForgeOps CDK or CDM deployment. \\n\\\nThe detected or provided deployment type controls certain behavior like obtaining an Identity \\\nManagement admin token or not and whether to export/import referenced email templates or how \\\nto walk through the tenant admin login flow of Identity Cloud and handle MFA'\n).choices(globalConfig.DEPLOYMENT_TYPES);\n\nconst insecureOption = new Option(\n '-k, --insecure',\n 'Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability.'\n).default(false, \"Don't allow insecure connections\");\n\nconst verboseOption = new Option(\n '--verbose',\n 'Verbose output during command execution. If specified, may or may not produce additional output.'\n);\n\nconst debugOption = new Option(\n '--debug',\n 'Debug output during command execution. If specified, may or may not produce additional output helpful for troubleshooting.'\n);\n\nconst curlirizeOption = new Option(\n '--curlirize',\n 'Output all network calls in curl format.'\n);\n\nconst defaultArgs = [\n hostArgument,\n realmArgument,\n usernameArgument,\n passwordArgument,\n];\n\nconst defaultOpts = [\n serviceAccountIdOption,\n serviceAccountJwkFileOption,\n deploymentOption,\n insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: (host: string) => state.setHost(host),\n [realmArgument.name()]: (realm: string) => state.setRealm(realm),\n [usernameArgument.name()]: (username: string) => state.setUsername(username),\n [passwordArgument.name()]: (password: string) => state.setPassword(password),\n [serviceAccountIdOption.attributeName()]: (saId: string) =>\n state.setServiceAccountId(saId),\n [serviceAccountJwkFileOption.attributeName()]: (file: string) => {\n try {\n const data = fs.readFileSync(file);\n const jwk = JSON.parse(data.toString());\n state.setServiceAccountJwk(jwk);\n } catch (error) {\n printMessage(\n `Error parsing JWK from file ${file}: ${error.message}`,\n 'error'\n );\n }\n },\n [deploymentOption.attributeName()]: (type: string) =>\n state.setDeploymentType(type),\n [insecureOption.attributeName()]: (insecure: boolean) =>\n state.setAllowInsecureConnection(insecure),\n [verboseOption.attributeName()]: (verbose: boolean) =>\n state.setVerbose(verbose),\n [debugOption.attributeName()]: (debug: boolean) => state.setDebug(debug),\n [curlirizeOption.attributeName()]: (curlirize: boolean) =>\n state.setCurlirize(curlirize),\n};\n\n/**\n * Command with default options\n */\nexport class FrodoStubCommand extends Command {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string) {\n super(name);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on('unhandledRejection', (error: any) => {\n printMessage(\n `${error.config?.method ? error.config.method + ' ' : ''}${\n error.config?.url ? error.config.url : ''\n }`,\n 'error'\n );\n printMessage(error.response?.data, 'error');\n printMessage(error.stack, 'error');\n printMessage(\n `Please report this unhandled error here: https://github.com/rockcarver/frodo-cli/issues`,\n 'error'\n );\n process.exitCode = 1;\n });\n\n // other default settings\n this.helpOption('-h, --help', 'Help');\n this.showHelpAfterError();\n this.configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n });\n\n // register default handlers\n state.setPrintHandler(printMessage);\n state.setVerboseHandler(verboseMessage);\n state.setDebugHandler(debugMessage);\n state.setCurlirizeHandler(curlirizeMessage);\n state.setCreateProgressHandler(createProgressIndicator);\n state.setUpdateProgressHandler(updateProgressIndicator);\n state.setStopProgressHandler(stopProgressIndicator);\n }\n}\n\n/**\n * Command with default options\n */\nexport class FrodoCommand extends FrodoStubCommand {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string, omits: string[] = []) {\n super(name);\n\n // register default arguments\n for (const arg of defaultArgs) {\n if (!omits.includes(arg.name())) this.addArgument(arg);\n }\n\n // register default options\n for (const opt of defaultOpts) {\n if (!omits.includes(opt.name())) this.addOption(opt);\n }\n\n // additional help\n this.addHelpText(\n 'after',\n `\\nEvironment Variables:\\n` +\n ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\\n` +\n ` FRODO_REALM: Realm. Overrides 'realm' argument.\\n` +\n ` FRODO_USERNAME: Username. Overrides 'username' argument.\\n` +\n ` FRODO_PASSWORD: Password. Overrides 'password' argument.\\n` +\n ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\\n` +\n ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\\n` +\n ('frodo conn save' === this.name()\n ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\\n`\n : ``) +\n (this.name().startsWith('frodo log')\n ? ` FRODO_LOG_KEY: Log API key. Overrides 'username' argument.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides 'password' argument.\\n`\n : ``) +\n ` FRODO_CONNECTION_PROFILES_PATH: Use this connection profiles file instead of '~/.frodo/Connections.json'.\\n` +\n ` FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.\\n` +\n ` FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.\\n` +\n ` FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.\\n` +\n ` FRODO_MASTER_KEY: Use this master key instead of '~/.frodo/masterkey.key' file. Takes precedence over FRODO_MASTER_KEY_PATH.\\n`\n );\n }\n\n /**\n *\n * @param args\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleDefaultArgsAndOpts(...args: any) {\n const command = args.pop();\n const options = args.pop();\n\n // handle arguments first\n for (const [i, v] of command.args.entries()) {\n if (!command._args[i]) {\n printMessage(\n `${command.args.length} arguments supplied but command only supports ${command._args.length}.`,\n 'warn'\n );\n break;\n }\n const arg = command._args[i].name();\n // handle only default arguments\n if (Object.keys(stateMap).includes(arg)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default argument '${arg}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[arg];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default argument '${arg}'.`\n );\n }\n }\n\n // handle options\n for (const [k, v] of Object.entries(options)) {\n // handle only default options\n if (Object.keys(stateMap).includes(k)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default option '${k}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[k];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default option '${k}'.`\n );\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAOC,EAAE,MAAM,IAAI;AAEnB,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SACEC,uBAAuB,EACvBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,EACvBC,cAAc,QACT,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIZ,QAAQ,CAC/B,QAAQ,EACR,iIACF,CAAC;AAED,MAAMa,aAAa,GAAG,IAAIb,QAAQ,CAChC,SAAS,EACT,yFACF,CAAC,CAACc,OAAO;AACP;AACAC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIb,YAAY,CAACc,iBAAiB,EACzD,oDACF,CAAC;AAED,MAAMC,gBAAgB,GAAG,IAAInB,QAAQ,CACnC,YAAY,EACZ,gHACF,CAAC;AAED,MAAMoB,gBAAgB,GAAG,IAAIpB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;AAEhE,MAAMqB,sBAAsB,GAAG,IAAInB,MAAM,CACvC,iBAAiB,EACjB,qBACF,CAAC;AAED,MAAMoB,2BAA2B,GAAG,IAAIpB,MAAM,CAC5C,sBAAsB,EACtB,iFACF,CAAC;AAED,MAAMqB,gBAAgB,GAAG,IAAIrB,MAAM,CACjC,mBAAmB,EACnB;AACF;A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,CAAC,CAAC,EAAE;QACrB/F,YAAY,CACT,GAAE4F,OAAO,CAACD,IAAI,CAACQ,MAAO,iDAAgDP,OAAO,CAACM,KAAK,CAACC,MAAO,GAAE,EAC9F,MACF,CAAC;QACD;MACF;MACA,MAAMhB,GAAG,GAAGS,OAAO,CAACM,KAAK,CAACH,CAAC,CAAC,CAACtE,IAAI,CAAC,CAAC;MACnC;MACA,IAAI2E,MAAM,CAACC,IAAI,CAAC7E,QAAQ,CAAC,CAAC4D,QAAQ,CAACD,GAAG,CAAC,EAAE;QACvCpF,YAAY,CACT,qEAAoEoF,GAAI,IAC3E,CAAC;QACD;QACA,MAAMmB,OAAY,GAAG9E,QAAQ,CAAC2D,GAAG,CAAC;QAClCmB,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLjG,YAAY,CACT,yEAAwEoF,GAAI,IAC/E,CAAC;MACH;IACF;;IAEA;IACA,KAAK,MAAM,CAACoB,CAAC,EAAEP,CAAC,CAAC,IAAII,MAAM,CAACH,OAAO,CAACH,OAAO,CAAC,EAAE;MAC5C;MACA,IAAIM,MAAM,CAACC,IAAI,CAAC7E,QAAQ,CAAC,CAAC4D,QAAQ,CAACmB,CAAC,CAAC,EAAE;QACrCxG,YAAY,CACT,mEAAkEwG,CAAE,IACvE,CAAC;QACD;QACA,MAAMD,OAAY,GAAG9E,QAAQ,CAAC+E,CAAC,CAAC;QAChCD,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLjG,YAAY,CACT,uEAAsEwG,CAAE,IAC3E,CAAC;MACH;IACF;EACF;AACF"}
|
package/esm/cli/log/log-fetch.js
CHANGED
|
@@ -2,7 +2,7 @@ import { frodo, state } from '@rockcarver/frodo-lib';
|
|
|
2
2
|
import { Option } from 'commander';
|
|
3
3
|
import { fetchLogs, provisionCreds } from '../../ops/LogOps';
|
|
4
4
|
import * as config from '../../utils/Config';
|
|
5
|
-
import { printMessage } from '../../utils/Console';
|
|
5
|
+
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
6
6
|
import { FrodoCommand } from '../FrodoCommand';
|
|
7
7
|
import { sourcesOptionM } from './log';
|
|
8
8
|
const {
|
|
@@ -29,31 +29,47 @@ Following values are possible (values on the same line are equivalent): \
|
|
|
29
29
|
Cannot be more than 30 days in the past. If not specified, logs from one hour ago are fetched \
|
|
30
30
|
(-e is ignored)')).addOption(new Option('-e, --end-timestamp <endTs>', 'End timestamp for period. Default: "now"')).addOption(new Option('-s, --search-string <ss>', 'Filter by a specific string (ANDed with transactionID filter)')).addOption(new Option('-d, --defaults', 'Use default logging noise filters').default(false, `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`)).action(async (host, user, password, options, command) => {
|
|
31
31
|
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
32
|
-
let
|
|
32
|
+
let foundCredentials = false;
|
|
33
33
|
const conn = await getConnectionProfile();
|
|
34
|
-
if (conn)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
if (conn) state.setHost(conn.tenant);
|
|
35
|
+
|
|
36
|
+
// log api creds have been supplied as username and password arguments
|
|
37
|
+
if (state.getUsername() && state.getPassword()) {
|
|
38
|
+
verboseMessage(`Using log api credentials from command line.`);
|
|
39
|
+
state.setLogApiKey(state.getUsername());
|
|
40
|
+
state.setLogApiSecret(state.getPassword());
|
|
41
|
+
foundCredentials = true;
|
|
42
|
+
}
|
|
43
|
+
// log api creds from connection profile
|
|
44
|
+
else if (conn && conn.logApiKey != null && conn.logApiSecret != null) {
|
|
45
|
+
verboseMessage(`Using log api credentials from connection profile.`);
|
|
46
|
+
state.setLogApiKey(conn.logApiKey);
|
|
47
|
+
state.setLogApiSecret(conn.logApiSecret);
|
|
48
|
+
foundCredentials = true;
|
|
49
|
+
}
|
|
50
|
+
// log api creds have been supplied via env variables
|
|
51
|
+
else if (state.getLogApiKey() && state.getLogApiSecret()) {
|
|
52
|
+
verboseMessage(`Using log api credentials from environment variables.`);
|
|
53
|
+
foundCredentials = true;
|
|
54
|
+
}
|
|
55
|
+
// no log api creds but got username and password, so can try to create them
|
|
56
|
+
else if (conn && conn.username && conn.password) {
|
|
57
|
+
printMessage(`Found admin credentials in connection profile, attempting to create log api credentials...`);
|
|
58
|
+
state.setUsername(conn.username);
|
|
59
|
+
state.setPassword(conn.password);
|
|
60
|
+
if (await getTokens(true)) {
|
|
61
|
+
const creds = await provisionCreds();
|
|
62
|
+
state.setLogApiKey(creds.api_key_id);
|
|
63
|
+
state.setLogApiSecret(creds.api_key_secret);
|
|
64
|
+
await saveConnectionProfile(state.getHost());
|
|
65
|
+
foundCredentials = true;
|
|
56
66
|
}
|
|
67
|
+
// unable to create credentials
|
|
68
|
+
else {
|
|
69
|
+
printMessage(`Unable to create log api credentials.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (foundCredentials) {
|
|
57
73
|
const now = Date.now() / 1000;
|
|
58
74
|
const nowString = new Date(now * 1000).toISOString();
|
|
59
75
|
if (typeof options.beginTimestamp === 'undefined' || !options.beginTimestamp) {
|
|
@@ -76,16 +92,16 @@ Cannot be more than 30 days in the past. If not specified, logs from one hour ag
|
|
|
76
92
|
const endTs = Date.parse(options.endTimestamp) / 1000;
|
|
77
93
|
if (endTs < beginTs) {
|
|
78
94
|
printMessage('End timestamp can not be before begin timestamp', 'error');
|
|
95
|
+
process.exitCode = 1;
|
|
79
96
|
return;
|
|
80
97
|
}
|
|
81
98
|
if (now - beginTs > LOG_TIME_WINDOW_MAX) {
|
|
82
99
|
printMessage('Begin timestamp can not be more than 30 days in the past', 'error');
|
|
100
|
+
process.exitCode = 1;
|
|
83
101
|
return;
|
|
84
102
|
}
|
|
85
103
|
let intermediateEndTs = 0;
|
|
86
104
|
printMessage(`Fetching ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}] of ${conn.tenant}...`);
|
|
87
|
-
if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
|
|
88
|
-
|
|
89
105
|
let timeIncrement = LOG_TIME_WINDOW_INCREMENT;
|
|
90
106
|
if (endTs - beginTs > 30) {
|
|
91
107
|
timeIncrement = timeIncrement * 30;
|
|
@@ -96,6 +112,12 @@ Cannot be more than 30 days in the past. If not specified, logs from one hour ag
|
|
|
96
112
|
beginTs = intermediateEndTs;
|
|
97
113
|
} while (intermediateEndTs < endTs);
|
|
98
114
|
}
|
|
115
|
+
// no log api credentials
|
|
116
|
+
else {
|
|
117
|
+
printMessage('No log api credentials found!');
|
|
118
|
+
program.help();
|
|
119
|
+
process.exitCode = 1;
|
|
120
|
+
}
|
|
99
121
|
});
|
|
100
122
|
program.parse();
|
|
101
123
|
//# sourceMappingURL=log-fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-fetch.js","names":["frodo","state","Option","fetchLogs","provisionCreds","config","printMessage","FrodoCommand","sourcesOptionM","getTokens","login","resolveLevel","cloud","log","getConnectionProfile","saveConnectionProfile","conn","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","creds","api_key_id","api_key_secret","now","Date","nowString","toISOString","beginTimestamp","tempStartDate","setTime","tempEndDate","endTimestamp","beginTs","parse","endTs","intermediateEndTs","opts","sources","level","timeIncrement","transactionId","searchString","getNoiseFilters","defaults"],"sources":["../../../src/cli/log/log-fetch.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { fetchLogs, provisionCreds } from '../../ops/LogOps';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './log';\n\nconst { getTokens } = frodo.login;\nconst { resolveLevel } = frodo.cloud.log;\nconst { getConnectionProfile, saveConnectionProfile } = frodo.conn;\n\nconst SECONDS_IN_30_DAYS = 2592000;\nconst SECONDS_IN_1_HOUR = 3600;\nconst LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;\nconst LOG_TIME_WINDOW_INCREMENT = 1;\n\nconst program = new FrodoCommand('frodo log fetch', ['realm', 'type']);\nprogram\n .description(\n 'Fetch Identity Cloud logs between a specified begin and end time period.\\\n WARNING: depending on filters and time period specified, this could take substantial time to complete.'\n )\n .addOption(sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option(\n '-b, --begin-timestamp <beginTs>',\n 'Begin timestamp for period (in ISO8601, example: \"2022-10-13T19:06:28Z\", or \"2022-09.30\". \\\nCannot be more than 30 days in the past. If not specified, logs from one hour ago are fetched \\\n(-e is ignored)'\n )\n )\n .addOption(\n new Option(\n '-e, --end-timestamp <endTs>',\n 'End timestamp for period. Default: \"now\"'\n )\n )\n .addOption(\n new Option(\n '-s, --search-string <ss>',\n 'Filter by a specific string (ANDed with transactionID filter)'\n )\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n let credsFromParameters = true;\n const conn = await getConnectionProfile();\n if (conn) {\n state.setHost(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (!state.getUsername() && !state.getPassword()) {\n credsFromParameters = false;\n printMessage(\n 'User credentials not specified as parameters and no saved API key and secret found!',\n 'warn'\n );\n return;\n }\n } else {\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n }\n if (await getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n }\n }\n const now = Date.now() / 1000;\n const nowString = new Date(now * 1000).toISOString();\n if (\n typeof options.beginTimestamp === 'undefined' ||\n !options.beginTimestamp\n ) {\n // no beginTimestamp value specified, default is 1 hour ago\n const tempStartDate = new Date();\n tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);\n options.beginTimestamp = tempStartDate.toISOString();\n // also override endTimestamp to now\n const tempEndDate = new Date();\n tempEndDate.setTime(now * 1000);\n options.endTimestamp = tempEndDate;\n printMessage(\n 'No timestamps specified, defaulting to logs from 1 hour ago',\n 'info'\n );\n }\n if (\n typeof options.endTimestamp === 'undefined' ||\n !options.endTimestamp\n ) {\n // no endTimestamp value specified, default is now\n options.endTimestamp = nowString;\n printMessage(\n 'No end timestamp specified, defaulting end timestamp to \"now\"',\n 'info'\n );\n }\n let beginTs = Date.parse(options.beginTimestamp) / 1000;\n const endTs = Date.parse(options.endTimestamp) / 1000;\n if (endTs < beginTs) {\n printMessage(\n 'End timestamp can not be before begin timestamp',\n 'error'\n );\n return;\n }\n if (now - beginTs > LOG_TIME_WINDOW_MAX) {\n printMessage(\n 'Begin timestamp can not be more than 30 days in the past',\n 'error'\n );\n return;\n }\n let intermediateEndTs = 0;\n printMessage(\n `Fetching ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}] of ${\n conn.tenant\n }...`\n );\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n\n let timeIncrement = LOG_TIME_WINDOW_INCREMENT;\n if (endTs - beginTs > 30) {\n timeIncrement = timeIncrement * 30;\n }\n do {\n intermediateEndTs = beginTs + timeIncrement;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n command.opts().searchString,\n null,\n config.getNoiseFilters(options.defaults)\n );\n beginTs = intermediateEndTs;\n } while (intermediateEndTs < endTs);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,EAAEC,cAAc,QAAQ,kBAAkB;AAC5D,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,OAAO;AAEtC,MAAM;EAAEC;AAAU,CAAC,GAAGT,KAAK,CAACU,KAAK;AACjC,MAAM;EAAEC;AAAa,CAAC,GAAGX,KAAK,CAACY,KAAK,CAACC,GAAG;AACxC,MAAM;EAAEC,oBAAoB;EAAEC;AAAsB,CAAC,GAAGf,KAAK,CAACgB,IAAI;AAElE,MAAMC,kBAAkB,GAAG,OAAO;AAClC,MAAMC,iBAAiB,GAAG,IAAI;AAC9B,MAAMC,mBAAmB,GAAGF,kBAAkB;AAC9C,MAAMG,yBAAyB,GAAG,CAAC;AAEnC,MAAMC,OAAO,GAAG,IAAId,YAAY,CA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,OAAO,GAAGO,aAAa;MAC3C,MAAM7D,SAAS,CACb4B,OAAO,CAAC8B,IAAI,CAAC,CAAC,CAACC,OAAO,EACtB,IAAIb,IAAI,CAACQ,OAAO,GAAG,IAAI,CAAC,CAACN,WAAW,CAAC,CAAC,EACtC,IAAIF,IAAI,CAACW,iBAAiB,GAAG,IAAI,CAAC,CAACT,WAAW,CAAC,CAAC,EAChDxC,YAAY,CAACoB,OAAO,CAAC8B,IAAI,CAAC,CAAC,CAACE,KAAK,CAAC,EAClChC,OAAO,CAAC8B,IAAI,CAAC,CAAC,CAACI,aAAa,EAC5BlC,OAAO,CAAC8B,IAAI,CAAC,CAAC,CAACK,YAAY,EAC3B,IAAI,EACJ7D,MAAM,CAAC8D,eAAe,CAACrC,OAAO,CAACsC,QAAQ,CACzC,CAAC;MACDX,OAAO,GAAGG,iBAAiB;IAC7B,CAAC,QAAQA,iBAAiB,GAAGD,KAAK;EACpC;AACF,CAAC,CAAC;AAEJtC,OAAO,CAACqC,KAAK,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"log-fetch.js","names":["frodo","state","Option","fetchLogs","provisionCreds","config","printMessage","verboseMessage","FrodoCommand","sourcesOptionM","getTokens","login","resolveLevel","cloud","log","getConnectionProfile","saveConnectionProfile","conn","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","foundCredentials","setHost","tenant","getUsername","getPassword","setLogApiKey","setLogApiSecret","logApiKey","logApiSecret","getLogApiKey","getLogApiSecret","username","setUsername","setPassword","creds","api_key_id","api_key_secret","getHost","now","Date","nowString","toISOString","beginTimestamp","tempStartDate","setTime","tempEndDate","endTimestamp","beginTs","parse","endTs","process","exitCode","intermediateEndTs","opts","sources","level","timeIncrement","transactionId","searchString","getNoiseFilters","defaults","help"],"sources":["../../../src/cli/log/log-fetch.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { fetchLogs, provisionCreds } from '../../ops/LogOps';\nimport * as config from '../../utils/Config';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './log';\n\nconst { getTokens } = frodo.login;\nconst { resolveLevel } = frodo.cloud.log;\nconst { getConnectionProfile, saveConnectionProfile } = frodo.conn;\n\nconst SECONDS_IN_30_DAYS = 2592000;\nconst SECONDS_IN_1_HOUR = 3600;\nconst LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;\nconst LOG_TIME_WINDOW_INCREMENT = 1;\n\nconst program = new FrodoCommand('frodo log fetch', ['realm', 'type']);\nprogram\n .description(\n 'Fetch Identity Cloud logs between a specified begin and end time period.\\\n WARNING: depending on filters and time period specified, this could take substantial time to complete.'\n )\n .addOption(sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option(\n '-b, --begin-timestamp <beginTs>',\n 'Begin timestamp for period (in ISO8601, example: \"2022-10-13T19:06:28Z\", or \"2022-09.30\". \\\nCannot be more than 30 days in the past. If not specified, logs from one hour ago are fetched \\\n(-e is ignored)'\n )\n )\n .addOption(\n new Option(\n '-e, --end-timestamp <endTs>',\n 'End timestamp for period. Default: \"now\"'\n )\n )\n .addOption(\n new Option(\n '-s, --search-string <ss>',\n 'Filter by a specific string (ANDed with transactionID filter)'\n )\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n\n let foundCredentials = false;\n\n const conn = await getConnectionProfile();\n if (conn) state.setHost(conn.tenant);\n\n // log api creds have been supplied as username and password arguments\n if (state.getUsername() && state.getPassword()) {\n verboseMessage(`Using log api credentials from command line.`);\n state.setLogApiKey(state.getUsername());\n state.setLogApiSecret(state.getPassword());\n foundCredentials = true;\n }\n // log api creds from connection profile\n else if (conn && conn.logApiKey != null && conn.logApiSecret != null) {\n verboseMessage(`Using log api credentials from connection profile.`);\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n foundCredentials = true;\n }\n // log api creds have been supplied via env variables\n else if (state.getLogApiKey() && state.getLogApiSecret()) {\n verboseMessage(`Using log api credentials from environment variables.`);\n foundCredentials = true;\n }\n // no log api creds but got username and password, so can try to create them\n else if (conn && conn.username && conn.password) {\n printMessage(\n `Found admin credentials in connection profile, attempting to create log api credentials...`\n );\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n if (await getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n await saveConnectionProfile(state.getHost());\n foundCredentials = true;\n }\n // unable to create credentials\n else {\n printMessage(`Unable to create log api credentials.`);\n }\n }\n\n if (foundCredentials) {\n const now = Date.now() / 1000;\n const nowString = new Date(now * 1000).toISOString();\n if (\n typeof options.beginTimestamp === 'undefined' ||\n !options.beginTimestamp\n ) {\n // no beginTimestamp value specified, default is 1 hour ago\n const tempStartDate = new Date();\n tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);\n options.beginTimestamp = tempStartDate.toISOString();\n // also override endTimestamp to now\n const tempEndDate = new Date();\n tempEndDate.setTime(now * 1000);\n options.endTimestamp = tempEndDate;\n printMessage(\n 'No timestamps specified, defaulting to logs from 1 hour ago',\n 'info'\n );\n }\n if (\n typeof options.endTimestamp === 'undefined' ||\n !options.endTimestamp\n ) {\n // no endTimestamp value specified, default is now\n options.endTimestamp = nowString;\n printMessage(\n 'No end timestamp specified, defaulting end timestamp to \"now\"',\n 'info'\n );\n }\n let beginTs = Date.parse(options.beginTimestamp) / 1000;\n const endTs = Date.parse(options.endTimestamp) / 1000;\n if (endTs < beginTs) {\n printMessage(\n 'End timestamp can not be before begin timestamp',\n 'error'\n );\n process.exitCode = 1;\n return;\n }\n if (now - beginTs > LOG_TIME_WINDOW_MAX) {\n printMessage(\n 'Begin timestamp can not be more than 30 days in the past',\n 'error'\n );\n process.exitCode = 1;\n return;\n }\n let intermediateEndTs = 0;\n printMessage(\n `Fetching ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}] of ${\n conn.tenant\n }...`\n );\n\n let timeIncrement = LOG_TIME_WINDOW_INCREMENT;\n if (endTs - beginTs > 30) {\n timeIncrement = timeIncrement * 30;\n }\n do {\n intermediateEndTs = beginTs + timeIncrement;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n command.opts().searchString,\n null,\n config.getNoiseFilters(options.defaults)\n );\n beginTs = intermediateEndTs;\n } while (intermediateEndTs < endTs);\n }\n // no log api credentials\n else {\n printMessage('No log api credentials found!');\n program.help();\n process.exitCode = 1;\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,SAAS,EAAEC,cAAc,QAAQ,kBAAkB;AAC5D,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc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K,CAAC,EAClCrC,OAAO,CAACmC,IAAI,CAAC,CAAC,CAACI,aAAa,EAC5BvC,OAAO,CAACmC,IAAI,CAAC,CAAC,CAACK,YAAY,EAC3B,IAAI,EACJnE,MAAM,CAACoE,eAAe,CAAC1C,OAAO,CAAC2C,QAAQ,CACzC,CAAC;MACDb,OAAO,GAAGK,iBAAiB;IAC7B,CAAC,QAAQA,iBAAiB,GAAGH,KAAK;EACpC;EACA;EAAA,KACK;IACHzD,YAAY,CAAC,+BAA+B,CAAC;IAC7CgB,OAAO,CAACqD,IAAI,CAAC,CAAC;IACdX,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF,CAAC,CAAC;AAEJ3C,OAAO,CAACwC,KAAK,CAAC,CAAC"}
|
package/esm/cli/log/log-list.js
CHANGED
|
@@ -15,45 +15,66 @@ const {
|
|
|
15
15
|
const program = new FrodoCommand('frodo log list', ['realm', 'type']);
|
|
16
16
|
program.description('List available ID Cloud log sources.').action(async (host, user, password, options, command) => {
|
|
17
17
|
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
18
|
-
let credsFromParameters = true;
|
|
19
18
|
verboseMessage('Listing available ID Cloud log sources...');
|
|
19
|
+
let foundCredentials = false;
|
|
20
20
|
const conn = await getConnectionProfile();
|
|
21
|
-
if (conn)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
if (conn) state.setHost(conn.tenant);
|
|
22
|
+
|
|
23
|
+
// log api creds have been supplied as username and password arguments
|
|
24
|
+
if (state.getUsername() && state.getPassword()) {
|
|
25
|
+
verboseMessage(`Using log api credentials from command line.`);
|
|
26
|
+
state.setLogApiKey(state.getUsername());
|
|
27
|
+
state.setLogApiSecret(state.getPassword());
|
|
28
|
+
foundCredentials = true;
|
|
29
|
+
}
|
|
30
|
+
// log api creds from connection profile
|
|
31
|
+
else if (conn && conn.logApiKey != null && conn.logApiSecret != null) {
|
|
32
|
+
verboseMessage(`Using log api credentials from connection profile.`);
|
|
33
|
+
state.setLogApiKey(conn.logApiKey);
|
|
34
|
+
state.setLogApiSecret(conn.logApiSecret);
|
|
35
|
+
foundCredentials = true;
|
|
36
|
+
}
|
|
37
|
+
// log api creds have been supplied via env variables
|
|
38
|
+
else if (state.getLogApiKey() && state.getLogApiSecret()) {
|
|
39
|
+
verboseMessage(`Using log api credentials from environment variables.`);
|
|
40
|
+
foundCredentials = true;
|
|
41
|
+
}
|
|
42
|
+
// no log api creds but got username and password, so can try to create them
|
|
43
|
+
else if (conn && conn.username && conn.password) {
|
|
44
|
+
printMessage(`Found admin credentials in connection profile, attempting to create log api credentials...`);
|
|
45
|
+
state.setUsername(conn.username);
|
|
46
|
+
state.setPassword(conn.password);
|
|
47
|
+
if (await getTokens(true)) {
|
|
48
|
+
const creds = await provisionCreds();
|
|
49
|
+
state.setLogApiKey(creds.api_key_id);
|
|
50
|
+
state.setLogApiSecret(creds.api_key_secret);
|
|
51
|
+
await saveConnectionProfile(state.getHost());
|
|
52
|
+
foundCredentials = true;
|
|
53
|
+
}
|
|
54
|
+
// unable to create credentials
|
|
55
|
+
else {
|
|
56
|
+
printMessage(`Unable to create log api credentials.`);
|
|
43
57
|
}
|
|
58
|
+
}
|
|
59
|
+
if (foundCredentials) {
|
|
44
60
|
const sources = await getLogSources();
|
|
45
61
|
if (sources.length === 0) {
|
|
46
62
|
printMessage("Can't get sources, possible cause - wrong API key or secret", 'error');
|
|
47
63
|
} else {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
sources.forEach(source => {
|
|
64
|
+
printMessage(`Log sources from ${state.getHost()}`);
|
|
65
|
+
for (const source of sources) {
|
|
51
66
|
printMessage(`${source}`, 'data');
|
|
52
|
-
}
|
|
67
|
+
}
|
|
53
68
|
printMessage('Use any combination of comma separated sources, example:', 'info');
|
|
54
|
-
printMessage(`$ frodo logs tail -c am-core,idm-core ${
|
|
69
|
+
printMessage(`$ frodo logs tail -c am-core,idm-core ${state.getHost()}`, 'text');
|
|
55
70
|
}
|
|
56
71
|
}
|
|
72
|
+
// no log api credentials
|
|
73
|
+
else {
|
|
74
|
+
printMessage('No log api credentials found!');
|
|
75
|
+
program.help();
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
}
|
|
57
78
|
});
|
|
58
79
|
program.parse();
|
|
59
80
|
//# sourceMappingURL=log-list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-list.js","names":["frodo","state","provisionCreds","printMessage","verboseMessage","FrodoCommand","getTokens","login","getConnectionProfile","saveConnectionProfile","conn","getLogSources","cloud","log","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","
|
|
1
|
+
{"version":3,"file":"log-list.js","names":["frodo","state","provisionCreds","printMessage","verboseMessage","FrodoCommand","getTokens","login","getConnectionProfile","saveConnectionProfile","conn","getLogSources","cloud","log","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","foundCredentials","setHost","tenant","getUsername","getPassword","setLogApiKey","setLogApiSecret","logApiKey","logApiSecret","getLogApiKey","getLogApiSecret","username","setUsername","setPassword","creds","api_key_id","api_key_secret","getHost","sources","length","source","help","process","exitCode","parse"],"sources":["../../../src/cli/log/log-list.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\n\nimport { provisionCreds } from '../../ops/LogOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { getConnectionProfile, saveConnectionProfile } = frodo.conn;\nconst { getLogSources } = frodo.cloud.log;\n\nconst program = new FrodoCommand('frodo log list', ['realm', 'type']);\nprogram\n .description('List available ID Cloud log sources.')\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n\n verboseMessage('Listing available ID Cloud log sources...');\n\n let foundCredentials = false;\n\n const conn = await getConnectionProfile();\n if (conn) state.setHost(conn.tenant);\n\n // log api creds have been supplied as username and password arguments\n if (state.getUsername() && state.getPassword()) {\n verboseMessage(`Using log api credentials from command line.`);\n state.setLogApiKey(state.getUsername());\n state.setLogApiSecret(state.getPassword());\n foundCredentials = true;\n }\n // log api creds from connection profile\n else if (conn && conn.logApiKey != null && conn.logApiSecret != null) {\n verboseMessage(`Using log api credentials from connection profile.`);\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n foundCredentials = true;\n }\n // log api creds have been supplied via env variables\n else if (state.getLogApiKey() && state.getLogApiSecret()) {\n verboseMessage(`Using log api credentials from environment variables.`);\n foundCredentials = true;\n }\n // no log api creds but got username and password, so can try to create them\n else if (conn && conn.username && conn.password) {\n printMessage(\n `Found admin credentials in connection profile, attempting to create log api credentials...`\n );\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n if (await getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n await saveConnectionProfile(state.getHost());\n foundCredentials = true;\n }\n // unable to create credentials\n else {\n printMessage(`Unable to create log api credentials.`);\n }\n }\n\n if (foundCredentials) {\n const sources = await getLogSources();\n if (sources.length === 0) {\n printMessage(\n \"Can't get sources, possible cause - wrong API key or secret\",\n 'error'\n );\n } else {\n printMessage(`Log sources from ${state.getHost()}`);\n for (const source of sources) {\n printMessage(`${source}`, 'data');\n }\n printMessage(\n 'Use any combination of comma separated sources, example:',\n 'info'\n );\n printMessage(\n `$ frodo logs tail -c am-core,idm-core ${state.getHost()}`,\n 'text'\n );\n }\n }\n // no log api credentials\n else {\n printMessage('No log api credentials found!');\n program.help();\n process.exitCode = 1;\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK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AC7D,OACF,CAAC;IACH,CAAC,MAAM;MACLA,YAAY,CAAE,oBAAmBF,KAAK,CAACuC,OAAO,CAAC,CAAE,EAAC,CAAC;MACnD,KAAK,MAAMG,MAAM,IAAIF,OAAO,EAAE;QAC5BtC,YAAY,CAAE,GAAEwC,MAAO,EAAC,EAAE,MAAM,CAAC;MACnC;MACAxC,YAAY,CACV,0DAA0D,EAC1D,MACF,CAAC;MACDA,YAAY,CACT,yCAAwCF,KAAK,CAACuC,OAAO,CAAC,CAAE,EAAC,EAC1D,MACF,CAAC;IACH;EACF;EACA;EAAA,KACK;IACHrC,YAAY,CAAC,+BAA+B,CAAC;IAC7CW,OAAO,CAAC8B,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF,CAAC,CAAC;AAEJhC,OAAO,CAACiC,KAAK,CAAC,CAAC"}
|
package/esm/cli/log/log-tail.js
CHANGED
|
@@ -2,7 +2,7 @@ import { frodo, state } from '@rockcarver/frodo-lib';
|
|
|
2
2
|
import { Option } from 'commander';
|
|
3
3
|
import { provisionCreds, tailLogs } from '../../ops/LogOps';
|
|
4
4
|
import * as config from '../../utils/Config';
|
|
5
|
-
import { printMessage } from '../../utils/Console';
|
|
5
|
+
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
6
6
|
import { FrodoCommand } from '../FrodoCommand';
|
|
7
7
|
import { sourcesOptionM } from './log';
|
|
8
8
|
const {
|
|
@@ -22,35 +22,56 @@ Following values are possible (values on the same line are equivalent): \
|
|
|
22
22
|
\n2, INFO or INFORMATION\n3, DEBUG, FINE, FINER or FINEST\
|
|
23
23
|
\n4 or ALL').default('ERROR', `${resolveLevel('ERROR')}`)).addOption(new Option('-t, --transaction-id <txid>', 'Filter by transactionId')).addOption(new Option('-d, --defaults', 'Use default logging noise filters').default(false, `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`)).action(async (host, user, password, options, command) => {
|
|
24
24
|
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
25
|
-
let
|
|
25
|
+
let foundCredentials = false;
|
|
26
26
|
const conn = await getConnectionProfile();
|
|
27
|
-
if (conn)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
27
|
+
if (conn) state.setHost(conn.tenant);
|
|
28
|
+
|
|
29
|
+
// log api creds have been supplied as username and password arguments
|
|
30
|
+
if (state.getUsername() && state.getPassword()) {
|
|
31
|
+
verboseMessage(`Using log api credentials from command line.`);
|
|
32
|
+
state.setLogApiKey(state.getUsername());
|
|
33
|
+
state.setLogApiSecret(state.getPassword());
|
|
34
|
+
foundCredentials = true;
|
|
35
|
+
}
|
|
36
|
+
// log api creds from connection profile
|
|
37
|
+
else if (conn && conn.logApiKey != null && conn.logApiSecret != null) {
|
|
38
|
+
verboseMessage(`Using log api credentials from connection profile.`);
|
|
39
|
+
state.setLogApiKey(conn.logApiKey);
|
|
40
|
+
state.setLogApiSecret(conn.logApiSecret);
|
|
41
|
+
foundCredentials = true;
|
|
42
|
+
}
|
|
43
|
+
// log api creds have been supplied via env variables
|
|
44
|
+
else if (state.getLogApiKey() && state.getLogApiSecret()) {
|
|
45
|
+
verboseMessage(`Using log api credentials from environment variables.`);
|
|
46
|
+
foundCredentials = true;
|
|
47
|
+
}
|
|
48
|
+
// no log api creds but got username and password, so can try to create them
|
|
49
|
+
else if (conn && conn.username && conn.password) {
|
|
50
|
+
printMessage(`Found admin credentials in connection profile, attempting to create log api credentials...`);
|
|
51
|
+
state.setUsername(conn.username);
|
|
52
|
+
state.setPassword(conn.password);
|
|
53
|
+
if (await getTokens(true)) {
|
|
54
|
+
const creds = await provisionCreds();
|
|
55
|
+
state.setLogApiKey(creds.api_key_id);
|
|
56
|
+
state.setLogApiSecret(creds.api_key_secret);
|
|
57
|
+
await saveConnectionProfile(state.getHost());
|
|
58
|
+
foundCredentials = true;
|
|
49
59
|
}
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
// unable to create credentials
|
|
61
|
+
else {
|
|
62
|
+
printMessage(`Unable to create log api credentials.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (foundCredentials) {
|
|
66
|
+
printMessage(`Tailing ID Cloud logs from the following sources: ${options.sources} and levels [${resolveLevel(options.level)}] of ${state.getHost()}...`);
|
|
52
67
|
await tailLogs(command.opts().sources, resolveLevel(command.opts().level), command.opts().transactionId, null, config.getNoiseFilters(options.defaults));
|
|
53
68
|
}
|
|
69
|
+
// no log api credentials
|
|
70
|
+
else {
|
|
71
|
+
printMessage('No log api credentials found!');
|
|
72
|
+
program.help();
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
}
|
|
54
75
|
});
|
|
55
76
|
program.parse();
|
|
56
77
|
//# sourceMappingURL=log-tail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-tail.js","names":["frodo","state","Option","provisionCreds","tailLogs","config","printMessage","FrodoCommand","sourcesOptionM","getTokens","login","resolveLevel","cloud","log","getConnectionProfile","saveConnectionProfile","conn","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","
|
|
1
|
+
{"version":3,"file":"log-tail.js","names":["frodo","state","Option","provisionCreds","tailLogs","config","printMessage","verboseMessage","FrodoCommand","sourcesOptionM","getTokens","login","resolveLevel","cloud","log","getConnectionProfile","saveConnectionProfile","conn","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","foundCredentials","setHost","tenant","getUsername","getPassword","setLogApiKey","setLogApiSecret","logApiKey","logApiSecret","getLogApiKey","getLogApiSecret","username","setUsername","setPassword","creds","api_key_id","api_key_secret","getHost","sources","level","opts","transactionId","getNoiseFilters","defaults","help","process","exitCode","parse"],"sources":["../../../src/cli/log/log-tail.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { provisionCreds, tailLogs } from '../../ops/LogOps';\nimport * as config from '../../utils/Config';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './log';\n\nconst { getTokens } = frodo.login;\nconst { resolveLevel } = frodo.cloud.log;\nconst { getConnectionProfile, saveConnectionProfile } = frodo.conn;\n\nconst program = new FrodoCommand('frodo log tail', ['realm', 'type']);\nprogram\n .description('Tail Identity Cloud logs.')\n .addOption(sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n\n let foundCredentials = false;\n\n const conn = await getConnectionProfile();\n if (conn) state.setHost(conn.tenant);\n\n // log api creds have been supplied as username and password arguments\n if (state.getUsername() && state.getPassword()) {\n verboseMessage(`Using log api credentials from command line.`);\n state.setLogApiKey(state.getUsername());\n state.setLogApiSecret(state.getPassword());\n foundCredentials = true;\n }\n // log api creds from connection profile\n else if (conn && conn.logApiKey != null && conn.logApiSecret != null) {\n verboseMessage(`Using log api credentials from connection profile.`);\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n foundCredentials = true;\n }\n // log api creds have been supplied via env variables\n else if (state.getLogApiKey() && state.getLogApiSecret()) {\n verboseMessage(`Using log api credentials from environment variables.`);\n foundCredentials = true;\n }\n // no log api creds but got username and password, so can try to create them\n else if (conn && conn.username && conn.password) {\n printMessage(\n `Found admin credentials in connection profile, attempting to create log api credentials...`\n );\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n if (await getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n await saveConnectionProfile(state.getHost());\n foundCredentials = true;\n }\n // unable to create credentials\n else {\n printMessage(`Unable to create log api credentials.`);\n }\n }\n\n if (foundCredentials) {\n printMessage(\n `Tailing ID Cloud logs from the following sources: ${\n options.sources\n } and levels [${resolveLevel(options.level)}] of ${state.getHost()}...`\n );\n await tailLogs(\n command.opts().sources,\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n null,\n config.getNoiseFilters(options.defaults)\n );\n }\n // no log api credentials\n else {\n printMessage('No log api credentials found!');\n program.help();\n process.exitCode = 1;\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,cAAc,EAAEC,QAAQ,QAAQ,kBAAkB;AAC3D,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,OAAO;AAEtC,MAAM;EAAEC;AAAU,CAAC,GAAGV,KAAK,CAACW,KAAK;AACjC,MAAM;EAAEC;AAAa,CAAC,GAAGZ,KAAK,CAACa,KAAK,CAACC,GAAG;AACxC,MAAM;EAAEC,oBAAoB;EAAEC;AAAsB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,CAACsB,KAAK,CAAE,QAAOhD,KAAK,CAAC8C,OAAO,CAAC,CAAE,KACrE,CAAC;IACD,MAAM3C,QAAQ,CACZwB,OAAO,CAACsB,IAAI,CAAC,CAAC,CAACF,OAAO,EACtBpC,YAAY,CAACgB,OAAO,CAACsB,IAAI,CAAC,CAAC,CAACD,KAAK,CAAC,EAClCrB,OAAO,CAACsB,IAAI,CAAC,CAAC,CAACC,aAAa,EAC5B,IAAI,EACJ9C,MAAM,CAAC+C,eAAe,CAACzB,OAAO,CAAC0B,QAAQ,CACzC,CAAC;EACH;EACA;EAAA,KACK;IACH/C,YAAY,CAAC,+BAA+B,CAAC;IAC7CY,OAAO,CAACoC,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF,CAAC,CAAC;AAEJtC,OAAO,CAACuC,KAAK,CAAC,CAAC"}
|
|
@@ -21,7 +21,7 @@ async (host, realm, user, password, options, command) => {
|
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
verboseMessage(`Importing script(s) into realm "${state.getRealm()}"...`);
|
|
24
|
-
if (options.
|
|
24
|
+
if (options.file) {
|
|
25
25
|
const outcome = await importScriptsFromFile(options.scriptName || options.script, options.file, options.reUuid);
|
|
26
26
|
if (!outcome) process.exitCode = 1;
|
|
27
27
|
} else if (options.allSeparate) {
|