Skip to content

Commit

Permalink
fix: Fix athena connection and scanning logic.
Browse files Browse the repository at this point in the history
Update dbcat to 0.10.6 which has part of the fixes.
Fix cli and API to make access and secret keys optional

Fix #153
Fix #155
  • Loading branch information
vrajat committed Nov 25, 2021
1 parent 2c9e219 commit 057f9ad
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion piicatcher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# flake8: noqa
__version__ = "0.17.3"
__version__ = "0.17.4"
4 changes: 2 additions & 2 deletions piicatcher/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ def scan_snowflake(
def scan_athena(
catalog_params: Dict[str, Any],
name: str,
aws_access_key_id: str,
aws_secret_access_key: str,
region_name: str,
s3_staging_dir: str,
aws_access_key_id: Optional[str] = None,
aws_secret_access_key: Optional[str] = None,
scan_type: ScanTypeEnum = ScanTypeEnum.shallow,
incremental: bool = True,
output_format: OutputFormat = OutputFormat.tabular,
Expand Down
4 changes: 2 additions & 2 deletions piicatcher/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def snowflake(
@app.command()
def athena(
name: str = typer.Option(..., help="A memorable name for the database"),
aws_access_key_id: str = typer.Option(..., help="AWS Access Key"),
aws_secret_access_key: str = typer.Option(..., help="AWS Secret Key"),
aws_access_key_id: str = typer.Option(None, help="AWS Access Key"),
aws_secret_access_key: str = typer.Option(None, help="AWS Secret Key"),
region_name: str = typer.Option(..., help="AWS Region Name"),
s3_staging_dir: str = typer.Option(..., help="S3 Staging Dir"),
scan_type: ScanTypeEnum = typer.Option(
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "piicatcher"
version = "0.17.3"
version = "0.17.4"
description = "Find PII data in databases"
authors = ["Tokern <[email protected]>"]
license = "Apache 2.0"
Expand Down
14 changes: 14 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,17 @@ def test_scan_athena(mocker, temp_sqlite_path, app_dir_path):
)
piicatcher.api.scan_database.assert_called_once()
Catalog.add_source.assert_called_once()


def test_scan_athena_iam(mocker, temp_sqlite_path, app_dir_path):
mocker.patch("piicatcher.api.scan_database")
mocker.patch.object(Catalog, "add_source")

scan_athena(
catalog_params={"path": temp_sqlite_path, "app_dir": app_dir_path},
name="test_scan_athena",
region_name="r",
s3_staging_dir="s3",
)
piicatcher.api.scan_database.assert_called_once()
Catalog.add_source.assert_called_once()
13 changes: 13 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ def case_athena_cli():
]


def case_athena_cli_iam():
return [
"scan",
"athena",
"--name",
"athena_cli",
"--region-name",
"us-east-1",
"--s3-staging-dir",
"s3://dummy",
]


@parametrize_with_cases("args", cases=".")
def test_cli(mocker, temp_sqlite_path, args):
mocker.patch("piicatcher.api.scan_database")
Expand Down

0 comments on commit 057f9ad

Please sign in to comment.