Skip to content

Commit e46500e

Browse files
authored
fix(logs): avoid logging EC2 ARN on commands #6152
## Problem The EC2 ARN sneaks its away into the logs via the `Ec2InstanceNode` tooltip property from `packages/core/src/awsService/ec2/explorer/ec2InstanceNode.ts`. When we run any command on this instance, we get the following logs with the middle section omitted for brevity. ``` 2024-12-04 17:25:10.859 [debug] command: running "aws.ec2.openTerminal" with arguments: [ { collapsibleState: 0, label: 'testInstance ({INSTANCE_ID}) RUNNING', ... contextValue: 'awsEc2RunningNode', iconPath: { id: 'pass', color: undefined }, tooltip: 'testInstance\n' + '{INSTANCE_ID}\n' + 'running\n' + 'arn:aws:ec2:us-east-1:{ACCOUNT_ID}:instance/{INSTANCE_ID}', id: '{INSTANCE_ID}' }, undefined ] ``` The actual AWS account ID in use is included in the logs. What makes this difficult is that this node is passed directly from VSCode here: https://github.com/aws/aws-toolkit-vscode/blob/d74f96c61f79716edf8a9a706a86c587887d3b9b/packages/core/src/awsService/ec2/activation.ts#L32-L37 and is processed by our commands wrapper here: https://github.com/aws/aws-toolkit-vscode/blob/d74f96c61f79716edf8a9a706a86c587887d3b9b/packages/core/src/shared/vscode/commands2.ts#L649-L660 The wrapper is logging the node directly from vscode, not giving us a chance to use `partialClone` on it first. ## Solution - omit all tooltips from the logs, since this is usually redundant information anyway.
1 parent 7fe8a25 commit e46500e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core/src/shared/vscode/commands2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ async function runCommand<T extends Callback>(fn: T, info: CommandInfo<T>): Prom
656656

657657
logger.debug(
658658
`command: running ${label} with arguments: %O`,
659-
partialClone(args, 3, ['clientSecret', 'accessToken', 'refreshToken'], '[omitted]')
659+
partialClone(args, 3, ['clientSecret', 'accessToken', 'refreshToken', 'tooltip'], '[omitted]')
660660
)
661661

662662
try {

0 commit comments

Comments
 (0)