Skip to content

Commit a362b69

Browse files
feat: [SNOW-1890085] use SecurePath
1 parent 3c17ebb commit a362b69

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/snowflake/cli/_plugins/dbt/commands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from __future__ import annotations
1616

1717
import logging
18-
from pathlib import Path
1918
from typing import Optional
2019

2120
import typer
@@ -27,6 +26,7 @@
2726
from snowflake.cli.api.feature_flags import FeatureFlag
2827
from snowflake.cli.api.identifiers import FQN
2928
from snowflake.cli.api.output.types import CommandResult, MessageResult, QueryResult
29+
from snowflake.cli.api.secure_path import SecurePath
3030

3131
app = SnowTyperFactory(
3232
name="dbt",
@@ -84,9 +84,9 @@ def deploy_dbt(
8484
Copy dbt files and create or update dbt on Snowflake project.
8585
"""
8686
if source is None:
87-
path = Path.cwd()
87+
path = SecurePath.cwd()
8888
else:
89-
path = Path(source)
89+
path = SecurePath(source)
9090
return QueryResult(
9191
DBTManager().deploy(
9292
path.resolve(),

src/snowflake/cli/_plugins/dbt/manager.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
from __future__ import annotations
1616

17-
from pathlib import Path
1817
from typing import Optional
1918

2019
import yaml
2120
from click import ClickException
2221
from snowflake.cli._plugins.stage.manager import StageManager
2322
from snowflake.cli.api.console import cli_console
23+
from snowflake.cli.api.constants import DEFAULT_SIZE_LIMIT_MB
2424
from snowflake.cli.api.identifiers import FQN
25+
from snowflake.cli.api.secure_path import SecurePath
2526
from snowflake.cli.api.sql_execution import SqlExecutionMixin
2627
from snowflake.connector.cursor import SnowflakeCursor
2728

@@ -33,19 +34,19 @@ def list(self) -> SnowflakeCursor: # noqa: A003
3334

3435
def deploy(
3536
self,
36-
path: Path,
37+
path: SecurePath,
3738
name: FQN,
3839
dbt_version: Optional[str],
3940
dbt_adapter_version: str,
4041
execute_in_warehouse: Optional[str],
4142
force: bool,
4243
) -> SnowflakeCursor:
43-
dbt_project_path = path.joinpath("dbt_project.yml")
44+
dbt_project_path = path / "dbt_project.yml"
4445
if not dbt_project_path.exists():
4546
raise ClickException(f"dbt_project.yml does not exist in provided path.")
4647

4748
if dbt_version is None:
48-
with dbt_project_path.open() as fd:
49+
with dbt_project_path.open(read_file_limit_mb=DEFAULT_SIZE_LIMIT_MB) as fd:
4950
dbt_project_config = yaml.safe_load(fd)
5051
try:
5152
dbt_version = dbt_project_config["version"]
@@ -61,7 +62,7 @@ def deploy(
6162
stage_manager.create(stage_fqn, temporary=True)
6263

6364
with cli_console.phase("Copying project files to stage"):
64-
results = list(stage_manager.put_recursive(path, stage_name))
65+
results = list(stage_manager.put_recursive(path.path, stage_name))
6566
cli_console.step(f"Copied {len(results)} files")
6667

6768
with cli_console.phase("Creating DBT project"):

src/snowflake/cli/api/secure_path.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def absolute(self):
7272
"""
7373
return SecurePath(self._path.absolute())
7474

75+
@classmethod
76+
def cwd(cls) -> SecurePath:
77+
return cls(Path.cwd())
78+
7579
def resolve(self):
7680
"""
7781
Make the path absolute, resolving symlinks

0 commit comments

Comments
 (0)