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

[profiles] Panic if decisions is missing attributes #3037

Open
LaurenceJJones opened this issue May 30, 2024 · 2 comments
Open

[profiles] Panic if decisions is missing attributes #3037

LaurenceJJones opened this issue May 30, 2024 · 2 comments
Assignees
Labels

Comments

@LaurenceJJones
Copy link
Contributor

What happened?

User from discord was having a panic happen

error : runtime error: invalid memory address or nil pointer dereference
version: v1.6.1-c6e40191
BuildDate: 2024-04-18_13:41:46
GoVersion: 1.21.9
goroutine 803 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x5e
github.com/crowdsecurity/go-cs-lib/trace.WriteStackTrace({0x1da4760?, 0x357b2c0})
        github.com/crowdsecurity/[email protected]/trace/trace.go:26 +0x245
github.com/crowdsecurity/crowdsec/pkg/apiserver.recoverFromPanic(0xc0021fa400)
        github.com/crowdsecurity/crowdsec/pkg/apiserver/apiserver.go:90 +0x39a
panic({0x1da4760?, 0x357b2c0?})
        runtime/panic.go:914 +0x21f
github.com/crowdsecurity/crowdsec/pkg/csprofiles.(*Runtime).GenerateDecisionFromProfile(0xc00053f5c0, 0xc0014a5300)
        github.com/crowdsecurity/crowdsec/pkg/csprofiles/csprofiles.go:148 +0x527
github.com/crowdsecurity/crowdsec/pkg/csprofiles.(*Runtime).EvaluateProfile(0xc00053f5c0, 0xc0014a5300)
        github.com/crowdsecurity/crowdsec/pkg/csprofiles/csprofiles.go:191 +0x29a
github.com/crowdsecurity/crowdsec/pkg/apiserver/controllers/v1.(*Controller).CreateAlert(0xc000c09360, 0xc0021fa400)
        github.com/crowdsecurity/crowdsec/pkg/apiserver/controllers/v1/alerts.go:210 +0x7d2
github.com/gin-gonic/gin.(*Context).Next(0xc0021fa400)
        github.com/gin-gonic/[email protected]/context.go:174 +0x2b
github.com/crowdsecurity/crowdsec/pkg/apiserver/controllers.(*Controller).NewV1.PrometheusMachinesMiddleware.func6(0xc0021fa400)
        github.com/crowdsecurity/crowdsec/pkg/apiserver/controllers/v1/metrics.go:93 +0x185

reason being there decisions array way mistyped

decisions:
 - type: ban
 - duration: 4h

What did you expect to happen?

For the program to handle this improper decisions array and warn the user or bail at startup time with a invalid configuration

How can we reproduce it (as minimally and precisely as possible)?

Alter the default profiles to have

decisions:
 - type: ban
 - duration: 4h

Then generate a decision from normal processing

Anything else we need to know?

No response

Crowdsec version

$ cscli version
# paste output here

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Enabled collections and parsers

$ cscli hub list -o raw
# paste output here

Acquisition config

```console # On Linux: $ cat /etc/crowdsec/acquis.yaml /etc/crowdsec/acquis.d/* # paste output here

On Windows:

C:> Get-Content C:\ProgramData\CrowdSec\config\acquis.yaml

paste output here

Config show

$ cscli config show
# paste output here

Prometheus metrics

$ cscli metrics
# paste output here

Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.

@LaurenceJJones LaurenceJJones added the kind/bug Something isn't working label May 30, 2024
Copy link

@LaurenceJJones: Thanks for opening an issue, it is currently awaiting triage.

In the meantime, you can:

  1. Check Crowdsec Documentation to see if your issue can be self resolved.
  2. You can also join our Discord.
  3. Check Releases to make sure your agent is on the latest version.
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@mmetc mmetc self-assigned this May 30, 2024
@mmetc
Copy link
Contributor

mmetc commented May 30, 2024

#3038

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants