Skip to content

Commit

Permalink
feat(docker): make dockerfile/buildargs specific
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Jun 22, 2021
1 parent caf7958 commit 9cd48f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ggshield/scan/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _get_config(archive: tarfile.TarFile) -> Tuple[Dict, Dict, File]:
json.loads(config_file_content),
File(
config_file_content,
filename=os.path.join(archive.name, config_file_path), # type: ignore
filename="Dockerfile or build-args", # noqa: E501
filesize=config_file_info.size,
),
)
Expand Down
18 changes: 9 additions & 9 deletions tests/scan/test_scan_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ def test_get_files_from_docker_archive(self):
files = get_files_from_docker_archive(DOCKER_EXAMPLE_PATH)

expected_files = {
"6f19b02ab98ac5757d206a2f0f5a4741ad82d39b08b948321196988acb9de8b1.json": None, # noqa: E501
"64a345482d74ea1c0699988da4b4fe6cda54a2b0ad5da49853a9739f7a7e5bbc/layer.tar/app/file_one": "Hello, I am the first file!\n", # noqa: E501
"2d185b802fb3c2e6458fe1ac98e027488cd6aedff2e3d05eb030029c1f24d60f/layer.tar/app/file_three.sh": "echo Life is beautiful.\n", # noqa: E501
"2d185b802fb3c2e6458fe1ac98e027488cd6aedff2e3d05eb030029c1f24d60f/layer.tar/app/file_two.py": """print("Hi! I'm the second file but I'm happy.")\n""", # noqa: E501
"Dockerfile or build-args": None, # noqa: E501
DOCKER_EXAMPLE_PATH
/ "64a345482d74ea1c0699988da4b4fe6cda54a2b0ad5da49853a9739f7a7e5bbc/layer.tar/app/file_one": "Hello, I am the first file!\n", # noqa: E501
DOCKER_EXAMPLE_PATH
/ "2d185b802fb3c2e6458fe1ac98e027488cd6aedff2e3d05eb030029c1f24d60f/layer.tar/app/file_three.sh": "echo Life is beautiful.\n", # noqa: E501
DOCKER_EXAMPLE_PATH
/ "2d185b802fb3c2e6458fe1ac98e027488cd6aedff2e3d05eb030029c1f24d60f/layer.tar/app/file_two.py": """print("Hi! I'm the second file but I'm happy.")\n""", # noqa: E501
}

assert set(files.files) == {
str(DOCKER_EXAMPLE_PATH / file_path) for file_path in expected_files
}
assert set(files.files) == {str(file_path) for file_path in expected_files}

for file_path, expected_content in expected_files.items():
full_path = DOCKER_EXAMPLE_PATH / file_path
file = files.files[str(full_path)]
file = files.files[str(file_path)]
assert expected_content is None or file.document == expected_content

0 comments on commit 9cd48f0

Please sign in to comment.