-
Notifications
You must be signed in to change notification settings - Fork 314
Description
Describe the bug
As a user I want to use typespec generated clients that are free from CWE warnings.
Actual behavior
Client is getting CWE warnings due to insecure function use.
The clients are using xml.etree.ElementTree.fromstring
which is considered insecure generating CWE-611 warnings.
The jinja templates literally are trying to ignore this problem by using # nosec
tags.
typespec/packages/http-client-python/generator/pygen/codegen/templates/serialization.py.jinja2
Line 103 in f7fc86f
return ET.fromstring(data_as_str) # nosec typespec/packages/http-client-python/generator/pygen/codegen/templates/serialization.py.jinja2
Line 103 in f7fc86f
return ET.fromstring(data_as_str) # nosec
Expected behavior
Clients would use defusedxml which is considered safe.
It would be best to use the safe package. At a minimum a statement regarding why this may be ignored would be helpful.
Reproduction
npm install -g @typespec/compiler
tsp --version
1.2.1
tsp init
... choose REST
... include python client emitter
// update tsp config.yaml to emit to emitter-output-dir: "{cwd}/clientpy"
tsp compile .
snyk code test
FireShot Capture 018 - PR Check - Snyk - [app.snyk.io].pdf
Details:
- Review README on branch: https://github.com/joekiller/typespec-pyclient-snyk-CWE-611/tree/trigger-cwe-warning and
- feat: add python client triggering CWE-611 joekiller/typespec-pyclient-snyk-CWE-611#2
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.