Fixed mutable object used as kwarg for Server ctor #376
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.
Hello,
I am a security engineer at r2c.dev. We are working to write code
checks for security in open source code.
In python, the default values of function parameters are instantiated
at function definition time. All calls to that function that use the
default value all point to the same global object. e.g.:
Because of this, two instances of Server (initialized without passing
in a protocol_config option) actually share the same protocol_config.
So modifying one server's config affects the other ones.
Fix:
The recommended solution is to either set default to None and assign
a new empty object when the variable is None.
We have a tool called Bento you can use for your project that continuously detects problems like this one. The check that identified this issue will be available in the very near future.
Thanks, and I hope this helps! Let me know if you have any questions.