Skip to content

Commit 07205e8

Browse files
miraoclaude
andcommitted
fix(run-workers): mask nested secrets and clear stale metaStep parent (#5820)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1a3b154 commit 07205e8

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎lib/step/base.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ class Step {
250250
args.push(arg.getMasked())
251251
} else if (arg && !Array.isArray(arg) && arg.toString && arg.toString() !== '[object Object]') {
252252
args.push(arg.toString())
253+
} else if (arg && typeof arg === 'object' && !Array.isArray(arg)) {
254+
const masked = {}
255+
for (const [key, value] of Object.entries(arg)) {
256+
masked[key] = value instanceof Secret ? value.getMasked() : value
257+
}
258+
args.push((JSON.stringify(masked) || '').slice(0, 300))
253259
} else if (arg) {
254260
args.push((JSON.stringify(arg) || '').slice(0, 300))
255261
}

‎lib/step/deserialize.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function deserializeStep(data) {
2525

2626
if (humanizedArgs !== undefined) step.humanizeArgs = () => humanizedArgs
2727
if (text !== undefined) step.toString = () => text
28-
if (metaStep) step.metaStep = deserializeStep(metaStep)
28+
step.metaStep = metaStep ? deserializeStep(metaStep) : undefined
2929

3030
return step
3131
}

‎test/unit/step/deserialize_test.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ describe('Step serialization across workers', () => {
1919
expect(restored.args).to.deep.equal(['{xpath: //button}', '*****', 'text'])
2020
})
2121

22+
it('masks secrets nested in object arguments', () => {
23+
const step = new Step({}, 'sendPostRequest')
24+
step.setArguments(['/login', { user: 'john', password: new Secret('hunter2') }])
25+
26+
expect(transfer(step).args).to.deep.equal(['/login', '{"user":"john","password":"*****"}'])
27+
})
28+
29+
it('drops the parent of a reused meta step when it no longer has one', () => {
30+
const outer = new MetaStep('outerPage', 'open')
31+
const inner = new MetaStep('innerPage', 'login')
32+
inner.metaStep = outer
33+
const step = new Step({}, 'click')
34+
step.metaStep = inner
35+
36+
expect(transfer(step).metaStep.metaStep).to.be.instanceOf(MetaStep)
37+
inner.metaStep = null
38+
expect(transfer(step).metaStep.metaStep).to.be.undefined
39+
})
40+
2241
it('restores the meta step chain', () => {
2342
const section = new MetaStep(null, 'Login')
2443
const pageObject = new MetaStep('loginPage', 'login')

0 commit comments

Comments
 (0)