cwhub: install --force repair tainted, non-installed items (#2686)

This commit is contained in:
mmetc 2024-01-03 10:08:45 +01:00 committed by GitHub
parent ca784b147b
commit 2a2b09b52a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -101,7 +101,7 @@ func (i *Item) downloadLatest(overwrite bool, updateOnly bool) (string, error) {
} }
} }
if !i.State.Installed && updateOnly && i.State.Downloaded { if !i.State.Installed && updateOnly && i.State.Downloaded && !overwrite {
i.hub.logger.Debugf("skipping upgrade of %s: not installed", i.Name) i.hub.logger.Debugf("skipping upgrade of %s: not installed", i.Name)
return "", nil return "", nil
} }

View file

@ -181,3 +181,15 @@ teardown() {
rune -0 jq '.collections' <(output) rune -0 jq '.collections' <(output)
assert_json '[]' assert_json '[]'
} }
@test "tainted hub file, not enabled, install --force should repair" {
rune -0 cscli scenarios install crowdsecurity/ssh-bf
rune -0 cscli scenarios inspect crowdsecurity/ssh-bf -o json
local_path="$(jq -r '.local_path' <(output))"
echo >> "$local_path"
rm "$local_path"
rune -0 cscli scenarios install crowdsecurity/ssh-bf --force
rune -0 cscli scenarios inspect crowdsecurity/ssh-bf -o json
rune -0 jq -c '.tainted' <(output)
assert_output 'false'
}