cwhub: install --force repair tainted, non-installed items (#2686)
This commit is contained in:
parent
ca784b147b
commit
2a2b09b52a
2 changed files with 13 additions and 1 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue