Skip to content

Commit 5146c53

Browse files
Merge pull request #688 from nextcloud/backport/687/stable28
[stable28] [stable30] fix(generation): Fix common-password check when we accidentally hit t…
2 parents eb8c820 + d4c4c29 commit 5146c53

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

.github/workflows/block-merge-eol.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#
33
# https://github.com/nextcloud/.github
44
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
58

69
name: Block merges for EOL
710

@@ -23,15 +26,15 @@ jobs:
2326
runs-on: ubuntu-latest-low
2427

2528
steps:
26-
- name: Download updater config
27-
run: curl https://raw.githubusercontent.com/nextcloud/updater_server/production/config/config.php --output config.php
28-
2929
- name: Set server major version environment
3030
run: |
3131
# retrieve version number from branch reference
3232
server_major=$(echo "${{ github.base_ref }}" | sed -En 's/stable//p')
3333
echo "server_major=$server_major" >> $GITHUB_ENV
34+
echo "current_month=$(date +%Y-%m)" >> $GITHUB_ENV
3435
3536
- name: Checking if ${{ env.server_major }} is EOL
3637
run: |
37-
php -r 'echo json_encode(require_once "config.php");' | jq --arg version "${{ env.server_major }}" '.stable[$version]["100"].eol // .beta[$version]["100"].eol' | grep --silent -i 'false'
38+
curl -s https://raw.githubusercontent.com/nextcloud-releases/updater_server/production/config/major_versions.json \
39+
| jq '.["${{ env.server_major }}"]["eol"] // "9999-99" | . >= "${{ env.current_month }}"' \
40+
| grep -q true

lib/Validator/CommonPasswordsValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function validate(string $password): void {
4545
$enforceNonCommonPassword = $this->config->getEnforceNonCommonPassword();
4646
$passwordFile = __DIR__ . '/../../lists/list-'.strlen($password).'.php';
4747
if ($enforceNonCommonPassword && file_exists($passwordFile)) {
48-
$commonPasswords = require_once $passwordFile;
48+
$commonPasswords = require $passwordFile;
4949
if (isset($commonPasswords[strtolower($password)])) {
5050
$message = 'Password is among the 1,000,000 most common ones. Please make it unique.';
5151
$message_t = $this->l->t(

tests/lib/Validator/CommonPasswordsValidatorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,15 @@ public function testValidate(string $password, bool $enforced, bool $valid) {
7272
}
7373

7474
public function dataValidate() {
75-
return [
75+
$attempts = [
7676
['banana', false, true],
7777
['bananabananabananabanana', false, true],
7878
['banana', true, false],
7979
['bananabananabananabanana', true, true],
8080
];
81+
for ($i = 1; $i <= 39; $i++) {
82+
$attempts[] = [str_repeat('$', $i), true, true];
83+
}
84+
return $attempts;
8185
}
8286
}

0 commit comments

Comments
 (0)