Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(source-aws): prevent s3 client from being logged when errors are thrown #1475

Merged
merged 2 commits into from
Aug 22, 2024
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
7 changes: 7 additions & 0 deletions packages/source-aws/src/__test__/source.aws.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ describe('SourceAwsS3', () => {
it('should create s3 links from string url', () => {
assert.equal(new SourceAwsS3('s3://foo/bar.txt').url.href, 's3://foo/bar.txt');
});

it('should not expose "client" for logging', () => {
const source = new SourceAwsS3('s3://foo/bar.txt');
const keys = Object.keys(source);
assert.equal(keys.includes('client'), false);
assert.notEqual(source.client.config, null);
});
});
2 changes: 2 additions & 0 deletions packages/source-aws/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class SourceAwsS3 implements Source {

constructor(url: URL | string, client: S3Client = new S3Client({})) {
this.url = typeof url === 'string' ? new URL(url) : url;
// S3 clients are very large and if this object gets logged the log is very very large
Object.defineProperty(this, 'client', { enumerable: false });
this.client = client;
}

Expand Down