Skip to content

Commit

Permalink
Merge branch 'phpbb-extensions:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Skouat authored Sep 21, 2024
2 parents 597a32a + dee419a commit bbef2b5
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 52 deletions.
84 changes: 52 additions & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@ on:
jobs:
# START Basic Checks Job (EPV, code sniffer, images check, etc.)
basic-checks:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- php: '7.1'
- php: '7.2'
db: "none"
NOTESTS: 1

name: PHP ${{ matrix.php }} - ${{ matrix.db }}

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand Down Expand Up @@ -89,28 +89,26 @@ jobs:

# START MySQL and MariaDB Job
mysql-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- php: '7.1'
- php: '7.2'
db: "mariadb:10.1"
- php: '7.1'
- php: '7.2'
db: "mariadb:10.2"
- php: '7.1'
- php: '7.2'
db: "mariadb:10.3"
- php: '7.1'
- php: '7.2'
db: "mariadb:10.4"
- php: '7.1'
- php: '7.2'
db: "mariadb:10.5"
- php: '7.1'
- php: '7.2'
db: "mysql:5.6"
db_alias: "MyISAM Tests"
MYISAM: 1
- php: '7.1'
- php: '7.2'
db: "mysql:5.6"
- php: '7.1'
db: "mysql:5.7"
- php: '7.2'
db: "mysql:5.7"
- php: '7.3'
Expand All @@ -123,6 +121,12 @@ jobs:
db: "mysql:5.7"
- php: '8.1'
db: "mysql:5.7"
- php: '8.2'
db: "mysql:5.7"
- php: '8.3'
db: "mysql:5.7"
- php: '8.4'
db: "mysql:5.7"

name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }}

Expand Down Expand Up @@ -152,14 +156,14 @@ jobs:

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand All @@ -168,7 +172,7 @@ jobs:
MATRIX_DB: ${{ matrix.db }}
run: |
db=$(echo "${MATRIX_DB%%:*}")
echo "::set-output name=db::$db"
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -205,22 +209,38 @@ jobs:

# START PostgreSQL Job
postgres-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- php: '7.1'
- php: '7.2'
db: "postgres:9.5"
- php: '7.1'
- php: '7.2'
db: "postgres:9.6"
- php: '7.1'
- php: '7.2'
db: "postgres:10"
- php: '7.1'
- php: '7.2'
db: "postgres:11"
- php: '7.1'
- php: '7.2'
db: "postgres:12"
- php: '7.2'
db: "postgres:13"
- php: '7.3'
db: "postgres:13"
- php: '7.4'
db: "postgres:13"
- php: '8.0'
db: "postgres:12"
- php: '7.1'
- php: '8.0'
db: "postgres:13"
- php: '8.1'
db: "postgres:14"
- php: '8.2'
db: "postgres:14"
- php: '8.3'
db: "postgres:14"
- php: '8.4'
db: "postgres:14"

name: PHP ${{ matrix.php }} - ${{ matrix.db }}

Expand Down Expand Up @@ -252,14 +272,14 @@ jobs:

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand All @@ -268,7 +288,7 @@ jobs:
MATRIX_DB: ${{ matrix.db }}
run: |
db=$(echo "${MATRIX_DB%%:*}")
echo "::set-output name=db::$db"
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -305,11 +325,11 @@ jobs:

# START Other Tests Job (SQLite 3 and mssql)
other-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- php: '7.1'
- php: '7.2'
db: "sqlite3"
- php: '7.2'
db: "mcr.microsoft.com/mssql/server:2017-latest"
Expand Down Expand Up @@ -347,14 +367,14 @@ jobs:

steps:
- name: Checkout phpBB
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: phpbb/phpbb
ref: ${{ env.PHPBB_BRANCH }}
path: phpBB3

- name: Checkout extension
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
path: phpBB3/phpBB/ext/${{ env.EXTNAME }}

Expand All @@ -368,7 +388,7 @@ jobs:
else
db=$(echo "${MATRIX_DB%%:*}")
fi
echo "::set-output name=db::$db"
echo "db=$db" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ This extension adds passive security features to phpBB that allow the board's fo
Note: This extension is currently under development and is not ready to install on any live forum.

## License
[GNU General Public License v2](http://opensource.org/licenses/GPL-2.0)
[GNU General Public License v2](https://opensource.org/licenses/GPL-2.0)
2 changes: 1 addition & 1 deletion acp/teamsecurity_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct()
public function main()
{
$this->tpl_name = 'acp_teamsecurity';
$this->page_title = $this->language->lang('ACP_TEAM_SECURITY_SETTINGS');
$this->page_title = 'ACP_TEAM_SECURITY_SETTINGS';

// Only allow founders to view/manage these settings
if ($this->user->data['user_type'] != USER_FOUNDER)
Expand Down
8 changes: 3 additions & 5 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class ext extends \phpbb\extension\base
{
/**
* Check whether or not the extension can be enabled.
* Check whether the extension can be enabled.
* The current phpBB version should meet or exceed
* the minimum version required by this extension:
*
Expand All @@ -27,8 +27,7 @@ class ext extends \phpbb\extension\base
*/
public function is_enableable()
{
$config = $this->container->get('config');
return phpbb_version_compare($config['version'], '3.2.0', '>=');
return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>=');
}

/**
Expand All @@ -40,7 +39,6 @@ public function is_enableable()
*/
public function disable_step($old_state)
{
// Use hardcoded language here since the $user is not available
trigger_error('Please remove ext.php from the filesystem, purge the board cache, and try again.', E_USER_WARNING);
trigger_error('TEAM_SECURITY_DISABLE_MESSAGE', E_USER_WARNING);
}
}
3 changes: 3 additions & 0 deletions language/en/info_acp_teamsecurity.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@

// EMAIL
'ACP_CONTACT_ADMIN' => 'the board administrator or webmaster',

// EXT
'TEAM_SECURITY_DISABLE_MESSAGE' => 'Please remove “ext.php” from the filesystem, purge the board cache, and try again.',
));
7 changes: 7 additions & 0 deletions migrations/m4_serialize_to_json.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ public function update_data()
*/
public function serialize_to_json($cfg)
{
// This check is needed to prevent errors when uninstalling this migration/extension
json_decode($this->config[$cfg], false);
if (json_last_error() === JSON_ERROR_NONE)
{
return '';
}

$data = unserialize(trim($this->config[$cfg]), ['allowed_classes' => false]);

return $data ? json_encode($data) : '';
Expand Down
31 changes: 18 additions & 13 deletions tests/event/delete_log_security_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,41 @@ class delete_log_security_test extends listener_base
*/
public function delete_logs_security_data()
{
return array(
array('admin', true, false),
array('mod', true, false),
array('user', true, false),
array('users', true, false),
array('', true, true),
array('', false, false),
);
return [
['admin', LOG_ADMIN, [], false],
['admin', LOG_ADMIN, ['keywords' => ['test']], false],
['admin', LOG_ADMIN, ['log_id' => ['IN' => []]], false],
['mod', LOG_MOD, [], false],
['user', LOG_USER, [], false],
['users', LOG_USERS, [], false],
['', LOG_CRITICAL, [], true],
['', false, [], false],
];
}

/**
* Test the delete logs security event
*
* @dataProvider delete_logs_security_data
*/
public function test_delete_logs_security($mode, $log_type, $expected_log_type)
public function test_delete_logs_security($mode, $log_type, $conditions, $expected_log_type)
{
// Set some user DateTime options
$this->user->timezone = new \DateTimeZone('UTC');
$this->lang->lang('datetime', array());
$this->lang->lang('datetime', []);

$this->set_listener();

$this->listener->expects(self::exactly(count($conditions)))
->method('send_message');

$dispatcher = new \phpbb\event\dispatcher();
$dispatcher->addListener('core.delete_log', array($this->listener, 'delete_logs_security'));
$dispatcher->addListener('core.delete_log', [$this->listener, 'delete_logs_security']);

$event_data = array('mode', 'log_type');
$event_data = ['mode', 'log_type', 'conditions'];
$event_data_after = $dispatcher->trigger_event('core.delete_log', compact($event_data));
extract($event_data_after, EXTR_OVERWRITE);

self::assertSame($expected_log_type, $log_type);
self::assertEquals($expected_log_type, $log_type);
}
}
Loading

0 comments on commit bbef2b5

Please sign in to comment.