Skip to content

Commit 1778aa6

Browse files
committed
fix security concern for temp files
1 parent 975e3d1 commit 1778aa6

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

airbyte_cdk/test/standard_tests/docker_base.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,13 @@ def test_docker_image_build_and_read(
283283
container_config_path = "/secrets/config.json"
284284
container_catalog_path = "/secrets/catalog.json"
285285

286-
discovered_catalog_path = Path(
287-
tempfile.mktemp(prefix=f"{connector_name}-discovered-catalog-", suffix=".json")
288-
)
289-
configured_catalog_path = Path(
290-
tempfile.mktemp(prefix=f"{connector_name}-configured-catalog-", suffix=".json")
291-
)
292-
with scenario.with_temp_config_file(
293-
connector_root=connector_root,
294-
) as temp_config_file:
286+
with (
287+
scenario.with_temp_config_file(
288+
connector_root=connector_root,
289+
) as temp_config_file,
290+
tempfile.TemporaryDirectory(delete=False) as temp_dir_str,
291+
):
292+
temp_dir = Path(temp_dir_str)
295293
discover_result = run_docker_command(
296294
[
297295
"docker",
@@ -326,7 +324,7 @@ def test_docker_image_build_and_read(
326324
streams_list = [stream.name for stream in discovered_catalog.streams]
327325
if read_from_streams == "default" and metadata.data.suggestedStreams:
328326
# set `streams_list` to be the intersection of discovered and suggested streams.
329-
streams_list = list(set(streams_list) & set(metadata.data.suggestedStreams))
327+
streams_list = list(set(streams_list) & set(metadata.data.suggestedStreams.streams))
330328

331329
if isinstance(read_from_streams, list):
332330
# If `read_from_streams` is a list, we filter the discovered streams.
@@ -343,6 +341,7 @@ def test_docker_image_build_and_read(
343341
if stream.name in streams_list
344342
]
345343
)
344+
configured_catalog_path = temp_dir / "catalog.json"
346345
configured_catalog_path.write_text(
347346
orjson.dumps(asdict(configured_catalog)).decode("utf-8")
348347
)

0 commit comments

Comments
 (0)