Skip to content

Commit ae564b7

Browse files
committed
fix: mask ecr login password from log
1 parent d0bea67 commit ae564b7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/lib/ecrUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export async function loginToRegistry(
1818
.decode(encodedAuthToken)
1919
.trim()
2020
.split(':')
21-
await dockerHandler.runDockerCommand(dockerPath, 'login', ['-u', tokens[0], '-p', tokens[1], endpoint], {
22-
silent: true
21+
await dockerHandler.runDockerCommand(dockerPath, 'login', ['-u', tokens[0], '--password-stdin', endpoint], {
22+
silent: true,
23+
input: tokens[1] // Password provided via stdin
2324
})
2425
}
2526

tests/taskTests/ecrPullImage/ecrPullImage-test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('ECR Pull image', () => {
9696
})
9797

9898
test('Happy path', async () => {
99-
expect.assertions(2)
99+
expect.assertions(3)
100100
const dockerHandler = { ...defaultDocker }
101101
const runDockerCommand = jest.fn((thing1, thing2, thing3) => Promise.resolve())
102102
dockerHandler.runDockerCommand = runDockerCommand
@@ -108,6 +108,7 @@ describe('ECR Pull image', () => {
108108
const taskOperations = new TaskOperations(ecr, dockerHandler, taskParameters)
109109
await taskOperations.execute()
110110
expect(ecr.getAuthorizationToken).toBeCalledTimes(1)
111-
expect(runDockerCommand.mock.calls[0][2][4]).toStrictEqual('https://example.com')
111+
expect(runDockerCommand.mock.calls[0][2][2]).toStrictEqual('--password-stdin')
112+
expect(runDockerCommand.mock.calls[0][2][3]).toStrictEqual('https://example.com')
112113
})
113114
})

0 commit comments

Comments
 (0)