Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Jinja2 templates in sandboxed environment #639

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Starting with v1.31.6, this file will contain a record of major features and upd
- Fixed openCypher query bug regression in the [`01-About-the-Neptune-Notebook`](https://github.com/aws/graph-notebook/blob/main/src/graph_notebook/notebooks/01-Getting-Started/01-About-the-Neptune-Notebook.ipynb) sample ([Link to PR](https://github.com/aws/graph-notebook/pull/631))
- Fixed `%%graph_notebook_config` error when excluding optional Gremlin section ([Link to PR](https://github.com/aws/graph-notebook/pull/633))
- Fixed `--mode` argument for Neptune DB bulk loader requests via `%load` ([Link to PR](https://github.com/aws/graph-notebook/pull/637))
- Switched to generating Jinja2 templates in sandboxed environment ([Link to PR](https://github.com/aws/graph-notebook/pull/639))

## Release 4.4.2 (June 18, 2024)
- Set Gremlin `connection_protocol` defaults based on Neptune service when generating configuration via arguments ([Link to PR](https://github.com/aws/graph-notebook/pull/626))
Expand Down
7 changes: 5 additions & 2 deletions src/graph_notebook/visualization/template_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@

import os

from jinja2 import Template
from jinja2.sandbox import SandboxedEnvironment

dir_path = os.path.dirname(os.path.realpath(__file__))


def retrieve_template(template_name):
with open('%s/templates/%s' % (dir_path, template_name), 'r') as tab_template_file:
tab_template = tab_template_file.read().strip()
template = Template(tab_template)

env = SandboxedEnvironment()
template = env.from_string(tab_template)

return template
6 changes: 4 additions & 2 deletions src/graph_notebook/visualization/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

import os

from jinja2 import Template
from jinja2.sandbox import SandboxedEnvironment

dir_path = os.path.dirname(os.path.realpath(__file__))
with open('%s/templates/tabs.html' % dir_path, 'r') as tab_template_file:
tab_template = tab_template_file.read().strip()
template = Template(tab_template)

env = SandboxedEnvironment()
template = env.from_string(tab_template)


class Visualizer(object):
Expand Down
Loading