Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tools): Load tool configs for docker #84

Merged
merged 6 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/configs/chalk.c42spec
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,6 @@ tools that ship with chalk (see `chalk config`) currently respect it
doc: "Specifies which kind of tool this is."
}

field runs_once {
type: bool
default: true
write_lock: true
doc: "Does the tool implementation get invoked per-artifact or per-run?"
}

field priority {
type: int
default: 50
Expand Down
7 changes: 2 additions & 5 deletions src/confload.nim
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,8 @@ proc loadAllConfigs*() =
stack.addConfLoad(ioConfName, toStream(ioConfig), notEvenDefaults).
addConfLoad(attestConfName, toStream(attestConfig), checkNone)

let chalkOps = chalkConfig.getValidChalkCommandNames()
if commandName in chalkOps or (commandName == "not_supplied" and
chalkConfig.defaultCommand.getOrElse("") in chalkOps):
stack.addConfLoad(sbomConfName, toStream(sbomConfig), checkNone)
stack.addConfLoad(sastConfName, toStream(sastConfig), checkNone)
stack.addConfLoad(sbomConfName, toStream(sbomConfig), checkNone)
stack.addConfLoad(sastConfName, toStream(sastConfig), checkNone)

stack.addCallback(loadLocalStructs)
doRun()
Expand Down
15 changes: 9 additions & 6 deletions src/plugins/externalTool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ proc runOneTool(info: PIInfo, path: string, dict: var ChalkDict): bool =

return info.obj.stopOnSuccess

template toolBase(s: untyped, hostScope: static[bool]) {.dirty.} =
template toolBase(s: untyped) {.dirty.} =
result = ChalkDict()

var
Expand All @@ -104,9 +104,9 @@ template toolBase(s: untyped, hostScope: static[bool]) {.dirty.} =
runSast = chalkConfig.getRunSastTools()

for k, v in chalkConfig.tools:
if not v.enabled or hostScope != v.runs_once: continue
if not runSbom and v.kind == "sbom": continue
if not runSast and v.kind == "sast": continue
if not v.enabled: continue
if not runSbom and v.kind == "sbom": continue
if not runSast and v.kind == "sast": continue
let priority = v.priority
if v.kind notin toolInfo:
toolInfo[v.kind] = @[(priority, PIInfo(name: k, obj: v))]
Expand All @@ -123,11 +123,14 @@ template toolBase(s: untyped, hostScope: static[bool]) {.dirty.} =
return dict

proc toolGetChalkTimeHostInfo*(self: Plugin): ChalkDict {.cdecl.} =
toolBase(getContextDirectories()[0], true)
toolBase(getContextDirectories()[0])

proc toolGetChalkTimeArtifactInfo*(self: Plugin, obj: ChalkObj):
ChalkDict {.cdecl.} =
toolbase(obj.name, false)
if obj.fsRef != "":
toolbase(obj.fsRef)
else:
toolbase(obj.name)

proc loadExternalTool*() =
newPlugin("tool",
Expand Down