Skip to content

Conversation

@Eyal-Danieli
Copy link
Member

No description provided.

danielperezz and others added 7 commits September 28, 2025 15:43
* create a CLI for generating item.yaml and organize the CLI directory

* modify comments to module

* PR fixes

* Update cli/common/generate_item_yaml.py

Co-authored-by: Eyal Danieli <eyal_danieli@mckinsey.com>

---------

Co-authored-by: Eyal Danieli <eyal_danieli@mckinsey.com>
…le) (#911)

* histogram data drift module with empty example notebook

* post review fixes
* fill data-drift nb

* post review fixes
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

}

# Load and render template
env = Environment(loader=FileSystemLoader("."))

Check warning

Code scanning / CodeQL

Jinja2 templating with autoescape=False Medium

Using jinja2 templates with autoescape=False can potentially allow XSS attacks.

Copilot Autofix

AI 10 days ago

To fix the problem, we should pass a safe value for autoescape while creating the Jinja2 Environment. The most robust and future-proof way is to use Jinja2’s select_autoescape function, which will auto-enable escaping for html and xml templates, and otherwise leave it disabled (as is safe for YAML). This is the officially recommended approach and the least disruptive.

  • Import select_autoescape from Jinja2.
  • Change line 46 to:
    env = Environment(loader=FileSystemLoader("."), autoescape=select_autoescape(['html', 'xml']))

No further changes are needed unless CLI generates HTML/XML templates in the future, in which case this configuration would protect those, too.


Suggested changeset 1
cli/common/generate_item_yaml.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/cli/common/generate_item_yaml.py b/cli/common/generate_item_yaml.py
--- a/cli/common/generate_item_yaml.py
+++ b/cli/common/generate_item_yaml.py
@@ -2,7 +2,7 @@
 from pathlib import Path
 from datetime import datetime
 import click
-from jinja2 import Environment, FileSystemLoader
+from jinja2 import Environment, FileSystemLoader, select_autoescape
 
 TEMPLATES = {
     "function": "cli/utils/function_item_template.yaml.j2",
@@ -43,7 +43,7 @@
     }
 
     # Load and render template
-    env = Environment(loader=FileSystemLoader("."))
+    env = Environment(loader=FileSystemLoader("."), autoescape=select_autoescape(['html', 'xml']))
     template = env.get_template(TEMPLATES[type])
     rendered = template.render(params)
 
EOF
@@ -2,7 +2,7 @@
from pathlib import Path
from datetime import datetime
import click
from jinja2 import Environment, FileSystemLoader
from jinja2 import Environment, FileSystemLoader, select_autoescape

TEMPLATES = {
"function": "cli/utils/function_item_template.yaml.j2",
@@ -43,7 +43,7 @@
}

# Load and render template
env = Environment(loader=FileSystemLoader("."))
env = Environment(loader=FileSystemLoader("."), autoescape=select_autoescape(['html', 'xml']))
template = env.get_template(TEMPLATES[type])
rendered = template.render(params)

Copilot is powered by AI and may make mistakes. Always verify output.
@Eyal-Danieli Eyal-Danieli merged commit 628494a into master Nov 10, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants