Skip to content

Conversation

@lennartdohmann
Copy link
Member

No description provided.

@lennartdohmann lennartdohmann requested a review from Copilot August 20, 2025 14:23
@lennartdohmann lennartdohmann self-assigned this Aug 20, 2025
@lennartdohmann lennartdohmann linked an issue Aug 20, 2025 that may be closed by this pull request

This comment was marked as outdated.

@lennartdohmann lennartdohmann marked this pull request as ready for review August 21, 2025 09:51
@lennartdohmann lennartdohmann requested a review from Copilot August 21, 2025 09:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a configurable maximum scan size setting to replace the hardcoded file size limit. Users can now set a custom maximum file size (in MB) for virus scanning through the admin interface.

  • Replaces hardcoded 1GB file size limit with configurable setting
  • Adds admin UI form field for maximum scan size configuration
  • Updates error messages to use the configurable limit instead of hardcoded values

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
templates/admin.php Adds form input field for maximum scan size setting
src/admin-settings.js Includes max scan size in form submission data
lib/Settings/VaasAdmin.php Provides max scan size value to admin template
lib/Service/VerdictService.php Replaces hardcoded limit with configurable setting
lib/Service/ScanService.php Updates error message to use configurable limit
lib/Controller/SettingsController.php Handles saving of max scan size setting with validation
lib/Controller/ScanController.php Updates error message to use configurable limit
tests/bats/functionality-parallel.bats Adjusts test file size to match new default limit

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}
}
if ((int)$maxScanSize < 1) {
return new JSONResponse(['status' => 'error', 'message' => 'Invalid max scan size: ' . $maxScanSize]);
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation only checks for values less than 1, but doesn't handle the case where maxScanSize is null or empty string. This could cause unexpected behavior when casting to int.

Suggested change
return new JSONResponse(['status' => 'error', 'message' => 'Invalid max scan size: ' . $maxScanSize]);
if ($maxScanSize === null || $maxScanSize === '' || !is_numeric($maxScanSize) || (int)$maxScanSize < 1) {
return new JSONResponse(['status' => 'error', 'message' => 'Invalid max scan size: ' . var_export($maxScanSize, true)]);

Copilot uses AI. Check for mistakes.
* @return bool
*/
public static function isFileTooLargeToScan(string $path): bool {
public function isFileTooLargeToScan(string $path): bool {
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this method from static to instance method is a breaking change that could cause errors in other parts of the codebase that call VerdictService::isFileTooLargeToScan() statically.

Copilot uses AI. Check for mistakes.
<td class="input_field"><input id="notify_mails" type="text" name="notify_mails" value="<?php p($_['notifyMail']); ?>"/></td>
</tr>
<tr class="max-scan-size">
<td><div title="<?php p($l->t('The maximum scan size for files to be scanned in MB. Files above this limit are tagged as “Won\'t Scan”.'));?>" class="visible"><label for="max-scan-size"><?php p($l->t('Maximum scan size'));?></label></div></td>
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The escaped single quote in "Won't Scan" should use proper PHP string escaping. Consider using double quotes for the outer string to avoid confusion.

Suggested change
<td><div title="<?php p($l->t('The maximum scan size for files to be scanned in MB. Files above this limit are tagged as “Won\'t Scan”.'));?>" class="visible"><label for="max-scan-size"><?php p($l->t('Maximum scan size'));?></label></div></td>
<td><div title="<?php p($l->t("The maximum scan size for files to be scanned in MB. Files above this limit are tagged as “Won't Scan”."));?>" class="visible"><label for="max-scan-size"><?php p($l->t('Maximum scan size'));?></label></div></td>

Copilot uses AI. Check for mistakes.
@lennartdohmann lennartdohmann merged commit 95f517d into main Aug 21, 2025
20 checks passed
@lennartdohmann lennartdohmann deleted the scan-size-setting branch August 26, 2025 11:28
lennartdohmann added a commit that referenced this pull request Aug 28, 2025
* fix: correct syntax error in ScanService.php for constant declaration for PHP < 8.3 (#227)

* chore(deps): update dependency webpack-dev-server to v5.2.2 (#225)

Co-authored-by: Renovate Bot <[email protected]>

* chore(deps): update all non-major dependencies (#231)

Co-authored-by: Renovate Bot <[email protected]>

* chore(deps): update dependency psalm/phar to v6.13.0 (#232)

Co-authored-by: Renovate Bot <[email protected]>

* chore(deps): update all non-major dependencies (#233)

Co-authored-by: Renovate Bot <[email protected]>

* Add a quicker way for development with a local Nextcloud server and the app code changeable inside this server (#234)

* Add Nextclouds worklfow templates and apply Nextcloud coding style (#235)

* Add maximum scan size setting for file uploads (#236)

* Devcontainer and Workflow Performance (#237)

- Faster local development in devcontainer
- Add Make stages for local fast developing as well as unit and bats tests
- Remove unmaintained files from old debugging sessions`
- Cleanup unused files and bundle utility scripts

* Settings improvements (#238)

- Add button to test current vaas configuration
- Rename app settings to be more intuitive

* Add additional settings (#239)

- Control scan timeout
- Control usage of cache
- Control usage of hash lookup

* Refactor logging messages and remove redundant debug statements (#240)

* Update README with development environment setup instructions (#241)

* Remove unused settings (#242)

- Malicious file notifications summary
- Scan only new files

* Add make target for production like local setup (#243)

* Outsource file scan actions (#244)

---------

Co-authored-by: vaas-bot <[email protected]>
Co-authored-by: Renovate Bot <[email protected]>
lennartdohmann added a commit that referenced this pull request Aug 28, 2025
* fix: correct syntax error in ScanService.php for constant declaration for PHP < 8.3 (#227)

* Add a quicker way for development with a local Nextcloud server and the app code changeable inside this server (#234)

* Add Nextclouds worklfow templates and apply Nextcloud coding style (#235)

* Add maximum scan size setting for file uploads (#236)

* Devcontainer and Workflow Performance (#237)

- Faster local development in devcontainer
- Add Make stages for local fast developing as well as unit and bats tests
- Remove unmaintained files from old debugging sessions`
- Cleanup unused files and bundle utility scripts

* Settings improvements (#238)

- Add button to test current vaas configuration
- Rename app settings to be more intuitive

* Add additional settings (#239)

- Control scan timeout
- Control usage of cache
- Control usage of hash lookup

* Refactor logging messages and remove redundant debug statements (#240)

* Update README with development environment setup instructions (#241)

* Remove unused settings (#242)

- Malicious file notifications summary
- Scan only new files

* Add make target for production like local setup (#243)

* Outsource file scan actions (#244)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting to set max file size for scans

2 participants