Skip to content

Remove hack around property write to module.exports not being captured #221

@jeongsoolee09

Description

@jeongsoolee09

The current CodeQL for JavaScript library class Module fails to capture irregular JavaScript code that mixes ES2015 modules and CommonJS ones. This means that the code like below fails to register as a Module:

import fs from "fs";

module.exports = (srv) => { srv.on(...) }

This makes capturing the portion (srv) => { srv.on(...) } above impossible using standard library code. The current hack is to describe the property write directly in a low-level fashion:

exists(PropWrite moduleExports |
  moduleExports.getBase().asExpr().(VarAccess).getName() = "module" and
  moduleExports.getPropertyName() = "exports" and
  this = moduleExports.getRhs()
)

But this is obviously not ideal. Therefore, after the CodeQL Standard Library for JavaScript is fixed, remove the above code and replace it with any(Module module_).getABulkExportedNode().

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