Fix handling of Maps and other non plain object types#970
Fix handling of Maps and other non plain object types#970timokoessler wants to merge 5 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| } catch { | ||
| // Ignore errors |
There was a problem hiding this comment.
Silent catch in extractStringsFromUserInput swallows errors from the Reflect.ownKeys/Object.getOwnPropertyDescriptor loop; add logging or handle specific error cases instead of ignoring.
Show fix
| } catch { | |
| // Ignore errors | |
| } catch (error) { | |
| // Ignore errors from exotic objects/proxies that throw during reflection | |
| console.warn("Failed to extract strings from object via reflection:", error); |
Details
✨ AI Reasoning
A new try/catch was added around reflective property iteration in extractStringsFromUserInput. The catch clause is a bare, silent catch that only contains a comment saying errors are ignored. Silent catches can mask unexpected failures and make debugging harder. The try block uses Reflect.ownKeys/Object.getOwnPropertyDescriptor to inspect arbitrary objects, which can throw for some proxies or exotic objects; swallowing those silently hides the cause.
This finding points to the empty/silent catch introduced for the reflective iteration. Consider adding targeted error handling, logging, or restricting which objects are inspected to avoid silent failures.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
| ); | ||
| } | ||
|
|
||
| function getOwnStringDataProperties( |
There was a problem hiding this comment.
getOwnStringDataProperties performs Reflect.ownKeys + getOwnPropertyDescriptor per property and is used in recursive loops; cache or compute once per object to avoid repeated descriptor lookups.
Details
✨ AI Reasoning
A helper was added that enumerates property keys using Reflect.ownKeys and calls Object.getOwnPropertyDescriptor for each key. That helper is then used in hot code paths (loops and reduce operations) where previously simple for-in iterations were used. The work per property (descriptor retrieval and filtering) is constant but is now performed repeatedly across recursive searches and array reductions, causing the total cost to scale worse with input size. Caching the list of string-valued own properties once per object or avoiding descriptor lookups when not necessary would avoid repeated work.
🔧 How do I fix it?
Move constant work outside loops. Use StringBuilder instead of string concatenation in loops. Cache compiled regex patterns. Use hash-based lookups instead of nested loops. Batch database operations instead of N+1 queries.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Summary by Aikido
⚡ Enhancements
🔧 Refactors
More info