Feat(provisioning): add occ commands - #13670
Conversation
Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughAdded five provisioning console commands for creating, updating, listing, applying, and deleting configurations. Shared option handling validates connection settings, feature toggles, ports, SSL modes, and master-password input. Unit tests cover command flows and validation. ChangesProvisioning option handling
Create and update commands
Operational commands
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant ConsoleCommand
participant ProvisioningOptions
participant ProvisioningManager
ConsoleCommand->>ProvisioningOptions: Build provisioning data
ProvisioningOptions-->>ConsoleCommand: Return validated data
ConsoleCommand->>ProvisioningManager: Create provisioning
ProvisioningManager-->>ConsoleCommand: Return ID or validation error
Merge Risk: 🟠 High · up to The new mail provisioning console commands rely on shared option code that cannot be loaded on one of the supported PHP versions, so administrators on that version would see the commands fail outright. In addition, the master password can be supplied directly on the command line, where it can be observed by other local processes. Both should be addressed before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 13.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 68 functions across 11 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Advanced
Run ID: 8391b4e6-03d5-4205-a290-3de3282de7b6
📒 Files selected for processing (12)
appinfo/info.xmllib/Command/CreateProvisioning.phplib/Command/DeleteProvisioning.phplib/Command/ListProvisionings.phplib/Command/ProvisionAccounts.phplib/Command/ProvisioningOptions.phplib/Command/UpdateProvisioning.phptests/Unit/Command/CreateProvisioningTest.phptests/Unit/Command/DeleteProvisioningTest.phptests/Unit/Command/ListProvisioningsTest.phptests/Unit/Command/ProvisionAccountsTest.phptests/Unit/Command/UpdateProvisioningTest.php
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.
| * @psalm-type ProvisioningData = array<string, mixed> | ||
| */ | ||
| trait ProvisioningOptions { | ||
| private const SSL_MODES = ['none', 'ssl', 'tls']; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge nextcloud/mail /tmp/coderabbit-repo-knowledge/nextcloud-mail-16433369/conventions
Length of output: 1694
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- changed file ---'
git diff -- lib/Command/ProvisioningOptions.php
printf '%s\n' '--- file outline ---'
ast-grep outline lib/Command/ProvisioningOptions.php
printf '%s\n' '--- relevant source ---'
sed -n '1,190p' lib/Command/ProvisioningOptions.php
printf '%s\n' '--- PHP version declarations and CI references ---'
rg -n --glob '!vendor/**' --glob '!node_modules/**' 'PHP_VERSION|php-version|php:|PHP 8\.1|8\.1|ProvisioningOptions|master-password' .github composer.json lib tests 2>/dev/null | head -200Repository: nextcloud/mail
Length of output: 13054
Remove trait constants to restore PHP 8.1 compatibility.
The project supports PHP 8.1 and runs PHP 8.1 checks. PHP 8.1 does not support trait constants, so loading ProvisioningOptions causes a parse error. Move the constants on Lines 25–50 to a class and reference them from the trait, or replace them with PHP 8.1-compatible methods or local values.
🧰 Tools
🪛 GitHub Actions: Lint php / 2_php-lint (8.1).txt
[error] 25-25: PHP syntax lint failed: Traits cannot have constants. The command 'composer run lint' reported a fatal error while parsing this file.
🪛 GitHub Actions: Lint php / php-lint (8.1)
[error] 25-25: PHP syntax lint failed: Traits cannot have constants. Command 'composer run lint' reported a fatal error while parsing this file.
[error] 25-25: The lint step aborted with exit code 124 after PHP exited with status 255 while parsing the trait.
🪛 GitHub Actions: Static analysis / 1_static-psalm-analysis dev-stable34.txt
[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. The 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' command failed.
🪛 GitHub Actions: Static analysis / 2_static-psalm-analysis dev-stable32.txt
[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github'.
🪛 GitHub Actions: Static analysis / 3_static-psalm-analysis dev-stable35.txt
[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. The command 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' failed with exit code 2.
🪛 GitHub Actions: Static analysis / 4_static-psalm-analysis dev-master.txt
[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github'.
🪛 GitHub Actions: Static analysis / 5_static-psalm-analysis dev-stable33.txt
[error] 25-25: Psalm failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github': ConstantDeclarationInTrait. Traits cannot declare constants until PHP 8.2.0.
🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-master
[error] 25-25: Psalm reported ConstantDeclarationInTrait: traits cannot declare constants until PHP 8.2.0. Command 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' failed.
🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable32
[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github'.
🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable33
[error] 25-25: Psalm (composer run psalm) reported ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0.
🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable34
[error] 25-25: Psalm (ConstantDeclarationInTrait): Traits cannot declare constants until PHP 8.2.0. Command failed: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github.
🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable35
[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' failed with exit code 2.
🪛 GitHub Check: static-psalm-analysis dev-master
[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)
🪛 GitHub Check: static-psalm-analysis dev-stable32
[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)
🪛 GitHub Check: static-psalm-analysis dev-stable33
[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)
🪛 GitHub Check: static-psalm-analysis dev-stable34
[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)
🪛 GitHub Check: static-psalm-analysis dev-stable35
[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)
Sources: Linters/SAST tools, Pipeline failures
| InputOption::VALUE_OPTIONAL, | ||
| 'Master password used for all accounts instead of the login password. Pass without a value to read it from stdin', |
There was a problem hiding this comment.
🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- ProvisioningOptions.php outline ---'
ast-grep outline lib/Command/ProvisioningOptions.php
printf '%s\n' '--- ProvisioningOptions.php relevant sections ---'
cat -n lib/Command/ProvisioningOptions.php | sed -n '1,180p'
printf '%s\n' '--- direct references to master-password handling ---'
rg -n -C 4 -- '--master-password|OPTION_MASTER_PASSWORD|masterPassword|MASTER_PASSWORD' lib tests | head -240Repository: nextcloud/mail
Length of output: 24484
Sensitive Data Exposure
Reachability: External
Exploitability: Moderate
CWE: CWE-214
Do not accept the master password as an option value.
InputOption::VALUE_OPTIONAL allows --master-password=<secret>, which exposes the secret through the process argument list. Accept only --master-password without a value, then read the password through the existing hidden prompt or stdin path.
Assisted-by: ClaudeCode:claude-opus-5
🤖 AI (if applicable)
Summary by CodeRabbit