Skip to content
Merged
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
4 changes: 3 additions & 1 deletion packages/cli-kit/src/private/node/api/headers.test.ts
Comment thread
gonzaloriestra marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('common API methods', () => {
},
)

test('sanitizedHeadersOutput removes the headers that include the token', () => {
test('sanitizedHeadersOutput removes sensitive headers', () => {
// Given
const headers = {
'User-Agent': 'useragent',
Expand All @@ -85,6 +85,8 @@ describe('common API methods', () => {
authorization: 'token',
'Content-Type': 'application/json',
'X-Shopify-Access-Token': 'token',
Cookie: 'session=123',
'Set-Cookie': 'session=456',
}

// When
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-kit/src/private/node/api/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class GraphQLClientError extends RequestClientError {
*/
export function sanitizedHeadersOutput(headers: Record<string, string>): string {
const sanitized: Record<string, string> = {}
const keywords = ['token', 'authorization', 'subject_token']
const keywords = ['token', 'authorization', 'subject_token', 'cookie']
Object.keys(headers).forEach((header) => {
if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {
sanitized[header] = headers[header]!
Expand Down
Loading