mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-22 04:09:22 +00:00
reduce logs clientside
This commit is contained in:
parent
4f19da5395
commit
b543a72ee9
@ -106,17 +106,15 @@ public class AdminSettingsController {
|
|||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to save settings to file: {}", e.getMessage(), e);
|
log.error("Failed to save settings to file: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(GENERIC_FILE_ERROR);
|
||||||
.body("Failed to save settings to configuration file.");
|
|
||||||
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
log.error("Invalid setting key or value: {}", e.getMessage(), e);
|
log.error("Invalid setting key or value: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(GENERIC_INVALID_SETTING);
|
||||||
.body("Invalid setting key or value: " + e.getMessage());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unexpected error while updating settings: {}", e.getMessage(), e);
|
log.error("Unexpected error while updating settings: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
.body("Internal server error occurred while updating settings.");
|
.body(GENERIC_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,16 +212,14 @@ public class AdminSettingsController {
|
|||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to save section settings to file: {}", e.getMessage(), e);
|
log.error("Failed to save section settings to file: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(GENERIC_FILE_ERROR);
|
||||||
.body("Failed to save settings to configuration file.");
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
log.error("Invalid section data: {}", e.getMessage(), e);
|
log.error("Invalid section data: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(GENERIC_INVALID_SECTION);
|
||||||
.body("Invalid section data: " + e.getMessage());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unexpected error while updating section settings: {}", e.getMessage(), e);
|
log.error("Unexpected error while updating section settings: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
.body("Internal server error occurred while updating section settings.");
|
.body(GENERIC_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,16 +297,14 @@ public class AdminSettingsController {
|
|||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to save setting to file: {}", e.getMessage(), e);
|
log.error("Failed to save setting to file: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(GENERIC_FILE_ERROR);
|
||||||
.body("Failed to save setting to configuration file.");
|
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
log.error("Invalid setting key or value: {}", e.getMessage(), e);
|
log.error("Invalid setting key or value: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(GENERIC_INVALID_SETTING);
|
||||||
.body("Invalid setting key or value: " + e.getMessage());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Unexpected error while updating setting: {}", e.getMessage(), e);
|
log.error("Unexpected error while updating setting: {}", e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
.body("Internal server error occurred while updating setting.");
|
.body(GENERIC_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,6 +351,13 @@ public class AdminSettingsController {
|
|||||||
private static final Pattern SAFE_KEY_PATTERN = Pattern.compile("^[a-zA-Z0-9._]+$");
|
private static final Pattern SAFE_KEY_PATTERN = Pattern.compile("^[a-zA-Z0-9._]+$");
|
||||||
private static final int MAX_NESTING_DEPTH = 10;
|
private static final int MAX_NESTING_DEPTH = 10;
|
||||||
|
|
||||||
|
// Security: Generic error messages to prevent information disclosure
|
||||||
|
private static final String GENERIC_INVALID_SETTING = "Invalid setting key or value.";
|
||||||
|
private static final String GENERIC_INVALID_SECTION = "Invalid section data provided.";
|
||||||
|
private static final String GENERIC_SERVER_ERROR = "Internal server error occurred.";
|
||||||
|
private static final String GENERIC_FILE_ERROR =
|
||||||
|
"Failed to save settings to configuration file.";
|
||||||
|
|
||||||
private boolean isValidSettingKey(String key) {
|
private boolean isValidSettingKey(String key) {
|
||||||
if (key == null || key.trim().isEmpty()) {
|
if (key == null || key.trim().isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user