Skip to content

Conversation

@fraxken
Copy link
Member

@fraxken fraxken commented Jul 16, 2025

No description provided.

@fraxken fraxken requested review from clemgbld and Copilot July 16, 2025 15:49
@changeset-bot
Copy link

changeset-bot bot commented Jul 16, 2025

🦋 Changeset detected

Latest commit: 299e74b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nodesecure/js-x-ray Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the ProbeRunner to support per-probe context throughout its lifecycle and updates tests, probe implementations, and documentation accordingly.

  • Extend ProbeRunner to initialize, store, and pass a ProbeContext to all probe methods.
  • Refactor individual probes to accept and use the new ctx parameter instead of direct SourceFile references.
  • Update tests and example docs to assert and illustrate the new context propagation.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
workspaces/js-x-ray/test/ProbeRunner.spec.ts Update tests to expect context in arguments for all probe methods
workspaces/js-x-ray/src/probes/isWeakCrypto.ts Refactor to use ctx.sourceFile and ProbeContext
workspaces/js-x-ray/src/probes/isSyncIO.ts Refactor to accept ctx and extract tracer from ctx.sourceFile
workspaces/js-x-ray/src/probes/isSerializeEnv.ts Adapt to ProbeContext for validateNode, main, and initialize
workspaces/js-x-ray/src/probes/isRequire/isRequire.ts Use ctx.sourceFile in validate, main, and teardown
workspaces/js-x-ray/src/probes/isFetch.ts Switch to ctx: ProbeContext in validate, initialize, and main
workspaces/js-x-ray/src/ProbeRunner.ts Add context initialization, storage, and propagation logic
workspaces/js-x-ray/docs/AstAnalyser.md Update example to show ctx parameter in main signature
Comments suppressed due to low confidence (3)

workspaces/js-x-ray/src/ProbeRunner.ts:39

  • [nitpick] The initialize callback is typed to return a full ProbeContext but in practice it’s used to return only the context data (T). Consider updating the signature to return T instead of ProbeContext to simplify the API and avoid nested context objects.
  initialize?: (ctx: ProbeContext<T>) => void | ProbeContext;

workspaces/js-x-ray/src/ProbeRunner.ts:49

  • [nitpick] The Probe interface defines a context property as ProbeContext<T>, which leads to nested context shapes. Consider typing it as context?: T so it directly holds the context data returned by initialize.
  context?: ProbeContext<T>;

workspaces/js-x-ray/docs/AstAnalyser.md:146

  • The example validateNode signature no longer matches the updated API which now provides a ctx parameter. Consider updating the example to validateNode: (node, ctx) => [...] to reflect the new ProbeContext usage.
    validateNode: (node) => [

Update workspaces/js-x-ray/src/probes/isSyncIO.ts

Co-authored-by: Copilot <[email protected]>

chore: add changeset
@fraxken fraxken merged commit fad019f into master Jul 16, 2025
6 checks passed
@fraxken fraxken deleted the probe-context branch July 16, 2025 17:54
@github-actions github-actions bot mentioned this pull request Jul 14, 2025
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.

3 participants