mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-03-28 02:31:17 +01:00
# Description of Changes This pull request introduces a comprehensive auditing system to the application, along with minor updates to existing utilities and dependencies. The most significant changes include the addition of audit-related classes and enums, updates to the `ApplicationProperties` model to support auditing configuration, and enhancements to utility methods for handling static and trackable resources. ### Audit System Implementation: * **Audit Aspect for Method Annotations**: Added `AuditAspect` to process the new `@Audited` annotation, enabling detailed logging of method execution, HTTP requests, and operation results based on configurable audit levels. (`proprietary/src/main/java/stirling/software/proprietary/audit/AuditAspect.java`) * **Audit Event Types**: Introduced `AuditEventType` enum to define standardized event types for auditing, such as authentication events, file operations, and HTTP requests. (`proprietary/src/main/java/stirling/software/proprietary/audit/AuditEventType.java`) * **Audit Levels**: Added `AuditLevel` enum to define different levels of audit logging (OFF, BASIC, STANDARD, VERBOSE), providing granular control over the amount of data logged. (`proprietary/src/main/java/stirling/software/proprietary/audit/AuditLevel.java`) ### Application Properties Update: * **Audit Configuration in `ProFeatures`**: Updated the `ProFeatures` class in `ApplicationProperties` to include support for auditing with configurable retention days, levels, and enablement flags. (`common/src/main/java/stirling/software/common/model/ApplicationProperties.java`) ### Utility Enhancements: * **Static and Trackable Resource Handling**: Extended `RequestUriUtils` methods (`isStaticResource` and `isTrackableResource`) to recognize `.txt` files as valid static and trackable resources. (`common/src/main/java/stirling/software/common/util/RequestUriUtils.java`) [[1]](diffhunk://#diff-de3599037908683f2cd8f170939547612c6fc2203e9207eb4d7966508f92bbcbR22) [[2]](diffhunk://#diff-de3599037908683f2cd8f170939547612c6fc2203e9207eb4d7966508f92bbcbR39) ### Dependency Update: * **Spring Validation Starter**: Added `spring-boot-starter-validation` to project dependencies to support validation mechanisms required for auditing features. (`proprietary/build.gradle`) Dashboard WIP    --- ## 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/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/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/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/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: a <a> Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
68 lines
2.4 KiB
Java
68 lines
2.4 KiB
Java
package stirling.software.proprietary.config;
|
|
|
|
import lombok.Getter;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.core.Ordered;
|
|
import org.springframework.core.annotation.Order;
|
|
import org.springframework.stereotype.Component;
|
|
import stirling.software.common.model.ApplicationProperties;
|
|
import stirling.software.proprietary.audit.AuditLevel;
|
|
|
|
/**
|
|
* Configuration properties for the audit system.
|
|
* Reads values from the ApplicationProperties under premium.enterpriseFeatures.audit
|
|
*/
|
|
@Slf4j
|
|
@Getter
|
|
@Component
|
|
@Order(Ordered.HIGHEST_PRECEDENCE + 10)
|
|
public class AuditConfigurationProperties {
|
|
|
|
private final boolean enabled;
|
|
private final int level;
|
|
private final int retentionDays;
|
|
|
|
public AuditConfigurationProperties(ApplicationProperties applicationProperties) {
|
|
ApplicationProperties.Premium.EnterpriseFeatures.Audit auditConfig =
|
|
applicationProperties.getPremium().getEnterpriseFeatures().getAudit();
|
|
// Read values directly from configuration
|
|
this.enabled = auditConfig.isEnabled();
|
|
|
|
// Ensure level is within valid bounds (0-3)
|
|
int configLevel = auditConfig.getLevel();
|
|
this.level = Math.min(Math.max(configLevel, 0), 3);
|
|
|
|
// Retention days (0 means infinite)
|
|
this.retentionDays = auditConfig.getRetentionDays();
|
|
|
|
log.debug("Initialized audit configuration: enabled={}, level={}, retentionDays={} (0=infinite)",
|
|
this.enabled, this.level, this.retentionDays);
|
|
}
|
|
|
|
/**
|
|
* Get the audit level as an enum
|
|
* @return The current AuditLevel
|
|
*/
|
|
public AuditLevel getAuditLevel() {
|
|
return AuditLevel.fromInt(level);
|
|
}
|
|
|
|
/**
|
|
* Check if the current audit level includes the specified level
|
|
* @param requiredLevel The level to check against
|
|
* @return true if auditing is enabled and the current level includes the required level
|
|
*/
|
|
public boolean isLevelEnabled(AuditLevel requiredLevel) {
|
|
return enabled && getAuditLevel().includes(requiredLevel);
|
|
}
|
|
|
|
/**
|
|
* Get the effective retention period in days
|
|
* @return The number of days to retain audit records, or -1 for infinite retention
|
|
*/
|
|
public int getEffectiveRetentionDays() {
|
|
// 0 means infinite retention
|
|
return retentionDays <= 0 ? -1 : retentionDays;
|
|
}
|
|
} |