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

feat(plugins): add support for importing other modules within a plugin #180

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

jamagalhaes
Copy link
Collaborator

@jamagalhaes jamagalhaes commented Nov 5, 2024

KOALA-2189

This PR adds support for importing other modules within a plugin package.

This PR also replaces the use of find_spec from importlib.util with a safer approach because find_spec will implicitly import the parent module when the given name refers to a submodule.
In particular, this behavior presents a security risk: if a bad actor manages to inject malicious code into the __init__.py file of the package, that code will execute as soon as the package is imported. Since find_spec will import the package to resolve submodules, any malicious code in __init__.py will run even before the sandbox has a chance to apply its restrictions. cc @beaugunderson

@jamagalhaes jamagalhaes force-pushed the feat/koala-2189-plugin-mutiple-modules branch 2 times, most recently from 6e5e358 to abcc0eb Compare November 5, 2024 13:01
@jamagalhaes jamagalhaes marked this pull request as ready for review November 5, 2024 14:50
@jamagalhaes jamagalhaes requested a review from a team as a code owner November 5, 2024 14:50
@nmpsilva nmpsilva requested a review from aduane November 5, 2024 16:17
@jamagalhaes
Copy link
Collaborator Author

@aduane I'm open to suggestions/improvements

@jamagalhaes jamagalhaes force-pushed the feat/koala-2189-plugin-mutiple-modules branch from abcc0eb to bb62d58 Compare November 12, 2024 10:32
@jamagalhaes jamagalhaes force-pushed the feat/koala-2189-plugin-mutiple-modules branch from bb62d58 to bfa133b Compare November 12, 2024 17:43
Copy link
Member

@beaugunderson beaugunderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for the comprehensive tests! added one suggestion

@jamagalhaes jamagalhaes merged commit ac077fe into main Nov 14, 2024
4 checks passed
@jamagalhaes jamagalhaes deleted the feat/koala-2189-plugin-mutiple-modules branch November 14, 2024 12:38
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.

3 participants