From 485462a7d57e4eced5789eb3ddb879f4efaea213 Mon Sep 17 00:00:00 2001 From: Miroslav Shubernetskiy Date: Thu, 21 Mar 2024 23:10:26 -0400 Subject: [PATCH] fix: cant use getDockerExePath in codec init --- .github/pull_request_template.md | 1 + CHANGELOG.md | 7 +++++++ src/docker_base.nim | 3 +-- src/plugins/codecDocker.nim | 4 +++- src/util.nim | 6 +++--- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 7f1e43ed..e9aa0239 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -3,6 +3,7 @@ - [ ] Followed the steps in the contributor's guide: https://crashoverride.com/docs/other/contributing#filing-the-pull-request - [ ] PR title uses [semantic commit messages](https://nitayneeman.com/posts/understanding-semantic-commit-messages-using-git-and-angular/#fix) - [ ] Filled out the template to a useful degree +- [ ] Updated `CHANGELOG.md` if necessary ## Issue diff --git a/CHANGELOG.md b/CHANGELOG.md index 216b2259..86d50e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,13 @@ `AWS_DEFAULT_REGION` environment variables were not set [#246](https://github.com/crashappsec/chalk/pull/246) +### Fixes + +- Docker codec is bypassed when "docker" is not installed. + Otherwise any chalk sub-scan such as during `chalk exec` + had misleading error logs. + [#248](https://github.com/crashappsec/chalk/pull/248) + ## 0.3.4 **Mar 18, 2024** diff --git a/src/docker_base.nim b/src/docker_base.nim index c43cbaea..14ac6b7f 100644 --- a/src/docker_base.nim +++ b/src/docker_base.nim @@ -30,11 +30,10 @@ template extractBoxedDockerHash*(value: Box): Box = proc getDockerExeLocation*(): string = once: - trace("Searching PATH for 'docker'") let dockerConfigPath = chalkConfig.getDockerExe() dockerExeOpt = findExePath("docker", - configPath = dockerConfigPath, + configPath = dockerConfigPath, ignoreChalkExes = true) dockerExeLocation = dockerExeOpt.get("") if dockerExeLocation == "": diff --git a/src/plugins/codecDocker.nim b/src/plugins/codecDocker.nim index 1bdac674..cc6e8a2c 100644 --- a/src/plugins/codecDocker.nim +++ b/src/plugins/codecDocker.nim @@ -599,7 +599,9 @@ proc dockerExtractChalkMark*(chalk: ChalkObj): ChalkDict {.exportc, cdecl.} = addUnmarked(chalk.name) proc loadCodecDocker*() = - if getDockerExeLocation() == "": + # cant use getDockerExePath as that uses codecs to ignore chalk + # wrappings hence we just check if anything docker is on PATH here + if nimutils.findExePath("docker") == "": warn("Disabling docker codec as docker command is not available") else: newCodec("docker", diff --git a/src/util.nim b/src/util.nim index 044b23f6..9c7ea1fd 100644 --- a/src/util.nim +++ b/src/util.nim @@ -363,7 +363,7 @@ proc findExePath*(cmdName: string, # takes precedence over rest of dirs in PATH paths = @[configPath.get()] & paths - trace("Searching path for " & cmdName) + trace("Searching PATH for " & cmdName) var foundExes = findAllExePaths(cmdName, paths, usePath) if ignoreChalkExes: @@ -386,10 +386,10 @@ proc findExePath*(cmdName: string, foundExes = newExes if foundExes.len() == 0: - trace("Could not find '" & cmdName & "' in path.") + trace("Could not find '" & cmdName & "' in PATH.") return none(string) - trace("Found '" & cmdName & "' in path: " & foundExes[0]) + trace("Found '" & cmdName & "' in PATH: " & foundExes[0]) return some(foundExes[0]) proc handleExec*(prioritizedExes: seq[string], args: seq[string]) {.noreturn.} =