Skip to content

Commit

Permalink
SECURITY: Make 'unittest' mode only work during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reedy committed Aug 20, 2024
1 parent 760f514 commit a1f83e1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion help/resetpw.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
Cheers,
OpenFlights.org";

if (isset($_POST["unittest"])) {
if (defined(UNIT_TEST_MODE) && UNIT_TEST_MODE && isset($_POST["unittest"])) {
echo $link . "***" . $row['challenge'];
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion php/apsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
TXT;


if (isset($_POST["unittest"])) {
if (defined(UNIT_TEST_MODE) && UNIT_TEST_MODE && isset($_POST["unittest"])) {
echo $title . "\n\n" . $body;
exit;
}
Expand Down
3 changes: 3 additions & 0 deletions php/config.php.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

const UNIT_TEST_MODE = false;

$host = "localhost";
$dbname = "flightdb2";
$user = "openflights";
Expand Down
2 changes: 2 additions & 0 deletions test/server/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// Path to OpenFlights upload directory
$uploadDir = '../../import/';

const UNIT_TEST_MODE = true;

// Database configuration
$dbhost = "localhost";
$dbuser = "openflights";
Expand Down

0 comments on commit a1f83e1

Please sign in to comment.