Skip to content

Commit c34d7cd

Browse files
committed
Last few fixes for masking ips to work correctly
1 parent b3da61f commit c34d7cd

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/apm/presenter/PresenterFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static function create(string $runwayConfigPath): PresenterInterface
2222
$storageType = $runwayConfig['apm']['storage_type'];
2323
switch($storageType) {
2424
case 'sqlite':
25-
return new SqlitePresenter($runwayConfig['apm']['dest_db_dsn']);
25+
return new SqlitePresenter($runwayConfig);
2626
default:
2727
throw new InvalidArgumentException("Unsupported storage type: $storageType");
2828
}

src/apm/presenter/SqlitePresenter.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ class SqlitePresenter implements PresenterInterface
1212
*/
1313
protected PDO $db;
1414

15+
/**
16+
* Runway Config
17+
*/
18+
protected array $config;
19+
1520
/**
1621
* Constructor
1722
*
18-
* @param string $dsn PDO connection dsn
23+
* @param array $config Runway Config
1924
*/
20-
public function __construct(string $dsn)
25+
public function __construct(array $config)
2126
{
22-
$this->db = new PDO($dsn, null, null, [
27+
$this->config = $config;
28+
$this->db = new PDO($config['apm']['dest_db_dsn'], null, null, [
2329
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
2430
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
2531
PDO::ATTR_EMULATE_PREPARES => false
@@ -483,14 +489,16 @@ public function getRequestsData(string $threshold, int $page, int $perPage, stri
483489
$stmt = $this->db->prepare($requestQuery);
484490
$stmt->execute($paginatedRequestIds);
485491
$requests = $stmt->fetchAll(PDO::FETCH_ASSOC);
492+
493+
$shouldMaskIp = $this->shouldMaskIpAddresses();
486494

487495
// Fetch details for each request
488496
foreach ($requests as &$request) {
489497
$details = $this->getRequestDetails($request['request_id']);
490498
$request = array_merge($request, $details);
491499

492500
// Mask IP address if the option is enabled
493-
if ($this->shouldMaskIpAddresses()) {
501+
if ($shouldMaskIp === true) {
494502
$request['ip'] = $this->maskIpAddress($request['ip']);
495503
}
496504
}

0 commit comments

Comments
 (0)