Skip to content

Commit

Permalink
fix: cant use getDockerExePath in codec init
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Mar 22, 2024
1 parent 7079c87 commit 485462a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
3 changes: 1 addition & 2 deletions src/docker_base.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "":
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/codecDocker.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/util.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.} =
Expand Down

0 comments on commit 485462a

Please sign in to comment.