Skip to content

conditionals: fix handling of empty string values#10172

Open
niedbalski wants to merge 4 commits intomasterfrom
fix/10168
Open

conditionals: fix handling of empty string values#10172
niedbalski wants to merge 4 commits intomasterfrom
fix/10168

Conversation

@niedbalski
Copy link
Copy Markdown
Contributor

Summary

  • Allow empty string values for equality comparisons in conditionals
  • Add proper handling of string conditions in processor
  • Fix handling condition types in processor units
  • Add test cases for string condition handling and empty values

Fixes #10168

@leonardo-albertovich
Copy link
Copy Markdown
Contributor

Please don't remove review requests in the future.

Copy link
Copy Markdown
Contributor

@leonardo-albertovich leonardo-albertovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change all the pointer validations to explicitly compare against NULL (not just the ones I marked).

Comment thread src/flb_conditionals.c
case FLB_RULE_OP_EQ:
case FLB_RULE_OP_NEQ:
/* Allow empty string values for equality comparisons */
if (!value) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modify this to explicitly compare with NULL.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, wouldn't this be covered by the conditional in line 62? (which should be modified to explicitly compare the pointer values with NULL)

Comment thread src/flb_conditionals.c
case FLB_RULE_OP_REGEX:
case FLB_RULE_OP_NOT_REGEX:
/* Regex patterns must not be empty */
if (!value || !((char *)value)[0]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modify this to explicitly compare with NULL.
Please refactor the second part of the term to make it clearer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, since I don't see a loop or goto I don't understand why do we need to check that value is not NULL here as well, could you please clarify this?


/* Using cfl_variant_create_from_string instead of a non-existent cfl_variant_set_string */
variant = cfl_variant_create_from_string((char *)value);
if (!variant) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are not doing anything (ie. reporting) if cfl_variant_create_from_string returns NULL why do you have this code? returning variant would be the same.

@railsharipov
Copy link
Copy Markdown

Thank you for working on this. I hope this will be merged soon.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Modify filter conditions does not work when filter is used as input processor

3 participants