toContain('cacti_escapeshellarg($rrdfile[\'data_source_path\'])'); expect($batchgapfixSource)->not->toContain('--rrdfile=\'%s\''); }); test('batchgapfix escapes the window and method arguments', function () use ($batchgapfixSource) { expect($batchgapfixSource)->toContain('cacti_escapeshellarg($start_date)'); expect($batchgapfixSource)->toContain('cacti_escapeshellarg($end_date)'); expect($batchgapfixSource)->toContain('cacti_escapeshellarg($method)'); expect($batchgapfixSource)->toContain('cacti_escapeshellarg($avgnan)'); }); test('batchgapfix spawns its children with an argument array', function () use ($batchgapfixSource) { expect($batchgapfixSource)->toContain('exec_background($php_bin, $args)'); expect($batchgapfixSource)->not->toContain('exec_background($php_bin, $command)'); }); // --- float_rrdfiles --- test('float_rrdfiles escapes the RRDfile path on dump', function () use ($floatRrdfilesSource) { expect($floatRrdfilesSource)->toContain("(string) read_config_option('path_rrdtool')"); expect($floatRrdfilesSource)->toContain('cacti_escapeshellcmd($rrdtool_bin) . \' dump \' . cacti_escapeshellarg($rrd_path)'); expect($floatRrdfilesSource)->not->toContain('"$rrdtool_bin dump $rrd_path"'); }); test('batchgapfix normalizes an unset PHP binary path', function () use ($batchgapfixSource) { expect($batchgapfixSource)->toContain("(string) read_config_option('path_php_binary')"); }); test('float_rrdfiles escapes both paths on restore', function () use ($floatRrdfilesSource) { expect($floatRrdfilesSource)->toContain('cacti_escapeshellarg($tmp_file)'); expect($floatRrdfilesSource)->not->toContain('"$rrdtool_bin restore -f $tmp_file $rrd_path"'); }); // --- update_heartbeat --- test('update_heartbeat escapes the RRDfile path', function () use ($updateHeartbeatSource) { expect($updateHeartbeatSource)->toContain('cacti_escapeshellarg($f[\'rrd\'])'); expect($updateHeartbeatSource)->not->toContain('sprintf(\'rrdtool tune %s \''); }); test('update_heartbeat escapes each data source name', function () use ($updateHeartbeatSource) { expect($updateHeartbeatSource)->toContain('cacti_escapeshellarg($ds . \':\' . $new_heartbeat)'); expect($updateHeartbeatSource)->not->toContain('--heartbeat $ds:$new_heartbeat'); }); test('update_heartbeat takes RRDtool from the configured path', function () use ($updateHeartbeatSource) { expect($updateHeartbeatSource)->toContain('$rrdtool_bin = read_config_option(\'path_rrdtool\')'); expect($updateHeartbeatSource)->toContain('cacti_escapeshellcmd($rrdtool_bin)'); });