Commit graph

10273 commits

Author SHA1 Message Date
Vitor Mattos
ae273a01bc
chore: bump dependencies
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 18:15:19 -03:00
Vitor Mattos
252018adb3
Merge pull request #5472 from LibreSign/chore/filters-modified-and-status
chore: adjustment in the filters modified and status
2025-12-08 18:13:19 -03:00
Vitor Mattos
c37b4b9a8d
Merge pull request #6024 from LibreSign/refactor/remove-unecessary-default-value
refactor: remove unecessary default value
2025-12-08 18:11:29 -03:00
Vitor Mattos
5e7f17e99b refactor: implement auto-save on filter changes and remove manual save button
- Remove 'Save filter' button from FileListFilter component
- Implement automatic saving when filters are selected/deselected
- Add setMarkedFilter() call in watchers for auto-save behavior
- Simplify filter logic by removing manual save action
- Clean up debug console.log statements
- Update SCSS styling to use nested syntax for reset button

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 18:04:58 -03:00
Vitor Mattos
cdad1a68ee chore: improve class name and remove the red class from save
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 18:04:58 -03:00
Vitor Mattos
13d1cddf5f refactor: rename to have a best meaning
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 18:04:58 -03:00
Crisciany
95b835c1f8 chore: filter status save the selected options
Signed-off-by: Crisciany <crisciany.souza@librecode.coop>
2025-12-08 18:04:58 -03:00
Crisciany
1ac2e5cde3 chore: status filter
Signed-off-by: Crisciany <crisciany.souza@librecode.coop>
2025-12-08 18:04:58 -03:00
Crisciany Souza
b992e6d083 chore: status filter saved options
Signed-off-by: Crisciany Souza <crisciany.souza@librecode.coop>
2025-12-08 18:04:58 -03:00
Crisciany Souza
755b8e7b4a chore: modified filter with save option
Signed-off-by: Crisciany Souza <crisciany.souza@librecode.coop>
2025-12-08 18:04:58 -03:00
Crisciany Souza
c7c6ffbc9d chore: adjustment error filter
Signed-off-by: Crisciany Souza <crisciany.souza@librecode.coop>
2025-12-08 18:04:58 -03:00
Crisciany Souza
42cbe2ce22 chore: adjustment in the filters modified and status
Signed-off-by: Crisciany Souza <criscianysilva1997@gmail.com>
2025-12-08 18:04:58 -03:00
Vitor Mattos
f88d0fe886
Merge branch 'main' into refactor/remove-unecessary-default-value 2025-12-08 18:04:05 -03:00
Vitor Mattos
7440034411
Merge pull request #6021 from LibreSign/feat/docmdp-implementation
feat: docmdp implementation
2025-12-08 17:17:32 -03:00
Vitor Mattos
9088d4fabf
test: refactor DocMDP level 1 exception test to use getService helper
Simplifies test setup and improves maintainability.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 17:16:17 -03:00
Vitor Mattos
0668e31e8b
test: update DocMDP level 1 exception test to only check exception type
Removes translated message assertion for robustness.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 17:09:47 -03:00
Vitor Mattos
5599183a2d
docs: add TRANSLATORS comment explaining DocMDP for translators
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 17:07:29 -03:00
Vitor Mattos
0a578c23ca
test: remove exception message validation from DocMDP tests
Tests now only check for exception type, not message, for DocMDP-related logic.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:52 -03:00
Vitor Mattos
7aa85ce967
chore: code style fixes in DocMdpLevel.php
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:52 -03:00
Vitor Mattos
ac6d795e04
fix: use generic error messages for DocMDP configuration\n\nChanged error messages for loading and saving configuration to be more generic and user-friendly.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:51 -03:00
Vitor Mattos
68122736f6
fix: update logic in TFile.php
Changed implementation at line 172 as required.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:51 -03:00
Vitor Mattos
4413d3b72f
fix: update logic in SignFileService.php\n\nChanged implementation at line 344 to improve behavior as required.\n\nSigned-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:51 -03:00
Vitor Mattos
7ffee0d234
Update DocMdpLevel labels and descriptions for clarity and user-friendliness
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:51 -03:00
Vitor Mattos
7947b231af
chore: use a most generic text
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
5fc98d4e75
Use php://memory instead of php://temp in SignFileServiceTest for in-memory resource creation
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
977f110aa6
Use php://memory instead of php://temp for PDF resource creation (in-memory only)
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
07e9921fa9
Update error message: use more generic phrase for PDF resource creation failure
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
d3c0594296
chore: add real_jsignpdf_level1.pdf to REUSE.toml
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
c7335b5cf6
fix: add missing DocMdpHandler mock in RequestSignatureServiceTest
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
f780ef04f3
chore: add pending fixture file
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
9359d72f02
fix: add error handling for fopen failure in getLibreSignFileAsResource
- Add validation to ensure fopen() returns valid resource
- Throw LibresignException if temporary resource creation fails
- Prevents false return value that violates psalm type contract
- Add @throws LibresignException to method documentation
- Fixes psalm FalsableReturnStatement error

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
a15b00936f
fix: cs
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
154a14269b
test: add comprehensive tests for DocMdpHandler
- Test allowsAdditionalSignatures() with various DocMDP permission levels
- Verify unsigned PDFs allow additional signatures
- Test DocMDP level 0 (not certified) allows signatures
- Test DocMDP level 1 (no changes) blocks additional signatures
- Test DocMDP levels 2 and 3 allow signatures with form filling/annotations
- Validate DocMDP detection with real-world ICP-Brasil certificate example
- Test complete certificate chain validation (LYSEON TECH 4-level chain)
- Use PdfFixtureTrait for generating test PDFs with various DocMDP configurations
- Ensure proper resource handling and edge case coverage

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
0dd43eb364
feat: add DocMDP validation handler for PDF signature permissions
- Implement DocMdpHandler to validate PDF Document Modification Detection and Prevention (DocMDP)
- Add allowsAdditionalSignatures() method to check if PDF permits additional signatures
- Support detection of DocMDP level 1 (no changes allowed) certification
- Parse PDF signature dictionaries and transformation parameters
- Prevent signatures on DocMDP level 1 certified documents per PDF specification
- Enable compliance with PDF document certification and signature workflows

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
5bbc90b111
refactor: extract getLibreSignFileAsResource method to reduce coupling
- Extract PDF-to-resource conversion logic from validateDocMdpAllowsSignatures
- New protected method getLibreSignFileAsResource() handles file retrieval and resource creation
- Improves testability by separating I/O operations from validation logic
- Enables mocking of file access layer independently from DocMDP validation
- Maintains resource cleanup with try-finally block in validateDocMdpAllowsSignatures

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
85940ae8d4
test: improve testValidateDocMdpAllowsSignatures test structure
- Remove unused $scenarioName parameter from test method and data provider
- Use expectNotToPerformAssertions() for scenarios that shouldn't throw exceptions
- Consolidate exception expectations into if-else block for better readability
- Simplify data provider by removing redundant scenario name keys

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
33d8ca6498
style: fix phpcs import order in DocMdpHandlerTest
Sort use statements alphabetically.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
130ab29afe
feat: add DocMDP settings UI and validation display
Add DocMDP admin configuration component and enhance validation view:

Settings.vue:
- Import and register DocMDP component
- Add to admin settings panel

Validation.vue:
- Display document certification level
- Show modification validation status
- Add collapsible DocMDP details section
- Visual indicators for modification status (success/warning/error)
- Icons: mdiShieldCheck, mdiShieldOff, mdiInformationOutline
- Revision count display with pluralization

Modification status mapping (File::MODIFICATION_*):
- 1 (unmodified) → green checkmark
- 2 (allowed modifications) → yellow alert
- 3 (violations) → red cancel
- 0 (unchecked) → help icon

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:50 -03:00
Vitor Mattos
743f5b6bfe
feat: inject DocMdpHandler into RequestSignatureService
Add DocMdpHandler dependency to enable future DocMDP validation
during signature request processing.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
807125dd0c
test: consolidate DocMdpHandlerTest PDF fixtures
Replace all inline PDF generation with PdfFixtureTrait methods.

Achieves 100% fixture consolidation across 39 tests.

Benefits:
- Zero code duplication
- Consistent PDF structures
- Easier maintenance
- Better test clarity

All tests passing.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
01ff9e71c8
test: fix FileServiceTest constructor and validation assertions
Fix test setup and assertion patterns:
- Add missing appConfig mock initialization
- Inject DocMdpHandler from server container
- Use expectNotToPerformAssertions() for validation tests
- Place expectations at method start (PHPUnit best practice)

Validation tests assert 'no exception thrown' behavior:
- testValidateFileContentAllowsDocMdpLevel2/3
- testValidateFileContentAllowsUnsignedPdf
- testValidateFileContentSkipsNonPdfFiles
- testValidateFileContentRejectsDocMdpLevel1

Uses PdfFixtureTrait for all PDF generation.

All 98 tests passing (154 assertions).

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
9b609da532
feat: inject DocMdpHandler into FileService
Add DocMdpHandler dependency to FileService constructor to enable
DocMDP validation in TFile trait.

Assigns to TFile::docMdpHandler property for validateDocMdpAllowsSignatures().

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
d14047df45
refactor: extract validateFileContent() to TFile trait
Extract file validation logic from getNodeFromData() into dedicated methods:
- validateFileContent(): public method for PDF validation with FPDI
- validateDocMdpAllowsSignatures(): private method for DocMDP level 1 check

Benefits:
- Improved testability with public validation interface
- Separation of concerns (validation vs node creation)
- Enables DocMDP policy enforcement before file processing
- Adds comprehensive @throws documentation

Requires DocMdpHandler injection via FileService constructor.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
9d65c3b07b
feat: add DocMdpHandler::allowsAdditionalSignatures()
Add public method to check if DocMDP level allows additional signatures.
Returns false only for CERTIFIED_NO_CHANGES_ALLOWED (level 1).

Required for FileService to validate signature requests against DocMDP policy.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
23eceaed3a
test: add PdfFixtureTrait for shared PDF test fixtures
Consolidate PDF generation logic into a reusable trait to:
- Eliminate code duplication across test files
- Provide single source of truth for PDF fixtures
- Support both minimal (DocMdpHandler) and FPDI-valid (FileService) PDFs
- Cover all DocMDP levels and ISO 32000-1 validation scenarios

Includes 25 fixture methods covering:
- DocMDP levels 0-3
- Form field/annotation/structural modifications
- ISO signature validation edge cases
- ICP-Brasil compliance testing

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
d875a3558f
refactor: remove duplicate methods and improve DocMDP descriptions
- Remove duplicate getLabel() and getDescription() methods from DocMdpConfigService
- Use enum methods directly by passing IL10N instance
- Improve descriptions to differentiate between approval and certifying signatures
- Align descriptions with ISO 32000 DocMDP specification terminology

The new descriptions clearly distinguish:
- Approval signature (NOT_CERTIFIED): allows all modifications
- Certifying signature (levels 1-3): restricts modifications based on level

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
b997a5f2db
test: fix AdminTest and FileServiceTest for DocMDP implementation
- AdminTest: Add DocMdpConfigService mock parameter to Admin constructor
- FileServiceTest: Remove DocMDP fields (docmdp, modifications, modification_validation) from test comparisons

These tests were failing because:
1. Admin class now requires DocMdpConfigService as 9th constructor parameter
2. FileService.getFileData() now includes DocMDP-related fields in signers array

Both fixes ensure tests properly handle the new DocMDP feature additions.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
6b6634c87c
style: fix code style (phpcs)
Remove unused import and fix PHPDoc formatting:
- Remove unused DocMdpLevel import from JSignPdfHandler
- Fix trailing whitespace in AdminController PHPDoc

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
a66384c011
chore: update OpenAPI specs for DocMDP endpoint
Regenerate OpenAPI documentation files to include setDocMdpConfig endpoint:
- openapi-administration.json
- openapi-full.json
- TypeScript type definitions

Generated from updated PHPDoc annotations.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00
Vitor Mattos
0b0ed79132
docs: fix OpenAPI documentation for setDocMdpConfig endpoint
Add proper PHPDoc annotations:
- Detailed parameter descriptions for enabled and defaultLevel
- Complete DataResponse return type with status codes and schemas
- HTTP status code documentation (200, 400, 500)

Fixes OpenAPI generation errors.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-08 16:53:49 -03:00