Repository navigation
fix(declarative): require AIRBYTE_ENABLE_UNSAFE_CODE to instantiate Custom* components from YAML - #1076
Conversation
…ustom components Co-Authored-By: AJ Steers <aj@airbyte.io>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1784682886-gate-custom-component-code-exec#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1784682886-gate-custom-component-code-execPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
Co-Authored-By: AJ Steers <aj@airbyte.io>
AIRBYTE_ENABLE_UNSAFE_CODE to instantiate custom components
📝 WalkthroughWalkthroughCustom component creation now requires explicit custom-code permission before class resolution. Declarative test fixtures enable custom code by default, and tests verify disabled execution raises the permission error before imports occur. ChangesCustom code execution gate
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: AJ Steers <aj@airbyte.io>
AIRBYTE_ENABLE_UNSAFE_CODE to instantiate custom componentsAIRBYTE_ENABLE_UNSAFE_CODE to instantiate Custom* components from YAML
PyTest Results (Full)4 136 tests 4 124 ✅ 11m 42s ⏱️ Results for commit 2dee31c. |
Summary
Hardens the custom-component path so that instantiating a
Custom*component honors the sameAIRBYTE_ENABLE_UNSAFE_CODEgate that already protects injectedcomponents.pysource.Previously, only injected
components.pysource was gated (inget_registered_components_module). Theclass_nameresolution path inModelToComponentFactory.create_custom_componentwas not gated: it resolves an arbitrary fully-qualifiedclass_nameviaimportlib.import_module+getattrand then calls it with manifest-supplied kwargs, regardless ofAIRBYTE_ENABLE_UNSAFE_CODE. This meant a manifest could cause arbitrary importable code to be executed even in environments where custom code execution is meant to be disabled.Fix — add a guard at the top of
create_custom_component, before the class is resolved/imported:This centralizes enforcement for every
Custom*model type (they all route throughcreate_custom_component), and the check fires before any import happens.Tests
test_create_custom_component_requires_custom_code_enabledassertsAirbyteCustomCodeNotPermittedErroris raised when the env var is unset — both for a bundled custom-component class and for an arbitrary importable callable — verifying the gate fires before import.unit_tests/conftest.pythat enablesAIRBYTE_ENABLE_UNSAFE_CODEby default, reflecting the new precondition for building custom components. Gate-focused tests opt out via their ownmonkeypatch.Ran
unit_tests/sources/declarativecustom-component tests, the injected-code gate tests, and the previously-affected source/manifest suites locally — all green.ruff format/ruff checkclean.Relates to advisory
GHSA-g35w-6r6v-h4r7. Draft pending maintainer review of disclosure timing.Link to Devin session: https://app.devin.ai/sessions/091d09a568eb48018f82dd6ed27d2445
Requested by: Aaron ("AJ") Steers (@aaronsteers)
Summary by CodeRabbit
Bug Fixes
Tests
Important
Auto-merge enabled.
This PR is set to merge automatically when all requirements are met.