datadog-static-analyzer icon indicating copy to clipboard operation
datadog-static-analyzer copied to clipboard

[STAL-1886] JavaScript -> Rust Proof of Concept

Open jasonforal opened this issue 1 year ago • 1 comments

NOTE: Despite CI failures: this is a fully working proof of concept, but kept as a draft

To run:

  1. Create an empty directory to test this repo.
  2. In this repo, create a TypeScript file with a variable assignment to the string "hello". For example: echo 'let foo = "hello"\nlet bar = "world"' > index.ts
  3. Run the analyzer, pointing it to this directory: cargo run --bin datadog-static-analyzer -- --format sarif --output result.sarif --directory ~/sandbox
  4. You'll see the result of the Rust function call printed in stdout: Screenshot 2024-04-19 at 17 34 23

What problem are you trying to solve?

Demonstrate that we can call into Rust from JavaScript to perform expensive tree-based operations.

What is your solution?

Quick and messy prototype that shows ability to pass tree_sitter::Tree into a Rust function that can be called from from the JavaScript runtime.

This function counts the number of named nodes in the file's tree.

Alternatives considered

What the reviewer should know

  • Just a sketch, no consideration given to code organization.
  • CI only fails because I circumvented standard operation to make the POC run without config

jasonforal avatar Apr 19 '24 21:04 jasonforal

Datadog Software Composition Analysis

No vulnerabilities found.

Closing, as ddsa supplants this

jasonforal avatar Jun 20 '24 13:06 jasonforal