Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <math.h>
#include <napi.h>
#include <napi-inl.h>
#include <js_native_api.h>
#include <ddwaf.h>

#include <limits>
Expand Down Expand Up @@ -84,7 +85,22 @@ ddwaf_object* to_ddwaf_object_object(
}
}

Napi::Array properties = obj.GetPropertyNames();

napi_value result;
napi_status status = napi_get_all_property_names(env,
obj,
napi_key_own_only,
napi_key_skip_symbols,
napi_key_keep_numbers,
&result);

if ((status) != napi_ok) {
mlog("Error getting object properties");
return nullptr;
}

Napi::Array properties = Napi::Array(env, result);

uint32_t len = properties.Length();
if (lim && len > DDWAF_MAX_CONTAINER_SIZE) {
len = DDWAF_MAX_CONTAINER_SIZE;
Expand All @@ -103,11 +119,7 @@ ddwaf_object* to_ddwaf_object_object(
for (uint32_t i = 0; i < len; ++i) {
mlog("Getting properties");
Napi::Value keyV = properties.Get(i);
if (!obj.HasOwnProperty(keyV) || !keyV.IsString()) {
// We avoid inherited properties here.
// If the key is not a String, well this is weird
continue;
}

std::string key = keyV.ToString().Utf8Value();
Napi::Value valV = obj.Get(keyV);
mlog("Looping into ToPWArgs");
Expand Down