Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anilm3 committed May 16, 2024
1 parent e4a9dc6 commit 0e6a1f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions include/ddwaf_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ typedef struct _ddwaf_object ddwaf_object;
typedef struct _ddwaf_object_kv ddwaf_object_kv;
typedef struct _ddwaf_allocator ddwaf_allocator;
typedef enum _ddwaf_object_type ddwaf_object_type;
typedef void *(ddwaf_alloc_fn_type)(void *, size_t size, size_t alignment);
typedef void (ddwaf_free_fn_type)(void *, void *, size_t size, size_t alignment);
#endif

struct __attribute__((packed)) _ddwaf_object {
Expand Down
19 changes: 15 additions & 4 deletions src/condition/scalar_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ std::optional<condition_match> eval_object(Iterator &it, std::string_view addres
{std::move(highlight)}, matcher.name(), matcher.to_string(), ephemeral}};
}
}

auto [res, highlight] = matcher.match(src_sv);
if (!res) {
return {};
}

DDWAF_TRACE("Target {} matched parameter value {}", address, highlight);

return {{{{"input"sv, std::string{src_sv}, address, it.get_current_path()}},
{std::move(highlight)}, matcher.name(), matcher.to_string(), ephemeral}};
}

auto [res, highlight] = matcher.match(src);
Expand All @@ -72,10 +82,11 @@ std::optional<condition_match> eval_target(Iterator &it, std::string_view addres
throw ddwaf::timeout_exception();
}

// TODO FIX Type
/* if (it.type() != matcher.supported_type()) {*/
/*continue;*/
/*}*/
// TODO Find a more ergonomic way to do this
if ((matcher.supported_type() == object_type::string &&
(it.type() & object_type::string) == 0)) {
continue;
}

auto match = eval_object(it, address, ephemeral, matcher, transformers, limits);
if (match.has_value()) {
Expand Down
3 changes: 0 additions & 3 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ DDWAF_RET_CODE context::run(optional_ref<ddwaf_object> persistent,
}
}

// If the timeout provided is 0, we need to ensure the parameters are owned
// by the additive to ensure that the semantics of DDWAF_ERR_TIMEOUT are
// consistent across all possible timeout scenarios.
if (timeout == 0) {
if (res.has_value()) {
ddwaf_result &output = *res;
Expand Down

0 comments on commit 0e6a1f0

Please sign in to comment.