Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/common-templates/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ governing permissions and limitations under the License.
*
*/
function stringParameters (params) {
// hide credentials from the include-ims-credentials annotation
let imsCredentials = params.__ims_oauth_s2s || {}
if (imsCredentials.client_secret) {
imsCredentials = { ...imsCredentials, client_secret: '<hidden>' }
}
// hide authorization token without overriding params
let headers = params.__ow_headers || {}
if (headers.authorization) {
headers = { ...headers, authorization: '<hidden>' }
}
return JSON.stringify({ ...params, __ow_headers: headers })

return JSON.stringify({ ...params, __ow_headers: headers, __ims_oauth_s2s: imsCredentials })
Comment on lines 26 to +38
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringParameters now always injects __ims_oauth_s2s: {} into the returned JSON when the input params has no __ims_oauth_s2s. This changes the previous output shape and will break the existing "no auth header" test expectation (and any callers relying on the logged JSON matching the original params). Consider only adding __ims_oauth_s2s to the serialized object when it exists on the input params (or when it’s non-empty).

Copilot uses AI. Check for mistakes.
}

/**
Expand Down
7 changes: 7 additions & 0 deletions lib/common-templates/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ describe('stringParameters', () => {
expect(utils.stringParameters(params)).toEqual(expect.stringContaining('"authorization":"<hidden>"'))
expect(utils.stringParameters(params)).not.toEqual(expect.stringContaining('secret'))
})
test('with ims credentials', () => {
const params = {
a: 1, b: 2, __ims_oauth_s2s: { client_id: 'fake-client-id', client_secret: 'secret', org_id: 'fake@AdobeOrg' }
}
expect(utils.stringParameters(params)).toEqual(expect.stringContaining('"client_secret":"<hidden>"'))
expect(utils.stringParameters(params)).not.toEqual(expect.stringContaining('secret'))
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test’s not.toEqual(expect.stringContaining('secret')) assertion will fail because the output necessarily contains the substring secret in the key name client_secret (even when the value is properly hidden). Adjust the assertion to specifically check that the value isn't leaked (e.g., ensure it does not contain "client_secret":"secret", or parse the JSON and assert client_secret === '<hidden>').

Suggested change
expect(utils.stringParameters(params)).not.toEqual(expect.stringContaining('secret'))
expect(utils.stringParameters(params)).not.toEqual(expect.stringContaining('"client_secret":"secret"'))

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot and Cursor agree on the issue, but have different suggestions for how to fix it.

})
})

describe('checkMissingRequestInputs', () => {
Expand Down