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

[App Configuration] Not log value of key #40132

Merged

Conversation

ivywei0125
Copy link
Contributor

Description

When content type is json, we'll check if the value is a valid json. If invalid, throw JsonProcessingException.

Before fix, for a key-value: test_key: test_value, the error message in the log is as the following, contains the value "test_value".
"com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'test_value_3': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (String)"test_value_3"; line: 1, column: 13]"

We shouldn't include the value in logs to avoid any security issue.
After fix, the error message is:
"java.io.IOException: Invalid value of key '/foo/test_key_3'. Expected type: JSON String, Number, Array, Object or token 'null', 'true' or 'false'"

@github-actions github-actions bot added the azure-spring All azure-spring related issues label May 13, 2024
@ivywei0125 ivywei0125 changed the title [App Configuration] Not log value [App Configuration] Not log value of key May 13, 2024
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

JsonNode json = MAPPER.readTree(setting.getValue());
parseSetting(setting.getKey(), json, settings);
} catch (JsonProcessingException e) {
throw new IOException(
Copy link
Member

Choose a reason for hiding this comment

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

InvalidConfigurationPropertyValueException

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked the constructor of InvalidConfigurationPropertyValueException. It requires name, value and reason.
What shall we provide for value? We didn't want to log the value

Copy link
Member

Choose a reason for hiding this comment

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

If you read the description a null value for the value field is allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But is it a little wired that if we use a null value?
The error message would be Property test_key with value 'null' is invalid: Expected type: JSON String, Number, Array, Object or token 'null', 'true' or 'false'

Besides, I also tried to pass an empty string as value. It's also a little wired.
Property test_key with value '' is invalid: Expected type: JSON String, Number, Array, Object or token 'null', 'true' or 'false'

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we do what we do with our logs and put <Redacted>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thanks!

@ivywei0125 ivywei0125 merged commit a78ad26 into Azure:feature/spring-boot-3 May 23, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants