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

Float and null type support #197

Merged
merged 10 commits into from
Aug 7, 2023
Merged

Float and null type support #197

merged 10 commits into from
Aug 7, 2023

Conversation

Anilm3
Copy link
Collaborator

@Anilm3 Anilm3 commented Aug 3, 2023

Add support for float and null types, while also allowing invalid within containers.

Breaking changes:

  • ddwaf_object now has one more field in the union for doubles called f64
  • ddwaf_object_*_force are now the standard, so the _force suffix has been removed.
  • ddwaf_object_signed and ddwaf_object_unsigned have now been renamed to ddwaf_object_string_from_*
  • Not breaking but two new types have been introduced, DDWAF_OBJ_FLOAT and DDWAF_OBJ_NULL

src/utils.hpp Outdated Show resolved Hide resolved
src/matcher/equals.hpp Outdated Show resolved Hide resolved
This was referenced Aug 4, 2023
@Anilm3 Anilm3 requested a review from estringana August 4, 2023 15:09
@@ -95,7 +106,7 @@ ddwaf_object *ddwaf_object_stringl_nc(ddwaf_object *object, const char *string,
return object;
}

ddwaf_object *ddwaf_object_signed(ddwaf_object *object, int64_t value)
ddwaf_object *ddwaf_object_string_from_signed(ddwaf_object *object, int64_t value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

NP: I like this new naming from but it feels a bit inconsistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How so?

double ddwaf_object_get_float(const ddwaf_object *object)
{
if (object == nullptr || object->type != DDWAF_OBJ_FLOAT) {
return 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do user of this function know if the 0 comes from the object or from this conditional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They can't know, although they can always check if their object is null or of an incorrect type, but it's mostly a precaution for incorrect use of the API.

src/utils.hpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@estringana estringana left a comment

Choose a reason for hiding this comment

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

Just a few nitpicks

@Anilm3 Anilm3 requested a review from cataphract August 4, 2023 15:58
src/utils.hpp Outdated Show resolved Hide resolved
src/utils.hpp Outdated Show resolved Hide resolved
src/utils.hpp Outdated Show resolved Hide resolved
src/utils.hpp Outdated Show resolved Hide resolved
src/utils.hpp Outdated Show resolved Hide resolved
src/utils.hpp Show resolved Hide resolved
src/utils.hpp Outdated Show resolved Hide resolved
@Anilm3 Anilm3 merged commit 74b3ced into master Aug 7, 2023
18 checks passed
@Anilm3 Anilm3 deleted the anilm3/float-and-null-types branch August 7, 2023 15:18
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.

3 participants