Skip to content

Commit 1d89310

Browse files
fix: normalize scope within range to ensure allowlist check (#3735)
1 parent c61fa15 commit 1d89310

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmd/crowdsec-cli/clidecision/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (cli *cliDecisions) import_(ctx context.Context, input string, duration str
199199
decisionsStr := make([]string, 0, len(chunk))
200200

201201
for _, d := range chunk {
202-
if *d.Scope != types.Ip && *d.Scope != types.Range {
202+
if normalizedScope := types.NormalizeScope(*d.Scope); normalizedScope != types.Ip && normalizedScope != types.Range {
203203
continue
204204
}
205205

test/bats/cscli-allowlists.bats

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ teardown() {
167167
assert_stderr --partial 'Decision successfully added'
168168
}
169169

170+
@test "cscli allowlist: check lowercase range decisions import" {
171+
rune -0 cscli allowlist create foo -d 'a foo'
172+
rune -0 cscli allowlist add foo 192.168.0.0/16
173+
rune -0 cscli decisions import -i - <<<'192.168.0.0/24' --format values --scope range
174+
assert_output - <<-EOT
175+
Parsing values
176+
Value 192.168.0.0/24 is allowlisted by [192.168.0.0/16 from foo]
177+
Imported 0 decisions
178+
EOT
179+
refute_stderr
180+
}
181+
170182
@test "cscli allowlists check" {
171183
rune -0 cscli allowlist create foo -d 'a foo'
172184
rune -0 cscli allowlist add foo 192.168.0.0/16

0 commit comments

Comments
 (0)