Skip to content

Commit

Permalink
cwhub: install --force repair tainted, non-installed items
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Dec 22, 2023
1 parent b6f272d commit 2a29bd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cwhub/itemupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
return "", nil
}
Expand Down
12 changes: 12 additions & 0 deletions test/bats/20_hub_items.bats
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,15 @@ teardown() {
rune -0 jq '.collections' <(output)
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'
}

0 comments on commit 2a29bd5

Please sign in to comment.