ruby_converter

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ruby_converter lowers Ruby source into gIR so the shared taint engine can analyze it, mirroring the public shape of the other frontends (NewConverter / Converter.ConvertFile).

Like the Python frontend, it has no in-process Ruby parser, so it shells out to an embedded helper (rbdump.rb) that parses the file with the standard library's Ripper and prints its S-expression AST as JSON; lower.go turns that tree into gIR. Ripper ships with every MRI Ruby, so only `ruby` on PATH is required; ConvertFile returns a clear error if it is absent.

Scope (deliberately narrow, taint-focused): a real CFG via converters/ssabuild (if/elsif/while/until/case lower to blocks with PHI joins; a branch-free method stays one block). Covered expressions: literals, string interpolation, `+` concatenation, local variable reads/assignments, method/command calls (with and without a receiver), and index reads. The web request surface lowers to a synthetic source CALL so the engine seeds taint, via the same opaque-base heuristic the JS/Python frontends use — see isOpaqueBase. Unhandled nodes become an OP_CODE_INTRINSIC "ruby.unsupported" (expressions) or are dropped (statements) rather than aborting conversion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsERBFile

func IsERBFile(path string) bool

IsERBFile reports whether path is an ERB template. Rails names them `<name>.html.erb` / `<name>.js.erb`; the format segment is not significant here, only the .erb suffix.

func IsRubyFile

func IsRubyFile(path string) bool

IsRubyFile reports whether path is a Ruby source file this frontend lowers. Exported so internal/scan's language detection and this frontend's own file selection share ONE predicate instead of drifting copies. ERB templates count: a Rails view holds request input and output sinks, and erbToRuby turns one into plain Ruby before it reaches Ripper.

Types

type Converter

type Converter struct {
	frontend.Driver[rbFileResult]
}

Converter lowers Ruby source files/directories into gIR: the shared frontend.Driver surface (ConvertFile/ConvertInventory/Skipped) over Ruby's batch hooks (see batch). Requires `ruby` on PATH.

func NewConverter

func NewConverter() *Converter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL