Skip to content

Conversation

@TharmiganK
Copy link
Contributor

Purpose

$Subject

Discussion issue #1376


#### Configuration to Enable/Disable Sensitive Data Exclusion

By default, sensitive data exclusion is enabled. However, users can configure the logging package to disable this feature if needed. The `ballerina/log` package provide a global configuration option to control sensitive data exclusion behavior.
Copy link
Member

Choose a reason for hiding this comment

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

What is the usecase for users to enable sensitive data logging ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is useful in testing in development time where we need to verify some sensitive data. Also the proposed method has its own performance tradeoff(getting the mask string representation requires to check for the annotation which can affect the performance in runtime), and if the developer avoided printing any sensitive data by themself, then they don't want this performance drop.

Copy link
Member

Choose a reason for hiding this comment

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

This is useful in testing in development time where we need to verify some sensitive data.

IMO, it's likely that sensitive data would be stored in a datastore, so viewing it in logs might not be a common use case during dev testing.

Also the proposed method has its own performance tradeoff(getting the mask string representation requires to check for the annotation which can affect the performance in runtime), and if the developer avoided printing any sensitive data by themself, then they don't want this performance drop.

Agree that there would be a performance hit with the annotation processing. Did we consider any alternative approaches (maybe from Java logging frameworks) to solve this problem ? Maybe a pattern-matching based approach ? [1][2]

[1] - https://is.docs.wso2.com/en/7.0.0/deploy/monitor/log4j-mask-sensitive-information-in-logs/
[2] - https://www.baeldung.com/logback-mask-sensitive-data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The alternative section covers this where we can pass the masking function to the custom logger. But that is not intutive enough. Since Ballerina is type oriented, following approach seems to be suitable for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had a call, and agreed to do a comprehensive performance test once this is implemented. Based on the results we may have to disable it as default

Copy link
Member

Choose a reason for hiding this comment

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

I think having a configuration that enables sensible data masking and make it disabled by default is the right way to go. MI has the same experience. https://mi.docs.wso2.com/en/latest/administer/logging-and-monitoring/logging/masking-sensitive-information-in-logs/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we will proceed like that

Btw the perf results: #1376 (comment)


## Summary

This proposal introduces a mechanism to exclude sensitive data from being serialized in log output within the `ballerina/log` package. This enhancement addresses security concerns by preventing accidental exposure of sensitive information such as passwords, API keys, tokens, and other confidential data in application logs.
Copy link
Contributor

Choose a reason for hiding this comment

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

@TharmiganK While keeping BI in mind, if a low code developer (Who has no idea about the Ballerina concepts), try to use this feature but unaware of Ballerina's type system and directly use JSON or XML or any other text format, how would he apply these EXCLUDE and REPLACEMENT strategies via either annotation or function pointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the developers are using plain JSON or XML values then it is not possible to use this feature since the current proposed approach is coupled with the type system.

In that case, having a pattern matching approach (suggested by @ayeshLK) might work. For custom loggers developer has to implement the mask function (refer to alternative section) and for root logger, it can be based on pattern matching and the the regex patterns to mask sensitive data can be configured via the Config.toml.

@daneshk @ThisaruGuruge Appreciate your input on this

(Btw IMO, not knowing the Ballerina's type system might greatly affect the experience in low code. They cannot ensure type-safety and moreover they cannot use features that are coupled with type system - constraint validation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had a call, and agreed to go ahead with the annotation based approach. Discuss about BI support for annotation to support annotation based features

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants