Skip to content

Commit

Permalink
Remove unused IP blocking code, part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalchevrel committed Apr 8, 2024
1 parent 92c51c4 commit a97f160
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 42 deletions.
10 changes: 10 additions & 0 deletions app/inc/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use ReleaseInsights\Data;
use function Sentry\init;

// We always work with UTF8 encoding
mb_internal_encoding('UTF-8');
Expand Down Expand Up @@ -68,5 +69,14 @@
// Define a Nonce for inline scripts
define('NONCE', bin2hex(random_bytes(10)));

// Set up Sentry endpoint, don't send errors while in dev mode
if (STAGING) {
init(['dsn' => 'https://e17dcdc892db4ee08a6937603e407f76@o1069899.ingest.sentry.io/4505243444772864']);
}

if (PRODUCTION) {
init(['dsn' => 'https://20bef71984594e16add1d2c69146ad88@o1069899.ingest.sentry.io/4505243430092800']);
}

// Clean up temp variables from global space
unset($firefox_versions, $http_host);
12 changes: 1 addition & 11 deletions app/inc/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
declare(strict_types=1);

use ReleaseInsights\Request;

use function Sentry\{captureLastError, init};
use function Sentry\captureLastError;

// Catch errors via Ignition library in dev mode only
if (getenv('TESTING_CONTEXT') === false && LOCALHOST) {
Expand All @@ -15,15 +14,6 @@
}
}

// Set up Sentry endpoint, don't send errors while in dev mode
if (STAGING) {
init(['dsn' => 'https://e17dcdc892db4ee08a6937603e407f76@o1069899.ingest.sentry.io/4505243444772864']);
}

if (PRODUCTION) {
init(['dsn' => 'https://20bef71984594e16add1d2c69146ad88@o1069899.ingest.sentry.io/4505243430092800']);
}

// Send HTTP security headers
header('X-Content-Type-Options: nosniff');

Expand Down
31 changes: 0 additions & 31 deletions tests/Unit/ReleaseInsights/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,37 +164,6 @@
->not->toBeEmpty();
});

test('Utils::getIP', function () {
expect(U::getIP())->toBeNull();

$_SERVER['HTTP_CLIENT_IP'] = '1.1.1.1';
expect(U::getIP())->toBeString()->toEqual('1.1.1.1');
unset($_SERVER['HTTP_CLIENT_IP']);

$_SERVER['HTTP_X_FORWARDED_FOR'] = '2.1.1.1';
expect(U::getIP())->toBeString()->toEqual('2.1.1.1');
unset($_SERVER['HTTP_X_FORWARDED_FOR']);

$_SERVER['HTTP_X_FORWARDED'] = '3.1.1.1';
expect(U::getIP())->toBeString()->toEqual('3.1.1.1');
unset($_SERVER['HTTP_X_FORWARDED']);

$_SERVER['HTTP_FORWARDED_FOR'] = '4.1.1.1';
expect(U::getIP())->toBeString()->toEqual('4.1.1.1');
unset($_SERVER['HTTP_FORWARDED_FOR']);

$_SERVER['HTTP_FORWARDED'] = '5.1.1.1';
expect(U::getIP())->toBeString()->toEqual('5.1.1.1');
unset($_SERVER['HTTP_FORWARDED']);

$_SERVER['REMOTE_ADDR'] = '6.1.1.1';
expect(U::getIP())->toBeString()->toEqual('6.1.1.1');
unset($_SERVER['REMOTE_ADDR']);

expect(U::getIP())->toBeNull();
});


test('Utils::isJson', function () {
$this->assertFalse(U::isJson('1'));
$this->assertFalse(U::isJson('[1:]'));
Expand Down

0 comments on commit a97f160

Please sign in to comment.