fix tainted paths and intel graphics
This commit is contained in:
parent
68b7d6f3ec
commit
8ecaf65405
@ -149,8 +149,8 @@ sub _load_graphics_data {
|
|||||||
# API calls
|
# API calls
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
sub get_graphic_info {
|
sub get_graphics_info {
|
||||||
debug(__LINE__, "get_graphic_info called");
|
debug(__LINE__, "get_graphics_info called");
|
||||||
if (!($config{gpu}{intel_enabled} || !$config{gpu}{nvidia_enabled} || !$config{gpu}{amd_enabled})) {
|
if (!($config{gpu}{intel_enabled} || !$config{gpu}{nvidia_enabled} || !$config{gpu}{amd_enabled})) {
|
||||||
debug(__LINE__, "GPU information collection is disabled");
|
debug(__LINE__, "GPU information collection is disabled");
|
||||||
return { };
|
return { };
|
||||||
|
|||||||
@ -215,6 +215,10 @@ sub safe_write_json {
|
|||||||
my ($filepath, $data, $pretty) = @_;
|
my ($filepath, $data, $pretty) = @_;
|
||||||
$pretty //= 1;
|
$pretty //= 1;
|
||||||
|
|
||||||
|
# Untaint filepath for taint-mode environments (pveproxy runs with -T)
|
||||||
|
($filepath) = ($filepath =~ /^([a-zA-Z0-9_\/\-\.]+)$/)
|
||||||
|
or do { debug(__LINE__, "Unsafe filepath rejected: $filepath"); return 0; };
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
open my $fh, '>', $filepath or die "Failed to open $filepath: $!";
|
open my $fh, '>', $filepath or die "Failed to open $filepath: $!";
|
||||||
my $json = $pretty ? JSON->new->pretty->encode($data) : encode_json($data);
|
my $json = $pretty ? JSON->new->pretty->encode($data) : encode_json($data);
|
||||||
@ -232,6 +236,10 @@ sub safe_write_json {
|
|||||||
sub safe_read_json {
|
sub safe_read_json {
|
||||||
my ($filepath, $as_string) = @_;
|
my ($filepath, $as_string) = @_;
|
||||||
|
|
||||||
|
# Untaint filepath
|
||||||
|
($filepath) = ($filepath =~ /^([a-zA-Z0-9_\/\-\.]+)$/)
|
||||||
|
or return;
|
||||||
|
|
||||||
return unless -f $filepath;
|
return unless -f $filepath;
|
||||||
|
|
||||||
my $result;
|
my $result;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
+ $res->{PveMod_JsonSensorInfo} = PVE::API2::PVEMod_SensorInfo::get_sensors_info();
|
+ $res->{PveMod_JsonSensorInfo} = PVE::API2::PVEMod_SensorInfo::get_sensors_info();
|
||||||
+ $res->{PveMod_Version} = PVE::API2::PVEMod_SensorInfo::get_pve_mod_version();
|
+ $res->{PveMod_Version} = PVE::API2::PVEMod_SensorInfo::get_pve_mod_version();
|
||||||
+ $res->{PveMod_upsInfo} = PVE::API2::PVEMod_SensorInfo::get_ups_info();
|
+ $res->{PveMod_upsInfo} = PVE::API2::PVEMod_SensorInfo::get_ups_info();
|
||||||
+ $res->{PveMod_graphicInfo} = PVE::API2::PVEMod_SensorInfo::get_graphic_info();
|
+ $res->{PveMod_graphicsInfo} = PVE::API2::PVEMod_SensorInfo::get_graphic_info();
|
||||||
+ $res->{PveMod_systemInfo} = PVE::API2::PVEMod_SensorInfo::get_system_information();
|
+ $res->{PveMod_systemInfo} = PVE::API2::PVEMod_SensorInfo::get_system_information();
|
||||||
my $dinfo = df('/', 1); # output is bytes
|
my $dinfo = df('/', 1); # output is bytes
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user