Skip to content

Commit c286336

Browse files
committed
refactor: fix sicurezza
1 parent c640b85 commit c286336

10 files changed

Lines changed: 13 additions & 12 deletions

File tree

modules/aggiornamenti/actions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
break;
6565
}
6666

67+
// TODO: Blindare maggiormente le query che il gestionale ha generato per la correzione dei conflitti a database
6768
// WHITELIST: Permetti solo pattern SQL sicuri
6869
$allowed_patterns = [
6970
'/^ALTER\s+TABLE\s+`?[\w]+`?\s+(ADD|MODIFY|CHANGE|DROP)\s+(COLUMN\s+)?`?[\w]+`?/i',

modules/contratti/ajax/select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353

5454
if (empty($elements)) {
5555
$where[] = '`an_anagrafiche`.`idanagrafica`='.prepare($superselect['idanagrafica']);
56-
$allowed_stati = ['is_pianificabile', 'is_completato', 'is_fatturabile'];
57-
$stato = !empty($superselect['stato']) && in_array($superselect['stato'], $allowed_stati)
56+
$stati_consentiti = ['is_pianificabile', 'is_completato', 'is_fatturabile'];
57+
$stato = !empty($superselect['stato']) && in_array($superselect['stato'], $stati_consentiti)
5858
? $superselect['stato']
5959
: 'is_pianificabile';
6060
$where[] = '`idstato` IN (SELECT `id` FROM `co_staticontratti` WHERE `'.str_replace('`', '', $stato).'` = 1)';

modules/contratti/modals/confronta_righe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
$contratto = Contratto::find($id_record);
2626

2727
$id_anagrafica = $contratto->idanagrafica;
28-
$righe_ids = array_map('intval', explode(',', $_GET['righe'] ?? ''));
28+
$righe_ids = array_map('intval', explode(',', get('righe', true) ?? ''));
2929
$placeholders = implode(',', array_fill(0, count($righe_ids), '?'));
3030
$righe = $dbo->fetchArray(
3131
'SELECT

modules/ddt/modals/confronta_righe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
$id_anagrafica = $ddt->idanagrafica;
2828
$direzione = $ddt->direzione;
29-
$righe_ids = array_map('intval', explode(',', $_GET['righe'] ?? ''));
29+
$righe_ids = array_map('intval', explode(',', get('righe', true) ?? ''));
3030
$placeholders = implode(',', array_fill(0, count($righe_ids), '?'));
3131
$righe = $dbo->fetchArray(
3232
'SELECT

modules/fatture/modals/confronta_righe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
$id_anagrafica = $documento->idanagrafica;
2828
$direzione = $documento->direzione;
29-
$righe_ids = array_map('intval', explode(',', filter('righe') ?? ''));
29+
$righe_ids = array_map('intval', explode(',', get('righe', true) ?? ''));
3030
$placeholders = implode(',', array_fill(0, count($righe_ids), '?'));
3131
$righe = $dbo->fetchArray(
3232
'SELECT

modules/interventi/modals/confronta_righe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
$id_anagrafica = $intervento->idanagrafica;
2828
$direzione = $intervento->direzione;
29-
$righe_ids = array_map('intval', explode(',', filter('righe') ?? ''));
29+
$righe_ids = array_map('intval', explode(',', get('righe', true) ?? ''));
3030
$placeholders = implode(',', array_fill(0, count($righe_ids), '?'));
3131
$righe = $dbo->fetchArray(
3232
'SELECT

modules/ordini/ajax/select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
if (empty($elements)) {
4949
$where[] = '`an_anagrafiche`.`idanagrafica`='.prepare($superselect['idanagrafica']);
5050

51-
$allowed_stati = ['is_fatturabile', 'is_evadibile', 'is_completato'];
52-
$stato = !empty($superselect['stato']) && in_array($superselect['stato'], $allowed_stati)
51+
$stati_consentiti = ['is_fatturabile', 'is_evadibile', 'is_completato'];
52+
$stato = !empty($superselect['stato']) && in_array($superselect['stato'], $stati_consentiti)
5353
? $superselect['stato']
5454
: 'is_fatturabile';
5555
$where[] = '`or_statiordine`.'.$stato.' = 1';

modules/ordini/modals/confronta_righe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
$id_anagrafica = $ordine->idanagrafica;
2828
$direzione = $ordine->direzione;
29-
$righe_ids = array_map('intval', explode(',', $_GET['righe'] ?? ''));
29+
$righe_ids = array_map('intval', explode(',', get('righe', true) ?? ''));
3030
$placeholders = implode(',', array_fill(0, count($righe_ids), '?'));
3131
$righe = $dbo->fetchArray(
3232
'SELECT

modules/preventivi/ajax/select.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
$where[] = '`an_anagrafiche`.`idanagrafica`='.prepare($superselect['idanagrafica']);
5757
$where[] = '`co_preventivi`.`default_revision`=1';
5858

59-
$allowed_stati = ['is_pianificabile', 'is_completato', 'is_fatturabile', 'is_concluso'];
60-
$stato = !empty($superselect['stato']) && in_array($superselect['stato'], $allowed_stati)
59+
$stati_consentiti = ['is_pianificabile', 'is_completato', 'is_fatturabile', 'is_concluso'];
60+
$stato = !empty($superselect['stato']) && in_array($superselect['stato'], $stati_consentiti)
6161
? $superselect['stato']
6262
: 'is_pianificabile';
6363
$where[] = '(`'.str_replace('`', '', $stato).'` = 1)';

modules/preventivi/modals/confronta_righe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
$preventivo = Preventivo::find($id_record);
2626

2727
$id_anagrafica = $preventivo->idanagrafica;
28-
$righe_ids = array_map('intval', explode(',', $_GET['righe'] ?? ''));
28+
$righe_ids = array_map('intval', explode(',', get('righe', true) ?? ''));
2929
$placeholders = implode(',', array_fill(0, count($righe_ids), '?'));
3030
$righe = $dbo->fetchArray(
3131
'SELECT

0 commit comments

Comments
 (0)