Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Rust agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript
TS/JS: flag os.tmpdir, os.userInfo and the other os reads in analyze and bridge (#1424)
jakalijeydd220259cd89
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 85297c62..769fb83f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -287,6 +287,9 @@- PowerShell: a parameter typed `[decimal]`, `[uint64]` or `[ulong]` keeps its function inPowerShell, with the reasons C# gives for the same types, instead of bridging it as `f64` or`i64`. `[uint32]`, `[double]` and `[single]` bridge as before (#1341 by @jakalijey).+- TS/JS: `bridge` keeps a function that calls `os.tmpdir()` or `os.userInfo()`, and `analyze` flags+ `process.cwd()`, `os.homedir()`, `os.hostname()`, `os.tmpdir()` and `os.userInfo()` as state+ outside the arguments, as it did `process.env` (#1408 by @jakalijey).- Kotlin: a function that calls `Locale.getDefault`, `TimeZone.getDefault`, `ZoneId.systemDefault`or `Charset.defaultCharset` stays in Kotlin with the reason Java gives, and `analyze` flags thosecalls as state outside the arguments in Java and Kotlin (#1409 by @jakalijey).diff --git a/src/lang/effects.rs b/src/lang/effects.rsindex d06b0fae..a383dec7 100644--- a/src/lang/effects.rs+++ b/src/lang/effects.rs@@ -144,7 +144,14 @@ fn prints(lang: Lang) -> &'static [&'static str] {/// value (`ENV["HOME"]` was recorded as `/root`), and the port must read the same variable.fn environment(lang: Lang) -> &'static [&'static str] {match lang {- Lang::Ts => &["process.env", "process.cwd(", "os.homedir(", "os.hostname("],+ Lang::Ts => &[+ "process.env",+ "process.cwd(",+ "os.homedir(",+ "os.hostname(",+ "os.tmpdir(",+ "os.userInfo(",+ ],Lang::Python => &["os.environ","os.getenv(",@@ -1520,6 +1527,7 @@ mod tests {"def f(x):\n return os.environ.get('HOME', '') + x",),(Lang::Ts, "function f(x){ return process.env.HOME + x }"),+ (Lang::Ts, "function f(x){ return os.tmpdir() + x }"),(Lang::Go,"func F(x string) string { return os.Getenv(\"HOME\") + x }",diff --git a/src/ts/scan.rs b/src/ts/scan.rsindex 7263d4cd..756928b1 100644--- a/src/ts/scan.rs+++ b/src/ts/scan.rs@@ -606,6 +606,12 @@ impl<'a> Visit<'a> for Collector {(None, "bigint") if is_process_hrtime(&member.object) => {self.add(Risk::ClockAndRandom, it.span);}+ // What `bridge` keeps for reading the environment (`lang::effects`), so+ // `analyze` does not call the unit ready over the same calls.+ (Some("process"), "cwd")+ | (Some("os"), "homedir" | "hostname" | "tmpdir" | "userInfo") => {+ self.add(Risk::SharedState, it.span);+ }(Some("Math"), "round")| (Some("Number"), "parseInt" | "parseFloat")| (_, "toFixed") => {@@ -1001,6 +1007,9 @@ mod tests {Risk::NumberSemantics,),("export const a = () => process.env.HOME", Risk::SharedState),+ ("export const a = () => os.homedir()", Risk::SharedState),+ ("export const a = () => os.tmpdir()", Risk::SharedState),+ ("export const a = () => process.cwd()", Risk::SharedState),("export const a = () => process.hrtime()",Risk::ClockAndRandom,