Add input validation to report generator controller endpoints. #1219
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request adds input validation filters to the user-supplied
untrusted data provided to the report generator controller endpoints.
The modifications do not change any of the data serialization or api of
the endpoints.
The user-supplied report text (title, header, footer etc.) is modified
to filter out data that does not have a valid character encoding. This
mitigates a bug in the report generator if you tried to create a report
with a filename containing an invalid character such as 😊 then the UI would
show an error message:
the new behaviour is that the report will save ok but any invalid
characters will be converted to '?'. A complete fix for this bug is
beyond the scope of this pull request.
Motivation and Context
Potential security vulnerability using untrusted user data.
Tests performed
There are several complex regular expressions used to validate the data
this is necessary due to the non-standard serialization used in the
report generator. Unit tests have been added to confirm that the more
complex regular expressions used do pass through permissible data.