Skip to content

pentest: _RE_EXPORT_CONST matches an export const inside a block comment #44

Description

@Shahid-BugB

pentest/electron_surface.py:33-35 scans raw source with re.M and has no notion of comments, so a declaration on its own line inside a /* … */ block matches:

/*
export const GET_CONFIG = 'old-channel-name';
*/
export const GET_CONFIG = 'get-configuration';

Two distinct values for GET_CONFIG are collected, _constant_map correctly refuses to guess between them, and the name is dropped from the map entirely. Every ipcMain.handle(GET_CONFIG, …) then resolves to nothing and the channel disappears from the surface — a real, live channel erased by a commented-out line.

Note the direction: the phantom entry does not produce a wrong channel, it produces a manufactured collision that removes a right one. A stale commented-out constant next to its replacement is exactly the shape a rename leaves behind, so this is reachable by ordinary maintenance rather than by anything unusual.

Same class as the comment-awareness gap already noted for webPreferences in #29.

Suggested fix: strip /* … */ and // runs before the constant pre-pass, or require the match to be outside a comment region computed once per file. Deliberately deferred out of the constant-channels branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions