icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Disallow empty/integer object names

Open yhabteab opened this issue 3 years ago • 4 comments

This PR sets the required flag for object names to prevent objects with "" or null names from being created.

fixes #9097

yhabteab avatar Jun 21 '22 09:06 yhabteab

Please just make sure

object CheckCommand "cc" { }

object Host "h" {
	check_command = "cc"
	vars.x = [ "y" ]
}

apply Service "" for (x in host.vars.x) {
	check_command = "cc"
}

keeps working. (At least it does with 3bee85ba8.)

Al2Klimov avatar Jul 19 '22 09:07 Al2Klimov

Is that check obsolete now (there are different code branches that set name, so that's not the case necessarily)? Only doing the check there (moving the check out of the if (nc)) would mean that this wouldn't have an effect on templates.

What if we would generate the name from the NameComposer after the expression validation? So, the check would be performed after the first try ... catch! We would then not have to check for emptiness.

yhabteab avatar Jul 22 '22 11:07 yhabteab

By the way, the current state of the current PR still accepts this:

Do you want me to fix this now as well or are you sticking to the below statement?

At the moment, I'm leaning towards doing just 148f5b8, this on its own seems to fix (more testing needed, but looking good so far) the empty object name issue, the part that's actually causing issues here.

yhabteab avatar Jul 25 '22 07:07 yhabteab

or are you sticking to the below statement?

At the moment, I'm leaning towards doing just 148f5b8, this on its own seems to fix (more testing needed, but looking good so far) the empty object name issue, the part that's actually causing issues here.

That one.

julianbrost avatar Jul 25 '22 07:07 julianbrost