Skip to content

Commit

Permalink
test: checking metsys keys are present for non-chalk pushes
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Nov 5, 2024
1 parent ffb4910 commit 1d00168
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- When running `semgrep`, its always added to `PATH`,
as otherwise semgrep is not able to find `pysemgrep` folder.
([#439](https://github.com/crashappsec/chalk/pull/439))
- Docker pushing non-chalked images did not report metsys
plugin keys such as `_EXIT_CODE`, `_CHALK_RUN_TIME`.
([#438](https://github.com/crashappsec/chalk/pull/438))

### New Features

Expand Down
8 changes: 8 additions & 0 deletions tests/functional/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,14 @@ def test_build_and_push(
assert pull.find("Digest:") == f"sha256:{image_digest}"


def test_push_nonchalked(chalk: Chalk, random_hex: str):
tag_base = f"{REGISTRY}/nonchalked_{random_hex}"
tag = f"{tag_base}:latest"
Docker.build(content="FROM alpine", tag=tag)
push = chalk.docker_push(tag)
assert push.report.has(_OP_EXIT_CODE=0, _CHALK_RUN_TIME=ANY)


@pytest.mark.parametrize("test_file", ["valid/sample_1"])
def test_push_without_buildx(
chalk: Chalk,
Expand Down
1 change: 1 addition & 0 deletions tests/functional/testing.c4m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ custom_report.terminal_other_op.use_when: ["extract", "delete", "exec", "env", "

report_template insertion_default {
key._OP_EXIT_CODE.use = true
key._CHALK_RUN_TIME.use = true
}

report_template report_default {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/utils/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def build_cmd(
for t in tags:
cmd += ["-t", t]
if content:
stdin = content.encode()
stdin = Docker.dockerfile(content).encode()
cmd += ["-f", "-"]
elif dockerfile:
cmd += ["-f", str(dockerfile)]
Expand Down

0 comments on commit 1d00168

Please # to comment.