Skip to content

tasks: don't panic on a malformed sockets-monitor config - #1697

Open
NRGLine4Sec wants to merge 1 commit into
evilsocket:masterfrom
NRGLine4Sec:harden-task-config
Open

NRGLine4Sec wants to merge 1 commit into
evilsocket:masterfrom
NRGLine4Sec:harden-task-config

Conversation

@NRGLine4Sec

Copy link
Copy Markdown
Contributor

socketsmonitor.initConfig read its fields with bare type assertions: cfg["interval"].(string), cfg["state"].(float64), and the same for proto and family. The configuration is decoded JSON received from the GUI, so a config missing one of these fields, or carrying one of the wrong type, panicked the assertion and took the whole daemon down. A TASK_START for the sockets monitor without a state field crashes with:

panic: interface conversion: interface {} is nil, not float64

This reads each field with a checked conversion and returns a config error instead; New already propagates that error to the caller, which reports it. Valid configurations behave exactly as before, and interval keeps its 5s default.

A unit test covers a valid config, a missing field, a wrong-typed field, the interval default, and a non-object config.

🤖 Generated with Claude Code

initConfig asserted cfg["state"].(float64) and the same for "proto",
"family" and "interval" with no type check. A task config missing a
field, or carrying one of the wrong JSON type, panicked the assertion
and took the whole daemon down (a TASK_START without "state" crashed
with "interface conversion: interface {} is nil, not float64").

Read each field with a checked conversion and return a config error
instead, which the caller already reports. Valid configs behave as
before; "interval" keeps its 5s default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant