Skip to content

Conversation

@grypez
Copy link
Contributor

@grypez grypez commented Aug 21, 2024

Closes #9

Refs: #21

Copies untransformed the dependencies of src/endoify.mjs into the header of dist/endoify.mjs. Replaces the import statements of the source file with the comments

// @inline './ses.mjs';
// @inline './eventual-send.mjs';

to suggest that the bundler will inline them directly. These comments are not functional but as we learn more about vitest plugins I suspect they may be the maintainable method to effect this behavior.

The tests for this implementation are run by ava, not vitest, in accordance with the reasoning I outlined in #21 (comment)

Adds the ava dev dependency.

@grypez grypez requested a review from a team as a code owner August 21, 2024 06:02
@grypez grypez requested a review from SMotaal August 21, 2024 06:02
@socket-security
Copy link

socket-security bot commented Aug 21, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Deprecated npm/rimraf@3.0.2
  • Reason: Rimraf versions prior to v4 are no longer supported
⚠︎
Network access npm/node-fetch@2.7.0 🚫
Network access npm/node-fetch@2.7.0 🚫
Network access npm/node-fetch@2.7.0 🚫
AI warning npm/yargs@17.7.2
  • Notes: The code dynamically determines the flow of commands based on user input and specific conditions, potentially leading to command injection vulnerabilities if not handled properly. No explicit malicious behavior detected, but there is a security risk present.
  • Confidence: 1.00
  • Severity: 0.60
⚠︎
Deprecated npm/are-we-there-yet@2.0.0
  • Reason: This package is no longer supported.
⚠︎
Deprecated npm/gauge@3.0.2
  • Reason: This package is no longer supported.
⚠︎
Deprecated npm/npmlog@5.0.1
  • Reason: This package is no longer supported.
⚠︎
New author npm/async-sema@3.1.1 🚫
New author npm/memoize@10.0.0 🚫
New author npm/package-config@5.0.0 🚫
Shell access npm/detect-libc@2.0.3 🚫

View full report↗︎

Next steps

What is a deprecated package?

The maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.

Research the state of the package and determine if there are non-deprecated versions that can be used, or if it should be replaced with a new, supported solution.

What is network access?

This module accesses the network.

Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

What is an AI-detected potential code anomaly?

AI has identified unusual behaviors that may pose a security risk.

An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

What is new author?

A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.

Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights.

What is shell access?

This module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.

Packages should avoid accessing the shell which can reduce portability, and make it easier for malicious shell access to be introduced.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/rimraf@3.0.2
  • @SocketSecurity ignore npm/node-fetch@2.7.0
  • @SocketSecurity ignore npm/yargs@17.7.2
  • @SocketSecurity ignore npm/are-we-there-yet@2.0.0
  • @SocketSecurity ignore npm/gauge@3.0.2
  • @SocketSecurity ignore npm/npmlog@5.0.1
  • @SocketSecurity ignore npm/async-sema@3.1.1
  • @SocketSecurity ignore npm/memoize@10.0.0
  • @SocketSecurity ignore npm/package-config@5.0.0
  • @SocketSecurity ignore npm/detect-libc@2.0.3

It was supposed that, because a critical behavior of the shims is
their behavior under bundling, the test command in the shims
package should include building prior. However, it is worth noting
that the build is assumed to run in node 20 and fails in node 18
due to the nonexistence of import.meta.dirname at that version.

However, the hard requirement is only that the build be performed
prior to testing. The CI does this already, building with node 20
and then testing under both 18 and 20. Thus the build prephase can
be safely removed from the test command without endangering the
consistency of the `main` branch; caveat that developers may need
to rebuild before testing while developing in the shims package.
@grypez grypez force-pushed the grypez/bundle-endoify branch from bce5810 to e08bdaa Compare August 21, 2024 06:34
@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/ava@6.1.3 Transitive: environment, eval, filesystem, network, shell, unsafe +110 3.63 MB novemberborn

View full report↗︎

Copy link
Contributor

@SMotaal SMotaal left a comment

Choose a reason for hiding this comment

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

The changes look good with all the tests now running. So pending a review for the SocketSecurity notices, it is otherwise GTG!

@grypez
Copy link
Contributor Author

grypez commented Aug 21, 2024

Noting for posterity:

The CI build job requires that yarn build succeeds with node 20. The CI test job (essentially) requires that yarn test succeeds with node 18 and 20. The test job does not have access to the build artifacts from the build job, which allows the build and test jobs to run in parallel.

In order to allow the shims package to test its built shims, we prefix the shims test command with build && ava && , which, as a command called during the CI test job, runs with both node 18 and 20. Therefore, although our CI suggests the intended workflow for the ocap monorepo is "build with 20, run with 18 or 20", the tests tighten the constraint in the shims package specifically to "build and run with 18 or 20".

As @SMotaal noted, we can meet this constraint by replacing the node 20 implementation of path.resolve(import.meta.dirname, '..') with the more agnostic fileURLToPath(new URL('..', import.meta.url)).

@grypez grypez closed this Aug 22, 2024
@grypez grypez deleted the grypez/bundle-endoify branch October 4, 2024 16:59
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.

shims: Bundle external dependencies into endoify.mjs

3 participants