Skip to content

Add new initialize and finalize callbacks for probes #353

Open
@fraxken

Description

@fraxken

Problem

Currently, there is no way to execute probe-related code during the initialization or teardown phases of the SourceFile class lifecycle.

Proposal

My idea is to introduce two new optional callbacks for probes, to be implemented within the ProbeRunner:

Both methods would receive the current SourceFile instance as a parameter. Since ProbeRunner already stores this reference internally, this integration would be straightforward.

Note

SourceFile has no finalize/teardown lifecycle, we need to implement one and use in AstAnalyser (probably)

Example

Here’s a snippet of code that would be moved into the initialize callback of the isWeakCrypto probe:

this.tracer = new VariableTracer()
  .enableDefaultTracing()
  // ↓↓↓ this part
  .trace("crypto.createHash", {
    followConsecutiveAssignment: true, moduleName: "crypto"
  });

We don't need to trace crypto.createHash if the isWeakCrypto probe is not used.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions