Security constraints for :sample: keyword arguments
masterThe :sample: generation process uses eval() to parse arguments, which necessitates strict validation to prevent security risks. When providing KWARGS in a :sample: line, they must adhere to the following rules:
- Allowed Types: Keyword arguments must be literal values or
OrderedDictobjects. - Prohibited Operations: You cannot perform arithmetic (e.g.,
a=1+1) or call other built-in functions within the:sample:line. - Validation Failures: Any attempt to use non-literal values or unauthorized code will cause the validation to fail, and a warning will be logged to the console.
For implementation details regarding validation, refer to faker.sphinx.validator.SampleCodeValidator and faker.sphinx.docstring.ProviderMethodDocstring in the source code.