Skip to content

Node.js live sensor (--require hook) #56

Open

Description

@vsn411

Same contract as #55, for Node apps:

node --require @secfoo/sensor app.js   # reads SECFOO_WATCHLIST / SECFOO_EVENTS_OUT

Approach:

  • Hook Module._load (CommonJS) and use the module.register loader hooks (ESM, Node ≥ 20.6) to wrap watched exports of watched packages once, when they first load.
  • The wrapper increments a counter and captures new Error().stack on the first call only, trimmed to app frames.
  • Coverage: optionally enable V8 precise coverage through inspector (Profiler.startPreciseCoverage, with callCount: false and detailed: false to keep it cheap) to fill the session's app function totals.
  • Flush on an interval, and on beforeExit/SIGTERM.

The package lives under packaging/ or npm/, next to the existing npm wrapper. Check npm/ for the publishing layout before adding a new package.

Must not: change this, arguments, return values or thrown errors of wrapped functions; or break instanceof and property access on wrapped classes. Test this directly.

Done when: tests cover CJS and ESM sample apps and a wrapped class, and the PR includes an overhead benchmark.

Added for the live sensor (#51 phase 2):

Activity

  1. added
    enhancementNew feature or request
    help wantedExtra attention is needed
    hackathonOpen for the Secfoo hackathon
    difficulty: hardLeaderboard: 10 points when the PR closing this is merged
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: hardLeaderboard: 10 points when the PR closing this is mergedenhancementNew feature or requesthackathonOpen for the Secfoo hackathonhelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions