Snowflake Apps: gate deprecated Snowpark processor behind a feature flag [SNOW-3417033]#2987
Draft
sfc-gh-olorek wants to merge 1 commit into
Draft
Snowflake Apps: gate deprecated Snowpark processor behind a feature flag [SNOW-3417033]#2987sfc-gh-olorek wants to merge 1 commit into
sfc-gh-olorek wants to merge 1 commit into
Conversation
…lag [SNOW-3417033] The Snowpark annotation processor has been deprecated for several releases and emits a warning on every invocation (`Snowpark processor is not supported and will be removed soon.`). However, by default it still runs whenever a Native App project declares `processors: [snowpark]`, and its job is to execute every annotated `.py` artifact in a subprocess so that module-level objects can be introspected. That implicit code execution during `snow app bundle`/`deploy` is a gratuitous source of arbitrary-code-execution risk for any flow that pulls a repository before building it (e.g. review automation, CI where the repo is attacker-influenced). Following the pattern already used by `NativeAppSetupProcessor` + `ENABLE_NATIVE_APP_PYTHON_SETUP`, this change introduces `ENABLE_SNOWPARK_ANNOTATION_PROCESSOR` (default off) and wires it through `SnowparkAnnotationProcessor.is_enabled()`, which the compiler already honours to skip disabled processors. Users who still rely on the processor can opt in via config (`snowflake.cli.features.enable_snowpark_annotation_processor = true`) or env (`SNOWFLAKE_CLI_FEATURES_ENABLE_SNOWPARK_ANNOTATION_PROCESSOR=1`), which is the same mechanism documented for every other feature flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-review checklist
Changes description
Referenced Jira: SNOW-3417033.
The Snowpark annotation processor (
processors: [snowpark]in a Native App project definition) has been deprecated for several releases and emits a warning on every invocation:Despite the deprecation, the processor still runs by default whenever a project's artifacts declare it. Its job is to execute every annotated
.pyartifact in a subprocess (viaexecute_script_in_sandbox→importlib.util.exec_module) so that module-level objects can be introspected to emit SQL. That implicit code execution duringsnow app bundle/snow app deployis a gratuitous source of arbitrary-code-execution risk for any flow that pulls a repository before building it (review automation, CI pipelines where the repo is attacker-influenced, etc.).This PR applies the Jira-recommended mitigation: gate the processor behind an explicit opt-in feature flag, matching the existing pattern used by
NativeAppSetupProcessor/ENABLE_NATIVE_APP_PYTHON_SETUP.What changed
ENABLE_SNOWPARK_ANNOTATION_PROCESSOR(defaultFalse) insnowflake.cli.api.feature_flags.SnowparkAnnotationProcessornow exposes a staticis_enabled()method that returns the flag's value. The compiler already honoursis_enabled()on registered processors and silently skips disabled ones (seecompiler._is_enabled), so no compiler changes are required — invoking asnowparkprocessor while the flag is off is now a no-op.ENABLE_NATIVE_APP_PYTHON_SETUPtest.Behaviour for users who still rely on the processor
Opt in with one of:
config.toml:SNOWFLAKE_CLI_FEATURES_ENABLE_SNOWPARK_ANNOTATION_PROCESSOR=1Scope
py_filepath injection into the sandbox Jinja template); that is complementary hardening and remains useful even with this gate._execute_in_sandboxor the Jinja template.Tests
tests/nativeapp/test_feature_flags.py::test_feature_snowpark_annotation_processor_enabled— covers both truthy and falsy config values and verifies the correct config key.tests/nativeapp/suite passes (3345 tests) on Python 3.10.