Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #60 from thundra-io/feature/mask-stacktrace
Browse files Browse the repository at this point in the history
Implement error stack trace masking
  • Loading branch information
Serkan ÖZAL committed May 16, 2019
2 parents be55e0f + 7e9bc3d commit 9a5f192
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- "ES_JAVA_OPTS=-Xms64m -Xmx64m"
ports:
- "127.0.0.1:9200:9200"

resource_class: xlarge
steps:
- checkout
- run: npm install
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ Check out the [configuration part](https://thundra.readme.io/docs/nodejs-configu
| thundra_agent_lambda_trace_integrations_aws_sqs_message_mask | bool | false |
| thundra_agent_lambda_trace_integrations_aws_lambda_payload_mask | bool | false |
| thundra_agent_lambda_trace_integrations_aws_http_body_mask | bool | false |
| thundra_agent_lambda_report_rest_composite_enabled | bool | false |
| thundra_agent_lambda_report_rest_composite_enabled | bool | false |
| thundra_agent_lambda_error_stacktrace_mask | bool | false |


#### 2. Module initialization parameters
Expand Down
1 change: 1 addition & 0 deletions src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const envVariableKeys = {
THUNDRA_MASK_SQS_MESSAGE: 'thundra_agent_lambda_trace_integrations_aws_sqs_message_mask',
THUNDRA_MASK_LAMBDA_PAYLOAD: 'thundra_agent_lambda_trace_integrations_aws_lambda_payload_mask',
THUNDRA_MASK_HTTP_BODY: 'thundra_agent_lambda_trace_integrations_aws_http_body_mask',
THUNDRA_MASK_ERROR_STACK_TRACE: 'thundra_agent_lambda_error_stacktrace_mask',
};

export function getTimeoutMargin(region: string) {
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ class Utils {
error.errorMessage = JSON.stringify(error.errorMessage);
}

error.stack = Utils.getConfiguration(
envVariableKeys.THUNDRA_MASK_ERROR_STACK_TRACE) ? '' : error.stack;

return error;
}

Expand Down
15 changes: 14 additions & 1 deletion test/plugins/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ jest.mock('os', () => ({

jest.mock('../../dist/Constants', () => ({
PROC_STAT_PATH: './test/mocks/mock-proc-stat',
PROC_IO_PATH: './test/mocks/mock-proc-io'
PROC_IO_PATH: './test/mocks/mock-proc-io',
envVariableKeys: {
THUNDRA_MASK_ERROR_STACK_TRACE: 'thundra_agent_lambda_error_stacktrace_mask',
}
}));

describe('getCpuUsage', () => {
Expand Down Expand Up @@ -132,4 +135,14 @@ describe('parseError', () => {
expect(Utils.parseError(error).errorMessage).toEqual(JSON.stringify(error.message));
});
});

describe('mask stack trace', () => {
const error = new Error('I am an error');

process.env.thundra_agent_lambda_error_stacktrace_mask = 'true';

it('should set error.message as string', () => {
expect(Utils.parseError(error).stack).toEqual('');
});
});
});

0 comments on commit 9a5f192

Please sign in to comment.