Skip to content

fix: rework argvalue, allowing named arguments lookup#111

Open
CrackTC wants to merge 1 commit intoantgroup:mainfrom
CrackTC:fix/argvalues-rework
Open

fix: rework argvalue, allowing named arguments lookup#111
CrackTC wants to merge 1 commit intoantgroup:mainfrom
CrackTC:fix/argvalues-rework

Conversation

@CrackTC
Copy link
Copy Markdown
Collaborator

@CrackTC CrackTC commented Mar 31, 2026

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the representation of function arguments from arrays to records (Record<number | string, any>) across the analysis engine, including core analyzers for Java, JavaScript, Python, and Go. This change enables more robust handling of named arguments and variadic parameters. The review feedback identifies several critical issues resulting from this transition: a potential TypeError when iterating over records with for...of, premature loop termination when encountering falsy argument values, and overly restrictive type checks that might skip valid data. Addressing these points is essential to ensure the analyzer correctly processes all argument types without runtime errors.

rest_argvalues.forEach((element: any, index: any) => {
rest_val[index.toString()] = element
})
for (let j = 0; argvalues[i + j]; j++) {
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.

high

The loop condition argvalues[i + j] will terminate the loop prematurely if an argument value is falsy (e.g., null or undefined). In JavaScript, variadic parameters should collect all remaining arguments even if they are null or undefined. It is safer to check for the existence of the index in the record.

Suggested change
for (let j = 0; argvalues[i + j]; j++) {
for (let j = 0; (i + j) in argvalues; j++) {

Comment on lines 2637 to +2640
val = argvalues[index]
if (!val) {
continue
}
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.

high

The check if (!val) will skip arguments that are null or undefined. While undefined might indicate a missing argument, null is a valid value that should be passed to the function. Additionally, if val is a PrimitiveValue object representing 0 or false, it will be truthy, but if the system ever passes raw primitives here, they would be incorrectly skipped. It is safer to check if the key exists in the record.

Suggested change
val = argvalues[index]
if (!val) {
continue
}
val = argvalues[index]
if (val === undefined && !(index in argvalues)) {
continue
}


for (let i = 0; i < argvalues.length; i++) {
const arg = argvalues[i]
for (const arg of argvalues) {
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.

high

argvalues is now typed as a Record, which can be a plain object. Using for...of on a plain object will throw a TypeError because objects are not iterable. To support both arrays and objects safely, use Object.values(argvalues) for iteration.

Suggested change
for (const arg of argvalues) {
for (const arg of Object.values(argvalues)) {

if (config.entryPointMode === 'ONLY_CUSTOM') return // 不路由自采集
if (!(fclos._qid in registerServerPoints)) return // 处理Register_xxx_Server函数,即实现类注册点
if (!Array.isArray(argvalues) || argvalues.length < 1) return
if (!Array.isArray(argvalues) || Object.keys(argvalues).length < 1) return
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.

medium

The Array.isArray(argvalues) check is too restrictive now that argvalues is a Record. If argvalues is passed as a plain object (as seen in the Python analyzer changes), this check will cause an early return and skip processing. You should check if it is truthy and has keys instead.

Suggested change
if (!Array.isArray(argvalues) || Object.keys(argvalues).length < 1) return
if (!argvalues || Object.keys(argvalues).length < 1) return

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.

1 participant