mirror of
				https://github.com/Frooodle/Stirling-PDF.git
				synced 2025-11-01 01:21:18 +01:00 
			
		
		
		
	Fix endpoint mapping (#3999)
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
This commit is contained in:
		
							parent
							
								
									048277483b
								
							
						
					
					
						commit
						13bf8210fc
					
				@ -238,14 +238,14 @@ public class EndpointConfiguration {
 | 
			
		||||
        addEndpointToGroup("PageOps", "rotate-pdf");
 | 
			
		||||
        addEndpointToGroup("PageOps", "multi-page-layout");
 | 
			
		||||
        addEndpointToGroup("PageOps", "scale-pages");
 | 
			
		||||
        addEndpointToGroup("PageOps", "adjust-contrast");
 | 
			
		||||
        addEndpointToGroup("PageOps", "crop");
 | 
			
		||||
        addEndpointToGroup("PageOps", "auto-split-pdf");
 | 
			
		||||
        addEndpointToGroup("PageOps", "extract-page");
 | 
			
		||||
        addEndpointToGroup("PageOps", "pdf-to-single-page");
 | 
			
		||||
        addEndpointToGroup("PageOps", "auto-split-pdf");
 | 
			
		||||
        addEndpointToGroup("PageOps", "split-by-size-or-count");
 | 
			
		||||
        addEndpointToGroup("PageOps", "overlay-pdf");
 | 
			
		||||
        addEndpointToGroup("PageOps", "split-pdf-by-sections");
 | 
			
		||||
        addEndpointToGroup("PageOps", "split-pdf-by-chapters");
 | 
			
		||||
 | 
			
		||||
        // Adding endpoints to "Convert" group
 | 
			
		||||
        addEndpointToGroup("Convert", "pdf-to-img");
 | 
			
		||||
@ -274,27 +274,43 @@ public class EndpointConfiguration {
 | 
			
		||||
        addEndpointToGroup("Security", "sanitize-pdf");
 | 
			
		||||
        addEndpointToGroup("Security", "auto-redact");
 | 
			
		||||
        addEndpointToGroup("Security", "redact");
 | 
			
		||||
        addEndpointToGroup("Security", "validate-signature");
 | 
			
		||||
        addEndpointToGroup("Security", "stamp");
 | 
			
		||||
        addEndpointToGroup("Security", "sign");
 | 
			
		||||
 | 
			
		||||
        // Adding endpoints to "Other" group
 | 
			
		||||
        addEndpointToGroup("Other", "ocr-pdf");
 | 
			
		||||
        addEndpointToGroup("Other", "add-image");
 | 
			
		||||
        addEndpointToGroup("Other", "compress-pdf");
 | 
			
		||||
        addEndpointToGroup("Other", "extract-images");
 | 
			
		||||
        addEndpointToGroup("Other", "change-metadata");
 | 
			
		||||
        addEndpointToGroup("Other", "extract-image-scans");
 | 
			
		||||
        addEndpointToGroup("Other", "sign");
 | 
			
		||||
        addEndpointToGroup("Other", "flatten");
 | 
			
		||||
        addEndpointToGroup("Other", "repair");
 | 
			
		||||
        addEndpointToGroup("Other", "unlock-pdf-forms");
 | 
			
		||||
        addEndpointToGroup("Other", REMOVE_BLANKS);
 | 
			
		||||
        addEndpointToGroup("Other", "remove-annotations");
 | 
			
		||||
        addEndpointToGroup("Other", "compare");
 | 
			
		||||
        addEndpointToGroup("Other", "add-page-numbers");
 | 
			
		||||
        addEndpointToGroup("Other", "auto-rename");
 | 
			
		||||
        addEndpointToGroup("Other", "get-info-on-pdf");
 | 
			
		||||
        addEndpointToGroup("Other", "show-javascript");
 | 
			
		||||
        addEndpointToGroup("Other", "remove-image-pdf");
 | 
			
		||||
        addEndpointToGroup("Other", "add-attachments");
 | 
			
		||||
        addEndpointToGroup("Other", "view-pdf");
 | 
			
		||||
        addEndpointToGroup("Other", "replace-and-invert-color-pdf");
 | 
			
		||||
        addEndpointToGroup("Other", "multi-tool");
 | 
			
		||||
 | 
			
		||||
        // Adding endpoints to "Advance" group
 | 
			
		||||
        addEndpointToGroup("Advance", "adjust-contrast");
 | 
			
		||||
        addEndpointToGroup("Advance", "compress-pdf");
 | 
			
		||||
        addEndpointToGroup("Advance", "extract-image-scans");
 | 
			
		||||
        addEndpointToGroup("Advance", "repair");
 | 
			
		||||
        addEndpointToGroup("Advance", "auto-rename");
 | 
			
		||||
        addEndpointToGroup("Advance", "pipeline");
 | 
			
		||||
        addEndpointToGroup("Advance", "scanner-effect");
 | 
			
		||||
        addEndpointToGroup("Advance", "auto-split-pdf");
 | 
			
		||||
        addEndpointToGroup("Advance", "show-javascript");
 | 
			
		||||
        addEndpointToGroup("Advance", "split-by-size-or-count");
 | 
			
		||||
        addEndpointToGroup("Advance", "overlay-pdf");
 | 
			
		||||
        addEndpointToGroup("Advance", "split-pdf-by-sections");
 | 
			
		||||
        addEndpointToGroup("Advance", "edit-table-of-contents");
 | 
			
		||||
        addEndpointToGroup("Advance", "split-pdf-by-chapters");
 | 
			
		||||
 | 
			
		||||
        // CLI
 | 
			
		||||
        addEndpointToGroup("CLI", "compress-pdf");
 | 
			
		||||
 | 
			
		||||
@ -47,7 +47,8 @@ public class PrintFileController {
 | 
			
		||||
            throws IOException {
 | 
			
		||||
        MultipartFile file = request.getFileInput();
 | 
			
		||||
        String originalFilename = file.getOriginalFilename();
 | 
			
		||||
        if (originalFilename != null && (originalFilename.contains("..") || Paths.get(originalFilename).isAbsolute())) {
 | 
			
		||||
        if (originalFilename != null
 | 
			
		||||
                && (originalFilename.contains("..") || Paths.get(originalFilename).isAbsolute())) {
 | 
			
		||||
            throw new IOException("Invalid file path detected: " + originalFilename);
 | 
			
		||||
        }
 | 
			
		||||
        String printerName = request.getPrinterName();
 | 
			
		||||
 | 
			
		||||
@ -42,7 +42,6 @@ import stirling.software.common.service.CustomPDFDocumentFactory;
 | 
			
		||||
import stirling.software.common.util.TempFile;
 | 
			
		||||
import stirling.software.common.util.TempFileManager;
 | 
			
		||||
import stirling.software.common.util.WebResponseUtils;
 | 
			
		||||
import java.lang.IllegalArgumentException;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@RequestMapping("/api/v1/misc")
 | 
			
		||||
 | 
			
		||||
@ -331,7 +331,8 @@ public class PipelineProcessor {
 | 
			
		||||
        for (File file : files) {
 | 
			
		||||
            Path normalizedPath = Paths.get(file.getName()).normalize();
 | 
			
		||||
            if (normalizedPath.startsWith("..")) {
 | 
			
		||||
                throw new SecurityException("Potential path traversal attempt in file name: " + file.getName());
 | 
			
		||||
                throw new SecurityException(
 | 
			
		||||
                        "Potential path traversal attempt in file name: " + file.getName());
 | 
			
		||||
            }
 | 
			
		||||
            Path path = Paths.get(file.getAbsolutePath());
 | 
			
		||||
            // debug statement
 | 
			
		||||
 | 
			
		||||
@ -83,7 +83,9 @@ public class WatermarkController {
 | 
			
		||||
        MultipartFile watermarkImage = request.getWatermarkImage();
 | 
			
		||||
        if (watermarkImage != null) {
 | 
			
		||||
            String watermarkImageFileName = watermarkImage.getOriginalFilename();
 | 
			
		||||
            if (watermarkImageFileName != null && (watermarkImageFileName.contains("..") || watermarkImageFileName.startsWith("/"))) {
 | 
			
		||||
            if (watermarkImageFileName != null
 | 
			
		||||
                    && (watermarkImageFileName.contains("..")
 | 
			
		||||
                            || watermarkImageFileName.startsWith("/"))) {
 | 
			
		||||
                throw new SecurityException("Invalid file path in watermarkImage");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,7 @@ repositories {
 | 
			
		||||
 | 
			
		||||
allprojects {
 | 
			
		||||
    group = 'stirling.software'
 | 
			
		||||
    version = '1.0.2'
 | 
			
		||||
    version = '1.1.0'
 | 
			
		||||
 | 
			
		||||
    configurations.configureEach {
 | 
			
		||||
        exclude group: 'commons-logging', module: 'commons-logging'
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user