canvas 0.13.3__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of canvas might be problematic. Click here for more details.
- {canvas-0.13.3.dist-info → canvas-0.15.0.dist-info}/METADATA +1 -3
- {canvas-0.13.3.dist-info → canvas-0.15.0.dist-info}/RECORD +69 -46
- canvas_cli/templates/plugins/default/{{ cookiecutter.__project_slug }}/protocols/my_protocol.py +1 -1
- canvas_generated/messages/effects_pb2.py +2 -2
- canvas_generated/messages/effects_pb2.pyi +6 -0
- canvas_generated/messages/events_pb2.py +2 -2
- canvas_generated/messages/events_pb2.pyi +8 -0
- canvas_sdk/commands/tests/protocol/tests.py +3 -1
- canvas_sdk/commands/tests/test_utils.py +76 -18
- canvas_sdk/effects/banner_alert/tests.py +41 -20
- canvas_sdk/effects/questionnaire_result.py +29 -0
- canvas_sdk/events/base.py +1 -3
- canvas_sdk/handlers/action_button.py +5 -2
- canvas_sdk/handlers/application.py +1 -1
- canvas_sdk/handlers/cron_task.py +1 -1
- canvas_sdk/protocols/clinical_quality_measure.py +1 -1
- canvas_sdk/v1/apps.py +7 -0
- canvas_sdk/v1/data/__init__.py +75 -4
- canvas_sdk/v1/data/allergy_intolerance.py +3 -7
- canvas_sdk/v1/data/billing.py +2 -5
- canvas_sdk/v1/data/command.py +19 -8
- canvas_sdk/v1/data/condition.py +3 -7
- canvas_sdk/v1/data/detected_issue.py +4 -9
- canvas_sdk/v1/data/device.py +4 -8
- canvas_sdk/v1/data/imaging.py +12 -17
- canvas_sdk/v1/data/lab.py +16 -29
- canvas_sdk/v1/data/medication.py +3 -7
- canvas_sdk/v1/data/note.py +7 -14
- canvas_sdk/v1/data/observation.py +4 -11
- canvas_sdk/v1/data/organization.py +1 -2
- canvas_sdk/v1/data/patient.py +0 -1
- canvas_sdk/v1/data/practicelocation.py +2 -4
- canvas_sdk/v1/data/protocol_override.py +3 -6
- canvas_sdk/v1/data/questionnaire.py +5 -15
- canvas_sdk/v1/data/staff.py +5 -7
- canvas_sdk/v1/data/task.py +5 -11
- canvas_sdk/v1/data/user.py +0 -1
- canvas_sdk/v1/models.py +4 -0
- plugin_runner/aws_headers.py +77 -0
- plugin_runner/plugin_installer.py +26 -8
- plugin_runner/plugin_runner.py +5 -25
- plugin_runner/sandbox.py +105 -9
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/CANVAS_MANIFEST.json +38 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/README.md +11 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/protocols/my_protocol.py +33 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/templates/__init__.py +3 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/templates/base.py +6 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/utils/__init__.py +5 -0
- plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/utils/base.py +4 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/CANVAS_MANIFEST.json +29 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/README.md +12 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/other_module/base.py +10 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/protocols/my_protocol.py +18 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/CANVAS_MANIFEST.json +29 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/README.md +12 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/other_module/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/other_module/base.py +10 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/protocols/__init__.py +0 -0
- plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/protocols/my_protocol.py +18 -0
- plugin_runner/tests/test_application.py +9 -9
- plugin_runner/tests/test_plugin_installer.py +22 -13
- plugin_runner/tests/test_plugin_runner.py +171 -32
- plugin_runner/tests/test_sandbox.py +18 -14
- settings.py +7 -1
- canvas_sdk/models/__init__.py +0 -7
- {canvas-0.13.3.dist-info → canvas-0.15.0.dist-info}/WHEEL +0 -0
- {canvas-0.13.3.dist-info → canvas-0.15.0.dist-info}/entry_points.txt +0 -0
|
@@ -14,6 +14,11 @@ import os
|
|
|
14
14
|
result = os.listdir('.')
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
+
CODE_WITH_PLUGIN_RUNNER_SETTING_IMPORT = """
|
|
18
|
+
import settings
|
|
19
|
+
result = settings.AWS_SECRET_ACCESS_KEY
|
|
20
|
+
"""
|
|
21
|
+
|
|
17
22
|
CODE_WITH_ALLOWED_IMPORT = """
|
|
18
23
|
import json
|
|
19
24
|
result = json.dumps({"key": "value"})
|
|
@@ -23,9 +28,9 @@ CODE_WITH_FORBIDDEN_FUNC_NAME = """
|
|
|
23
28
|
builtins = {}
|
|
24
29
|
"""
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
import
|
|
28
|
-
result =
|
|
31
|
+
SOURCE_CODE_MODULE = """
|
|
32
|
+
import module.b
|
|
33
|
+
result = module.b
|
|
29
34
|
"""
|
|
30
35
|
|
|
31
36
|
|
|
@@ -39,7 +44,14 @@ def test_valid_code_execution() -> None:
|
|
|
39
44
|
def test_disallowed_import() -> None:
|
|
40
45
|
"""Test that restricted imports are not allowed."""
|
|
41
46
|
sandbox = Sandbox(CODE_WITH_RESTRICTED_IMPORT)
|
|
42
|
-
with pytest.raises(ImportError, match="os' is not an allowed import."):
|
|
47
|
+
with pytest.raises(ImportError, match="'os' is not an allowed import."):
|
|
48
|
+
sandbox.execute()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_plugin_runner_settings_import() -> None:
|
|
52
|
+
"""Test that imports of plugin runner settings are not allowed."""
|
|
53
|
+
sandbox = Sandbox(CODE_WITH_PLUGIN_RUNNER_SETTING_IMPORT)
|
|
54
|
+
with pytest.raises(ImportError, match="'settings' is not an allowed import."):
|
|
43
55
|
sandbox.execute()
|
|
44
56
|
|
|
45
57
|
|
|
@@ -98,16 +110,8 @@ print("Hello, Sandbox!")
|
|
|
98
110
|
assert "Hello, Sandbox!" in scope["_print"].txt, "Print output should be captured."
|
|
99
111
|
|
|
100
112
|
|
|
101
|
-
def test_sandbox_module_name_imports_within_package() -> None:
|
|
102
|
-
"""Test that modules within the same package can be imported."""
|
|
103
|
-
sandbox_module_a = Sandbox(source_code=SOURCE_CODE_MODULE_OS, namespace="os.a")
|
|
104
|
-
result = sandbox_module_a.execute()
|
|
105
|
-
|
|
106
|
-
assert "os" in result
|
|
107
|
-
|
|
108
|
-
|
|
109
113
|
def test_sandbox_denies_module_name_import_outside_package() -> None:
|
|
110
114
|
"""Test that modules outside the root package cannot be imported."""
|
|
111
|
-
sandbox_module_a = Sandbox(source_code=
|
|
112
|
-
with pytest.raises(ImportError, match="
|
|
115
|
+
sandbox_module_a = Sandbox(source_code=SOURCE_CODE_MODULE, namespace="other_module.a")
|
|
116
|
+
with pytest.raises(ImportError, match="module.b' is not an allowed import."):
|
|
113
117
|
sandbox_module_a.execute()
|
settings.py
CHANGED
|
@@ -19,7 +19,9 @@ INTEGRATION_TEST_CLIENT_SECRET = os.getenv("INTEGRATION_TEST_CLIENT_SECRET")
|
|
|
19
19
|
|
|
20
20
|
GRAPHQL_ENDPOINT = os.getenv("GRAPHQL_ENDPOINT", "http://localhost:8000/plugins-graphql")
|
|
21
21
|
|
|
22
|
-
INSTALLED_APPS = [
|
|
22
|
+
INSTALLED_APPS = [
|
|
23
|
+
"canvas_sdk.v1",
|
|
24
|
+
]
|
|
23
25
|
|
|
24
26
|
SECRET_KEY = os.getenv(
|
|
25
27
|
"SECRET_KEY",
|
|
@@ -49,6 +51,10 @@ else:
|
|
|
49
51
|
|
|
50
52
|
DATABASES = {"default": database_dict}
|
|
51
53
|
|
|
54
|
+
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID", "")
|
|
55
|
+
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY", "")
|
|
56
|
+
AWS_REGION = os.getenv("AWS_REGION", "us-west-2")
|
|
57
|
+
MEDIA_S3_BUCKET_NAME = os.getenv("MEDIA_S3_BUCKET_NAME", "canvas-client-media")
|
|
52
58
|
|
|
53
59
|
PLUGIN_RUNNER_SIGNING_KEY = os.getenv("PLUGIN_RUNNER_SIGNING_KEY", "")
|
|
54
60
|
|
canvas_sdk/models/__init__.py
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# ruff: noqa
|
|
2
|
-
# register all models in the app so they can be used with apps.get_model()
|
|
3
|
-
from canvas_sdk.v1.data.command import Command
|
|
4
|
-
from canvas_sdk.v1.data.condition import Condition
|
|
5
|
-
from canvas_sdk.v1.data.note import Note
|
|
6
|
-
from canvas_sdk.v1.data.patient import Patient
|
|
7
|
-
from canvas_sdk.v1.data.user import CanvasUser
|
|
File without changes
|
|
File without changes
|