#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Portal audit: label policy runs by their policy, flag automation sub-steps (#6937)
Anthony Stirling5944cd106bff
diff --git a/app/common/src/main/java/stirling/software/common/service/InternalApiClient.java b/app/common/src/main/java/stirling/software/common/service/InternalApiClient.javaindex 39e27457b3..63d577ca85 100644--- a/app/common/src/main/java/stirling/software/common/service/InternalApiClient.java+++ b/app/common/src/main/java/stirling/software/common/service/InternalApiClient.java@@ -8,6 +8,7 @@ import java.nio.file.Files;import java.time.Duration;import java.util.regex.Pattern;+import org.slf4j.MDC;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.core.env.Environment;import org.springframework.core.io.FileSystemResource;@@ -60,6 +61,17 @@ public class InternalApiClient {*/public static final String AUTOMATION_HEADER = "X-Stirling-Automation";+ /**+ * Header carrying the parent policy's name onto each sub-step dispatch, read from MDC key+ * {@link #POLICY_NAME_MDC_KEY} (set by the policy runner on the worker thread). Lets the audit+ * layer attribute a tool step to the policy that ran it, instead of showing it as a bare direct+ * call.+ */+ public static final String POLICY_NAME_HEADER = "X-Stirling-Policy-Name";++ /** MDC key the policy runner stamps with the running policy's name; forwarded as a header. */+ public static final String POLICY_NAME_MDC_KEY = "auditPolicyName";+private final ServletContext servletContext;private final UserServiceInterface userService;private final TempFileManager tempFileManager;@@ -120,6 +132,19 @@ public class InternalApiClient {headers.add(AutomationRunContext.RUN_ID_HEADER, runId);}+ // Forward the parent policy name (set in MDC by the policy runner) so the audited sub-step+ // ties back to its policy. Single-line, length-capped: it becomes an HTTP header value.+ String policyName = MDC.get(POLICY_NAME_MDC_KEY);+ if (policyName != null && !policyName.isBlank()) {+ String safe = policyName.replaceAll("[\\r\\n]", " ").trim();+ if (safe.length() > 200) {+ safe = safe.substring(0, 200);+ }+ if (!safe.isEmpty()) {+ headers.add(POLICY_NAME_HEADER, safe);+ }+ }+// A no-file ai/tools call (e.g. create-pdf-from-html-agent) sends only string params, so// without this RestTemplate would use urlencoded instead of the multipart the controller// expects. File-bearing calls get the right multipart content-type from RestTemplate.diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/audit/AuditAspect.java b/app/proprietary/src/main/java/stirling/software/proprietary/audit/AuditAspect.javaindex f42a0f29c1..12b2787b75 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/audit/AuditAspect.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/audit/AuditAspect.java@@ -142,6 +142,9 @@ public class AuditAspect {auditService.addTimingData(auditData, startTime, resp, auditedAnnotation.level(), isHttpRequest);+ // Merge controller-set policy context + the internal-automation marker onto the event.+ auditService.addAutomationContext(auditData, req);+// Resolve the event type based on annotation and contextString httpMethod = null;String path = null;diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/audit/AuditContext.java b/app/proprietary/src/main/java/stirling/software/proprietary/audit/AuditContext.javanew file mode 100644index 0000000000..650727f5ef--- /dev/null+++ b/app/proprietary/src/main/java/stirling/software/proprietary/audit/AuditContext.java@@ -0,0 +1,18 @@+package stirling.software.proprietary.audit;++/**+ * Request-scoped keys a controller can set to enrich its own audit event with context the generic+ * aspect can't infer from the HTTP request alone (e.g. the policy a pipeline run belongs to). The+ * aspect copies these into the audit data in its {@code finally} block, after the controller body+ * has run. See {@code AuditService#addAutomationContext}.+ */+public final class AuditContext {++ /** Request attribute: the name of the policy/pipeline a run executes. */+ public static final String REQ_ATTR_POLICY_NAME = "stirling.audit.policyName";++ /** Request attribute: the ordered tool endpoint paths a run executes. */+ public static final String REQ_ATTR_POLICY_STEPS = "stirling.audit.policySteps";++ private AuditContext() {}+}diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/audit/ControllerAuditAspect.java b/app/proprietary/src/main/java/stirling/software/proprietary/audit/ControllerAuditAspect.javaindex c59c6f3721..2f75b755e0 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/audit/ControllerAuditAspect.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/audit/ControllerAuditAspect.java@@ -205,6 +205,10 @@ public class ControllerAuditAspect {// Call auditService but with isHttpRequest=true to skip additional timingauditService.addTimingData(data, start, resp, level, true);+ // Merge controller-set policy context + the internal-automation marker (set after+ // the body ran, so it must happen here rather than with the pre-proceed HTTP data).+ auditService.addAutomationContext(data, req);+// Resolve the event type using the unified methodAuditEventType eventType =auditService.resolveEventType(diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/model/api/audit/InfraAuditSummary.java b/app/proprietary/src/main/java/stirling/software/proprietary/model/api/audit/InfraAuditSummary.javaindex c924218e3a..835344e81d 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/model/api/audit/InfraAuditSummary.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/model/api/audit/InfraAuditSummary.java@@ -17,6 +17,9 @@ public class InfraAuditSummary {@Schema(description = "Total events in the returned window", example = "40")private int totalEvents;+ @Schema(description = "Policy-run events", example = "3")+ private int policy;+@Schema(description = "Processing-category events", example = "24")private int processing;diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/policy/controller/PolicyController.java b/app/proprietary/src/main/java/stirling/software/proprietary/policy/controller/PolicyController.javaindex 3c9b56128a..e2c89f6a54 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/policy/controller/PolicyController.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/policy/controller/PolicyController.java@@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.RequestBody;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestPart;import org.springframework.web.bind.annotation.RestController;+import org.springframework.web.context.request.RequestContextHolder;+import org.springframework.web.context.request.ServletRequestAttributes;import org.springframework.web.multipart.MultipartFile;import org.springframework.web.server.ResponseStatusException;import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;@@ -32,6 +34,7 @@ import io.swagger.v3.oas.annotations.Hidden;import io.swagger.v3.oas.annotations.Operation;import io.swagger.v3.oas.annotations.tags.Tag;+import jakarta.servlet.http.HttpServletRequest;import jakarta.validation.Valid;import lombok.RequiredArgsConstructor;@@ -42,6 +45,7 @@ import stirling.software.common.model.job.JobResponse;import stirling.software.common.service.JobOwnershipService;import stirling.software.common.util.TempFile;import stirling.software.common.util.TempFileManager;+import stirling.software.proprietary.audit.AuditContext;import stirling.software.proprietary.policy.config.PolicyAccessGuard;import stirling.software.proprietary.policy.config.PolicyManagementAuthority;import stirling.software.proprietary.policy.engine.PolicyRunHandle;@@ -52,6 +56,7 @@ import stirling.software.proprietary.policy.engine.SweepOutcome;import stirling.software.proprietary.policy.ledger.ProcessedLedger;import stirling.software.proprietary.policy.model.OutputSpec;import stirling.software.proprietary.policy.model.PipelineDefinition;+import stirling.software.proprietary.policy.model.PipelineStep;import stirling.software.proprietary.policy.model.Policy;import stirling.software.proprietary.policy.model.PolicyInputs;import stirling.software.proprietary.policy.model.PolicyRun;@@ -113,6 +118,7 @@ public class PolicyController {@RequestPart("json") PipelineDefinition definition,@Valid @ModelAttribute PolicyRunFiles files)throws IOException {+ stampPolicyAudit(definition);requireRunnable(definition);PolicyInputs inputs = toInputs(files);PolicyRunHandle handle =@@ -132,6 +138,7 @@ public class PolicyController {@RequestPart("json") PipelineDefinition definition,@Valid @ModelAttribute PolicyRunFiles files)throws IOException {+ stampPolicyAudit(definition);requireRunnable(definition);PolicyInputs inputs = toInputs(files);@@ -464,6 +471,7 @@ public class PolicyController {() ->new ResponseStatusException(HttpStatus.NOT_FOUND, "No policy: " + policyId));+ stampPolicyAudit(policy.toDefinition());PolicyInputs inputs = toInputs(files);String runId = policyRunner.runWith(policy, inputs, PolicyProgressListener.NOOP).runId();return ResponseEntity.accepted().body(new JobResponse<>(true, runId, null));@@ -497,6 +505,31 @@ public class PolicyController {}}+ /**+ * Stamp this run's policy name and step endpoints onto the current request so the audit aspect+ * can label the event as the policy it ran (rather than the generic {@code /run} endpoint) and+ * record which tools it executed. No-op outside a web request.+ */+ private static void stampPolicyAudit(PipelineDefinition definition) {+ if (definition == null+ || !(RequestContextHolder.getRequestAttributes()+ instanceof ServletRequestAttributes attrs)) {+ return;+ }+ HttpServletRequest request = attrs.getRequest();+ if (definition.name() != null && !definition.name().isBlank()) {+ request.setAttribute(AuditContext.REQ_ATTR_POLICY_NAME, definition.name());+ }+ List<String> steps =+ definition.steps().stream()+ .map(PipelineStep::operation)+ .filter(op -> op != null && !op.isBlank())+ .toList();+ if (!steps.isEmpty()) {+ request.setAttribute(AuditContext.REQ_ATTR_POLICY_STEPS, steps);+ }+ }+/*** Ad-hoc runs (AI / one-off pipelines) are still editor activity, so their supplied documents* feed the same virtual editor source as stored editor policies, counted against the caller'sdiff --git a/app/proprietary/src/main/java/stirling/software/proprietary/policy/engine/PolicyEngine.java b/app/proprietary/src/main/java/stirling/software/proprietary/policy/engine/PolicyEngine.javaindex cef0f29e6f..d54caedd14 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/policy/engine/PolicyEngine.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/policy/engine/PolicyEngine.java@@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;import stirling.software.common.model.job.ResultFile;import stirling.software.common.service.AutomationRunContext;import stirling.software.common.service.FileStorage;+import stirling.software.common.service.InternalApiClient;import stirling.software.common.service.InternalApiTimeoutException;import stirling.software.common.service.JobOwnershipService;import stirling.software.common.service.JobQueue;@@ -149,6 +150,7 @@ public class PolicyEngine {runAsPrincipal(billingPrincipal,fileOwner,+ definition.name(),() -> runToCompletion(run, inputs, tracking, completion));// One admission unit per run; steps run synchronously within it, so this gates heavy work@@ -377,18 +379,26 @@ public class PolicyEngine {* dispatch attributes (and charges) usage to that user. A null/blank principal runs as-is.* Restores the previous MDC value afterward (defensive — worker threads aren't pooled).*/- private static void runAsPrincipal(String billingPrincipal, String fileOwner, Runnable body) {+ private static void runAsPrincipal(+ String billingPrincipal, String fileOwner, String policyName, Runnable body) {// Billing identity (MDC auditPrincipal) and output-file ownership (JobContext owner) are// set// independently: usage is charged to billingPrincipal, but stored output files are owned by// fileOwner — the user who triggered an org-wide policy — so they can fetch their results.// Either may be null (e.g. login disabled, or a trigger-fired run); each is applied only- // when present and restored afterward (defensive — worker threads aren't pooled).+ // when present and restored afterward (defensive — worker threads aren't pooled). The+ // policy+ // name rides MDC too so each tool step's loopback dispatch (InternalApiClient) can forward+ // it as a header, letting the audit tie the step back to its policy.String previousPrincipal = MDC.get(AUDIT_PRINCIPAL_MDC_KEY);+ String previousPolicyName = MDC.get(InternalApiClient.POLICY_NAME_MDC_KEY);String previousOwner = JobContext.getOwner();if (billingPrincipal != null && !billingPrincipal.isBlank()) {MDC.put(AUDIT_PRINCIPAL_MDC_KEY, billingPrincipal);}+ if (policyName != null && !policyName.isBlank()) {+ MDC.put(InternalApiClient.POLICY_NAME_MDC_KEY, policyName);+ }if (fileOwner != null && !fileOwner.isBlank()) {JobContext.setOwner(fileOwner);}@@ -400,6 +410,11 @@ public class PolicyEngine {} else {MDC.remove(AUDIT_PRINCIPAL_MDC_KEY);}+ if (previousPolicyName != null) {+ MDC.put(InternalApiClient.POLICY_NAME_MDC_KEY, previousPolicyName);+ } else {+ MDC.remove(InternalApiClient.POLICY_NAME_MDC_KEY);+ }JobContext.setOwner(previousOwner);}}diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/repository/PersistentAuditEventRepository.java b/app/proprietary/src/main/java/stirling/software/proprietary/repository/PersistentAuditEventRepository.javaindex 95075945ed..e140b8f5c8 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/repository/PersistentAuditEventRepository.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/repository/PersistentAuditEventRepository.java@@ -184,6 +184,20 @@ public interface PersistentAuditEventRepository extends JpaRepository<PersistentPage<PersistentAuditEvent> findByPrincipalIn(@Param("principals") List<String> principals, Pageable pageable);+ // Noise-excluding scans for the portal: keep the page window full of meaningful events so the+ // list doesn't shrink as read/polling noise (UI_DATA/HTTP_REQUEST) grows in the recent window.+ @Query("SELECT e FROM PersistentAuditEvent e WHERE e.type NOT IN :excludedTypes")+ Page<PersistentAuditEvent> findByTypeNotIn(+ @Param("excludedTypes") List<String> excludedTypes, Pageable pageable);++ @Query(+ "SELECT e FROM PersistentAuditEvent e WHERE e.type NOT IN :excludedTypes AND e.principal"+ + " IN :principals")+ Page<PersistentAuditEvent> findByTypeNotInAndPrincipalIn(+ @Param("excludedTypes") List<String> excludedTypes,+ @Param("principals") List<String> principals,+ Pageable pageable);+@Query("SELECT e FROM PersistentAuditEvent e WHERE e.type IN :types AND e.timestamp BETWEEN :startDate AND :endDate")Page<PersistentAuditEvent> findByTypeInAndTimestampBetween(diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/service/AuditService.java b/app/proprietary/src/main/java/stirling/software/proprietary/service/AuditService.javaindex a56ece5285..2fee8b5c7c 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/service/AuditService.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/service/AuditService.java@@ -37,9 +37,11 @@ import lombok.extern.slf4j.Slf4j;import stirling.software.common.model.api.PDFFile;import stirling.software.common.service.CustomPDFDocumentFactory;+import stirling.software.common.service.InternalApiClient;import stirling.software.common.util.RegexPatternUtils;import stirling.software.common.util.RequestUriUtils;import stirling.software.proprietary.accountlink.BillableOperationClassifier;+import stirling.software.proprietary.audit.AuditContext;import stirling.software.proprietary.audit.AuditEventType;import stirling.software.proprietary.audit.AuditLevel;import stirling.software.proprietary.audit.Audited;@@ -469,6 +471,73 @@ public class AuditService {}}+ /**+ * Merge controller-supplied context into the audit data, read in the aspect's {@code finally}+ * after the controller body has run. A policy run stamps its name and step endpoints as request+ * attributes ({@link AuditContext}); the internal loopback dispatch that executes each pipeline+ * step carries the automation marker header ({@link InternalApiClient#AUTOMATION_HEADER}).+ * Surfacing these lets the portal label a run as its policy instead of the raw {@code /run}+ * endpoint, and flag its sub-steps as automation rather than direct user actions.+ *+ * @param data The existing audit data map+ * @param req The current request, or null when not in a web context+ */+ public void addAutomationContext(Map<String, Object> data, HttpServletRequest req) {+ if (req == null) {+ return;+ }+ Object policyName = req.getAttribute(AuditContext.REQ_ATTR_POLICY_NAME);+ if (policyName == null) {+ // A pipeline step's loopback dispatch carries its parent policy name as a header, so+ // the+ // step audit ties back to the policy that ran it (not a bare direct call).+ String header = req.getHeader(InternalApiClient.POLICY_NAME_HEADER);+ if (header != null && !header.isBlank()) {+ policyName = header;+ }+ }+ if (policyName != null) {+ // Both sources are caller-controlled (the header is spoofable and, unlike the sender in+ // InternalApiClient, uncapped); strip newlines and cap before persisting to audit JSON.+ String safe = capLabel(String.valueOf(policyName));+ if (!safe.isEmpty()) {+ data.put("policyName", safe);+ }+ }+ Object steps = req.getAttribute(AuditContext.REQ_ATTR_POLICY_STEPS);+ if (steps instanceof List<?> list && !list.isEmpty()) {+ // Caller-supplied and unbounded; cap count and each entry so a crafted run can't+ // bloat the audit JSON the portal cache loads and parses in bulk.+ List<String> safeSteps =+ list.stream()+ .limit(MAX_POLICY_STEPS)+ .map(s -> capLabel(String.valueOf(s)))+ .filter(s -> !s.isEmpty())+ .toList();+ if (!safeSteps.isEmpty()) {+ data.put("policySteps", safeSteps);+ }+ }+ if ("true".equalsIgnoreCase(req.getHeader(InternalApiClient.AUTOMATION_HEADER))) {+ data.put("automation", Boolean.TRUE);+ }+ }++ /** Max characters kept for a persisted policy label; mirrors the InternalApiClient send cap. */+ private static final int MAX_LABEL_LEN = 200;++ /** Max step endpoints kept on a run's audit event; the portal only shows the first few. */+ private static final int MAX_POLICY_STEPS = 50;++ /** Single-line, length-capped label safe to persist to audit JSON and render in the portal. */+ private static String capLabel(String value) {+ if (value == null) {+ return "";+ }+ String safe = value.replaceAll("[\\r\\n]", " ").trim();+ return safe.length() > MAX_LABEL_LEN ? safe.substring(0, MAX_LABEL_LEN) : safe;+ }+/*** Add method arguments to the audit data*diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalAuditReadService.java b/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalAuditReadService.javaindex 1678cd095f..5a94e9d2b1 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalAuditReadService.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalAuditReadService.java@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;import lombok.RequiredArgsConstructor;+import stirling.software.proprietary.audit.AuditEventType;import stirling.software.proprietary.audit.PortalAuditEventRow;import stirling.software.proprietary.model.security.PersistentAuditEvent;import stirling.software.proprietary.repository.PersistentAuditEventRepository;@@ -24,12 +25,21 @@ public class PortalAuditReadService {/** Newest rows to scan; each surface filters this down to what it shows. */private static final int SCAN_LIMIT = 400;+ /**+ * Read/polling noise excluded at the query level so the scan window stays full of meaningful+ * events. Otherwise a busy scope's recent rows fill with these and the visible list shrinks as+ * traffic grows - the "audit getting smaller over time" a user would see. No portal surface+ * shows these types anyway (the infra tab and documents feed both drop them).+ */+ private static final List<String> NOISE_TYPES =+ List.of(AuditEventType.UI_DATA.name(), AuditEventType.HTTP_REQUEST.name());+private final PersistentAuditEventRepository auditRepository;/** Recent whole-server events (admins). */@Cacheable(value = CACHE_NAME, key = "'server'")public List<PortalAuditEventRow> serverEvents() {- return toRows(auditRepository.findAll(recentPage()).getContent());+ return toRows(auditRepository.findByTypeNotIn(NOISE_TYPES, recentPage()).getContent());}/** Recent events by the given principals (team scope). Empty principals yield an empty list. */@@ -38,7 +48,10 @@ public class PortalAuditReadService {if (principals.isEmpty()) {return List.of();}- return toRows(auditRepository.findByPrincipalIn(principals, recentPage()).getContent());+ return toRows(+ auditRepository+ .findByTypeNotInAndPrincipalIn(NOISE_TYPES, principals, recentPage())+ .getContent());}private static PageRequest recentPage() {diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalDocumentsService.java b/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalDocumentsService.javaindex 8784d5c5b6..fcae36f61b 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalDocumentsService.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalDocumentsService.java@@ -61,8 +61,17 @@ public class PortalDocumentsService {continue;}String path = asString(data.get("path"));- String source = sourceLabel(asString(data.get("__origin")));- String product = "API integration".equals(source) ? "API" : "Editor";+ // Pipeline steps run over an internal loopback (API-key auth), so origin alone reads as+ // "API". The automation marker distinguishes a policy-run step from real API traffic.+ boolean automation = isAutomation(data);+ String policyName = asString(data.get("policyName"));+ String source =+ automation+ ? (policyName != null && !policyName.isBlank()+ ? "Policy: " + policyName+ : "Policy automation")+ : sourceLabel(asString(data.get("__origin")));+ String product = automation ? "Automation" : productLabel(source);String action = prettyTool(path);boolean failed = isFailure(data);Instant ts = event.timestamp();@@ -174,6 +183,15 @@ public class PortalDocumentsService {return "Web upload";}+ private static String productLabel(String source) {+ return "API integration".equals(source) ? "API" : "Editor";+ }++ private static boolean isAutomation(Map<String, Object> data) {+ Object v = data.get("automation");+ return Boolean.TRUE.equals(v) || "true".equalsIgnoreCase(String.valueOf(v));+ }+private static String docType(String contentType, String name) {String ct = contentType == null ? "" : contentType.toLowerCase(Locale.ROOT);if (ct.contains("pdf") || name.toLowerCase(Locale.ROOT).endsWith(".pdf")) {diff --git a/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalInfraAuditService.java b/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalInfraAuditService.javaindex 73d45800a8..c47df3649f 100644--- a/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalInfraAuditService.java+++ b/app/proprietary/src/main/java/stirling/software/proprietary/service/PortalInfraAuditService.java@@ -54,6 +54,7 @@ public class PortalInfraAuditService {.limit(RETURN_LIMIT).toList();+ int policy = (int) events.stream().filter(e -> "policy".equals(e.getCategory())).count();int processing =(int) events.stream().filter(e -> "processing".equals(e.getCategory())).count();int elevation =@@ -63,6 +64,7 @@ public class PortalInfraAuditService {InfraAuditSummary summary =InfraAuditSummary.builder().totalEvents(events.size())+ .policy(policy).processing(processing).elevation(elevation).config(config)@@ -84,20 +86,32 @@ public class PortalInfraAuditService {private InfraAuditEventDto toDto(PortalAuditEventRow event) {Map<String, Object> data = parseData(event);String path = asString(data.get("path"));- String category = categoryFor(event.type(), path);+ String policyName = asString(data.get("policyName"));+ boolean automation = isAutomation(data);+ // Classify a dispatch by its real run-path URI, not a policyName: the latter can be spoofed+ // via the X-Stirling-Policy-Name header to make a direct call pose as a policy row.+ boolean policyDispatch = isPolicyRunPath(path) && !automation;+ // A dispatch is its own "policy" category so the UI badges it as a policy run, not a+ // generic processing op; its internal steps keep their real tool category.+ String category = policyDispatch ? "policy" : categoryFor(event.type(), path);return InfraAuditEventDto.builder().id(String.valueOf(event.id())).timestamp(event.timestamp() == null ? "" : TS_FORMAT.format(event.timestamp())).category(category)- .action(actionFor(event.type(), path))+ .action(actionFor(event.type(), path, policyName, automation)).actor(event.principal())- .target(targetFor(category, path, data))+ .target(targetFor(category, path, data, policyDispatch)).status(statusFor(event.type(), category, data)).latencyMs(asLong(data.get("latencyMs"))).build();}+ private static boolean isAutomation(Map<String, Object> data) {+ Object v = data.get("automation");+ return Boolean.TRUE.equals(v) || "true".equalsIgnoreCase(String.valueOf(v));+ }+private Map<String, Object> parseData(PortalAuditEventRow event) {if (event.data() == null || event.data().isEmpty()) {return Map.of();@@ -140,7 +154,37 @@ public class PortalInfraAuditService {|| p.contains("redact");}- private static String actionFor(String type, String path) {+ /**+ * Label for a row. A genuine policy dispatch (a {@code /policies/.../run} request) shows the+ * policy it ran; an internal pipeline step (automation marker) is flagged so it isn't read as a+ * direct action. The name is only shown as the action on a real run URI, so a spoofed+ * X-Stirling-Policy-Name header on a direct tool call can't overwrite its true action.+ */+ private static String actionFor(+ String type, String path, String policyName, boolean automation) {+ if (!automation && isPolicyRunPath(path)) {+ // A run with no name (ad-hoc pipeline) still reads better than the "run" endpoint.+ return policyName != null ? policyName : "Policy run";+ }+ String base = baseActionFor(type, path);+ if (automation) {+ return policyName != null+ ? base + " (policy: " + policyName + ")"+ : base + " (automation)";+ }+ return base;+ }++ /**+ * The pipeline-run endpoints: {@code /policies/run}, {@code /run/stream}, {@code /{id}/run}.+ */+ private static boolean isPolicyRunPath(String path) {+ return path != null+ && path.contains("/policies/")+ && (path.endsWith("/run") || path.endsWith("/run/stream"));+ }++ private static String baseActionFor(String type, String path) {AuditEventType t = AuditEventType.fromString(type);if (t == null) {return prettyTool(path);@@ -191,7 +235,32 @@ public class PortalInfraAuditService {return sb.isEmpty() ? "PDF operation" : sb.toString();}- private static String targetFor(String category, String path, Map<String, Object> data) {+ /** "Auto Redact, Compress PDF" from the run's step endpoints; first three, then "+N more". */+ private static String prettyStepList(Object steps) {+ if (!(steps instanceof List<?> list) || list.isEmpty()) {+ return null;+ }+ int shown = Math.min(3, list.size());+ StringBuilder sb = new StringBuilder();+ for (int i = 0; i < shown; i++) {+ if (i > 0) {+ sb.append(", ");+ }+ sb.append(prettyTool(asString(list.get(i))));+ }+ if (list.size() > shown) {+ sb.append(" +").append(list.size() - shown).append(" more");+ }+ return sb.toString();+ }++ private static String targetFor(+ String category, String path, Map<String, Object> data, boolean policyDispatch) {+ if (policyDispatch) {+ // The run touches no single file at this level; show the tools the policy runs instead.+ String steps = prettyStepList(data.get("policySteps"));+ return steps != null ? steps : "Pipeline";+ }if ("auth".equals(category)) {// Auth events don't act on a resource; the session is the closest thing.return "Web session";diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/service/AuditServiceTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/service/AuditServiceTest.javaindex a90fde6b85..c2d14d1307 100644--- a/app/proprietary/src/test/java/stirling/software/proprietary/service/AuditServiceTest.java+++ b/app/proprietary/src/test/java/stirling/software/proprietary/service/AuditServiceTest.java@@ -36,6 +36,7 @@ import jakarta.servlet.http.HttpServletResponse;import stirling.software.common.model.ApplicationProperties;import stirling.software.common.service.CustomPDFDocumentFactory;import stirling.software.common.service.InternalApiClient;+import stirling.software.proprietary.audit.AuditContext;import stirling.software.proprietary.audit.AuditEventType;import stirling.software.proprietary.audit.AuditLevel;import stirling.software.proprietary.audit.Audited;@@ -718,6 +719,57 @@ class AuditServiceTest {}}+ @Nested+ @DisplayName("addAutomationContext")+ class AddAutomationContext {++ @Test+ @DisplayName("caps and strips newlines from a spoofable policy-name header")+ void capsPolicyNameHeader() {+ MockHttpServletRequest req =+ new MockHttpServletRequest("POST", "/api/v1/misc/compress-pdf");+ req.addHeader(InternalApiClient.POLICY_NAME_HEADER, "evil\r\nname" + "x".repeat(500));+ Map<String, Object> data = new HashMap<>();++ service.addAutomationContext(data, req);++ String stored = (String) data.get("policyName");+ assertThat(stored).hasSize(200);+ assertThat(stored).doesNotContain("\r").doesNotContain("\n");+ }++ @Test+ @DisplayName("caps the number of persisted policy steps")+ void capsPolicySteps() {+ MockHttpServletRequest req = new MockHttpServletRequest("POST", "/api/v1/policies/run");+ req.setAttribute(+ AuditContext.REQ_ATTR_POLICY_STEPS,+ java.util.stream.IntStream.range(0, 100)+ .mapToObj(i -> "/api/v1/misc/step-" + i)+ .toList());+ Map<String, Object> data = new HashMap<>();++ service.addAutomationContext(data, req);++ @SuppressWarnings("unchecked")+ java.util.List<String> stored = (java.util.List<String>) data.get("policySteps");+ assertThat(stored).hasSize(50);+ }++ @Test+ @DisplayName("marks automation from the header")+ void marksAutomationHeader() {+ MockHttpServletRequest req =+ new MockHttpServletRequest("POST", "/api/v1/misc/compress-pdf");+ req.addHeader(InternalApiClient.AUTOMATION_HEADER, "true");+ Map<String, Object> data = new HashMap<>();++ service.addAutomationContext(data, req);++ assertThat(data).containsEntry("automation", Boolean.TRUE);+ }+ }+// ===== helpers =====private ProceedingJoinPoint joinPoint() {diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalAuditReadServiceTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalAuditReadServiceTest.javanew file mode 100644index 0000000000..b357fbc2e3--- /dev/null+++ b/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalAuditReadServiceTest.java@@ -0,0 +1,73 @@+package stirling.software.proprietary.service;++import static org.assertj.core.api.Assertions.assertThat;+import static org.mockito.ArgumentMatchers.any;+import static org.mockito.ArgumentMatchers.anyList;+import static org.mockito.Mockito.never;+import static org.mockito.Mockito.verify;+import static org.mockito.Mockito.when;++import java.util.List;++import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.ExtendWith;+import org.mockito.ArgumentCaptor;+import org.mockito.InjectMocks;+import org.mockito.Mock;+import org.mockito.junit.jupiter.MockitoExtension;+import org.springframework.data.domain.Page;+import org.springframework.data.domain.PageImpl;+import org.springframework.data.domain.Pageable;++import stirling.software.proprietary.model.security.PersistentAuditEvent;+import stirling.software.proprietary.repository.PersistentAuditEventRepository;++/**+ * The scan must drop read/polling noise (UI_DATA/HTTP_REQUEST) at the query level. Otherwise a busy+ * scope's recent rows fill with noise and the visible audit list shrinks as traffic grows.+ */+@ExtendWith(MockitoExtension.class)+class PortalAuditReadServiceTest {++ @Mock private PersistentAuditEventRepository repo;++ @InjectMocks private PortalAuditReadService service;++ private static Page<PersistentAuditEvent> emptyPage() {+ return new PageImpl<>(List.of());+ }++ @Test+ void serverScanExcludesReadNoiseAndNeverPullsEverything() {+ when(repo.findByTypeNotIn(anyList(), any(Pageable.class))).thenReturn(emptyPage());++ service.serverEvents();++ @SuppressWarnings("unchecked")+ ArgumentCaptor<List<String>> excluded = ArgumentCaptor.forClass(List.class);+ verify(repo).findByTypeNotIn(excluded.capture(), any(Pageable.class));+ assertThat(excluded.getValue()).contains("UI_DATA", "HTTP_REQUEST");+ verify(repo, never()).findAll(any(Pageable.class));+ }++ @Test+ void teamScanExcludesReadNoiseForTheTeamPrincipals() {+ when(repo.findByTypeNotInAndPrincipalIn(anyList(), anyList(), any(Pageable.class)))+ .thenReturn(emptyPage());++ service.scopedEvents("team:1", List.of("[email protected]", "[email protected]"));++ @SuppressWarnings("unchecked")+ ArgumentCaptor<List<String>> excluded = ArgumentCaptor.forClass(List.class);+ verify(repo)+ .findByTypeNotInAndPrincipalIn(excluded.capture(), anyList(), any(Pageable.class));+ assertThat(excluded.getValue()).contains("UI_DATA", "HTTP_REQUEST");+ }++ @Test+ void emptyTeamPrincipalsShortCircuitToNoQuery() {+ assertThat(service.scopedEvents("team:1", List.of())).isEmpty();+ verify(repo, never())+ .findByTypeNotInAndPrincipalIn(anyList(), anyList(), any(Pageable.class));+ }+}diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalDocumentsServiceTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalDocumentsServiceTest.javanew file mode 100644index 0000000000..1afc0af4a4--- /dev/null+++ b/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalDocumentsServiceTest.java@@ -0,0 +1,73 @@+package stirling.software.proprietary.service;++import static org.assertj.core.api.Assertions.assertThat;+import static org.mockito.Mockito.when;++import java.time.Instant;+import java.util.List;++import org.junit.jupiter.api.BeforeEach;+import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.ExtendWith;+import org.mockito.Mock;+import org.mockito.junit.jupiter.MockitoExtension;++import stirling.software.proprietary.audit.AuditEventType;+import stirling.software.proprietary.audit.PortalAuditEventRow;+import stirling.software.proprietary.model.api.documents.PortalReviewDocumentDto;++import tools.jackson.databind.json.JsonMapper;++/**+ * The Documents feed showed a policy run's internal steps as ordinary "API" traffic. They should+ * read as automation so a policy run isn't confused with a customer's own API integration.+ */+@ExtendWith(MockitoExtension.class)+class PortalDocumentsServiceTest {++ @Mock private PortalAuditReadService auditReadService;++ private PortalDocumentsService service;++ @BeforeEach+ void setUp() {+ service = new PortalDocumentsService(auditReadService, JsonMapper.builder().build());+ }++ private static PortalAuditEventRow row(long id, String data) {+ return new PortalAuditEventRow(+ id, "[email protected]", AuditEventType.PDF_PROCESS.name(), data, Instant.now());+ }++ private PortalReviewDocumentDto onlyDoc(String data) {+ when(auditReadService.serverEvents()).thenReturn(List.of(row(1L, data)));+ return service.serverDocuments().getDocuments().get(0);+ }++ @Test+ void policyStepDocumentIsLabelledAutomation() {+ PortalReviewDocumentDto doc =+ onlyDoc(+ "{\"path\":\"/api/v1/security/auto-redact\",\"automation\":true,"+ + "\"__origin\":\"API\",\"files\":[{\"name\":\"mushroom life.pdf\","+ + "\"type\":\"application/pdf\"}],\"statusCode\":200}");++ assertThat(doc.getName()).isEqualTo("mushroom life.pdf");+ assertThat(doc.getAction()).isEqualTo("Auto Redact");+ // Was product "API" (loopback used the API key); now clearly a policy automation step.+ assertThat(doc.getProduct()).isEqualTo("Automation");+ assertThat(doc.getSource()).isEqualTo("Policy automation");+ }++ @Test+ void directApiDocumentStaysApi() {+ PortalReviewDocumentDto doc =+ onlyDoc(+ "{\"path\":\"/api/v1/misc/compress-pdf\",\"__origin\":\"API\","+ + "\"files\":[{\"name\":\"a.pdf\",\"type\":\"application/pdf\"}],"+ + "\"statusCode\":200}");++ assertThat(doc.getProduct()).isEqualTo("API");+ assertThat(doc.getSource()).isEqualTo("API integration");+ }+}diff --git a/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalInfraAuditServiceTest.java b/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalInfraAuditServiceTest.javanew file mode 100644index 0000000000..8d225367f3--- /dev/null+++ b/app/proprietary/src/test/java/stirling/software/proprietary/service/PortalInfraAuditServiceTest.java@@ -0,0 +1,149 @@+package stirling.software.proprietary.service;++import static org.assertj.core.api.Assertions.assertThat;+import static org.mockito.Mockito.when;++import java.time.Instant;+import java.util.List;++import org.junit.jupiter.api.BeforeEach;+import org.junit.jupiter.api.Test;+import org.junit.jupiter.api.extension.ExtendWith;+import org.mockito.Mock;+import org.mockito.junit.jupiter.MockitoExtension;++import stirling.software.proprietary.audit.AuditEventType;+import stirling.software.proprietary.audit.PortalAuditEventRow;+import stirling.software.proprietary.model.api.audit.InfraAuditEventDto;++import tools.jackson.databind.json.JsonMapper;++/**+ * The Infrastructure → Audit tab reproduces the reported bug: a policy run showed as a bare "Run"+ * row plus a separate "Auto Redact" row with no hint either belonged to a policy.+ */+@ExtendWith(MockitoExtension.class)+class PortalInfraAuditServiceTest {++ @Mock private PortalAuditReadService auditReadService;++ private PortalInfraAuditService service;++ @BeforeEach+ void setUp() {+ service = new PortalInfraAuditService(auditReadService, JsonMapper.builder().build());+ }++ private static PortalAuditEventRow row(long id, String data) {+ return new PortalAuditEventRow(+ id,+ "[email protected]",+ AuditEventType.PDF_PROCESS.name(),+ data,+ Instant.parse("2026-07-09T10:18:24Z"));+ }++ private InfraAuditEventDto onlyEvent(String data) {+ when(auditReadService.serverEvents()).thenReturn(List.of(row(1L, data)));+ return service.serverAuditLog().getEvents().get(0);+ }++ @Test+ void policyDispatchShowsPolicyNameAndTheToolsItRuns() {+ String data =+ "{\"path\":\"/api/v1/policies/run\",\"policyName\":\"Redaction\","+ + "\"policySteps\":[\"/api/v1/security/auto-redact\","+ + "\"/api/v1/misc/compress-pdf\"],\"statusCode\":202,"+ + "\"latencyMs\":5}";+ when(auditReadService.serverEvents()).thenReturn(List.of(row(1L, data)));++ var resp = service.serverAuditLog();+ InfraAuditEventDto e = resp.getEvents().get(0);++ // Was "Run" / "Run" under "processing"; now names the policy, lists what it ran, and+ // badges as its own "policy" category with its own summary count.+ assertThat(e.getAction()).isEqualTo("Redaction");+ assertThat(e.getCategory()).isEqualTo("policy");+ assertThat(e.getTarget()).isEqualTo("Auto Redact, Compress PDF");+ assertThat(resp.getSummary().getPolicy()).isEqualTo(1);+ }++ @Test+ void internalPipelineStepIsFlaggedAsAutomation() {+ InfraAuditEventDto e =+ onlyEvent(+ "{\"path\":\"/api/v1/security/auto-redact\",\"automation\":true,"+ + "\"files\":[{\"name\":\"mushroom life.pdf\"}],"+ + "\"statusCode\":200,\"latencyMs\":300}");++ // Was a bare "Auto Redact" indistinguishable from a direct user action.+ assertThat(e.getAction()).isEqualTo("Auto Redact (automation)");+ assertThat(e.getCategory()).isEqualTo("security");+ assertThat(e.getTarget()).isEqualTo("mushroom life.pdf");+ }++ @Test+ void internalStepCarryingItsPolicyNameLinksBackToThePolicy() {+ InfraAuditEventDto e =+ onlyEvent(+ "{\"path\":\"/api/v1/security/auto-redact\",\"automation\":true,"+ + "\"policyName\":\"Redaction demo\",\"files\":[{\"name\":"+ + "\"demo.pdf\"}],\"statusCode\":200}");++ // The forwarded policy name makes the step's origin unmistakable.+ assertThat(e.getAction()).isEqualTo("Auto Redact (policy: Redaction demo)");+ assertThat(e.getCategory()).isEqualTo("security");+ assertThat(e.getTarget()).isEqualTo("demo.pdf");+ }++ @Test+ void adHocRunWithoutNameStillReadsAsPolicyRun() {+ InfraAuditEventDto e =+ onlyEvent(+ "{\"path\":\"/api/v1/policies/run/stream\",\"statusCode\":200,"+ + "\"latencyMs\":4}");++ assertThat(e.getAction()).isEqualTo("Policy run");+ assertThat(e.getTarget()).isEqualTo("Pipeline");+ }++ @Test+ void directToolRunIsUnchanged() {+ InfraAuditEventDto e =+ onlyEvent(+ "{\"path\":\"/api/v1/misc/compress-pdf\","+ + "\"files\":[{\"name\":\"a.pdf\"}],\"statusCode\":200,"+ + "\"latencyMs\":100}");++ assertThat(e.getAction()).isEqualTo("Compress PDF");+ assertThat(e.getCategory()).isEqualTo("processing");+ assertThat(e.getTarget()).isEqualTo("a.pdf");+ }++ /**+ * A spoofed X-Stirling-Policy-Name header lands in audit data as policyName on a direct tool+ * call (no automation marker, non-run path). It must NOT flip the row into a "policy" dispatch+ * that overwrites the real action and hides the affected file - only a real /policies/.../run+ * URI does that.+ */+ @Test+ void forgedPolicyNameOnDirectCallCannotMaskTheRealAction() {+ when(auditReadService.serverEvents())+ .thenReturn(+ List.of(+ row(+ 1L,+ "{\"path\":\"/api/v1/security/remove-password\","+ + "\"policyName\":\"Daily cleanup\",\"files\":"+ + "[{\"name\":\"secret.pdf\"}],\"statusCode\":200}")));++ var resp = service.serverAuditLog();+ InfraAuditEventDto e = resp.getEvents().get(0);++ // Real op and file stay visible; the forged name does not become the action or category.+ assertThat(e.getAction()).isEqualTo("Remove Password");+ assertThat(e.getCategory()).isEqualTo("security");+ assertThat(e.getTarget()).isEqualTo("secret.pdf");+ assertThat(resp.getSummary().getPolicy()).isEqualTo(0);+ }+}diff --git a/frontend/editor/public/locales/en-US/translation.toml b/frontend/editor/public/locales/en-US/translation.tomlindex d323a5a5f9..ac1ab2c9e7 100644--- a/frontend/editor/public/locales/en-US/translation.toml+++ b/frontend/editor/public/locales/en-US/translation.toml@@ -6955,6 +6955,7 @@ all = "All"auth = "Auth"config = "Config"elevation = "Elevation"+policy = "Policy"processing = "Processing"security = "Security"@@ -6964,7 +6965,7 @@ title = "You don't have access"[portal.infrastructure.audit.metrics]config = "Config"-elevation = "Elevation"+policy = "Policy"processing = "Processing"totalEvents = "Total events · 24h"@@ -6972,6 +6973,7 @@ totalEvents = "Total events · 24h"auth = "Auth"config = "Config"elevation = "Elevation"+policy = "Policy"processing = "Processing"security = "Security"diff --git a/frontend/editor/src/portal/api/documents.ts b/frontend/editor/src/portal/api/documents.tsindex cbb109ec30..9e75f40ec7 100644--- a/frontend/editor/src/portal/api/documents.ts+++ b/frontend/editor/src/portal/api/documents.ts@@ -4,8 +4,8 @@ import type { Tier } from "@portal/contexts/TierContext";export type DocumentStatus = "processed" | "flagged" | "in-review" | "error";-/** Which Stirling product ran the operation. */-export type ProductType = "API" | "Editor";+/** Which Stirling product ran the operation. "Automation" = a policy/pipeline run's tool step. */+export type ProductType = "API" | "Editor" | "Automation";/** A single field pulled out of the document by extraction. */export interface Extraction {@@ -98,6 +98,7 @@ export const DOCUMENT_STATUS_TONE: Record<DocumentStatus, StatusTone> = {export const PRODUCT_CHIP_TONE: Record<ProductType, ChipAccent> = {API: "brand",Editor: "success",+ Automation: "warning",};/** Classification chip accent: danger when unclassified, warning when it needs a look. */diff --git a/frontend/editor/src/portal/api/infrastructure.ts b/frontend/editor/src/portal/api/infrastructure.tsindex 073409e6c6..d624f67e03 100644--- a/frontend/editor/src/portal/api/infrastructure.ts+++ b/frontend/editor/src/portal/api/infrastructure.ts@@ -169,6 +169,7 @@ export type AuditCategory =| "auth"| "config"| "elevation"+ | "policy"| "processing"| "security";@@ -187,6 +188,7 @@ export interface AuditEvent {export interface AuditSummary {totalEvents: number;+ policy: number;processing: number;elevation: number;config: number;diff --git a/frontend/editor/src/portal/components/infrastructure/AuditTab.tsx b/frontend/editor/src/portal/components/infrastructure/AuditTab.tsxindex 07bff185da..b27d57995e 100644--- a/frontend/editor/src/portal/components/infrastructure/AuditTab.tsx+++ b/frontend/editor/src/portal/components/infrastructure/AuditTab.tsx@@ -46,6 +46,7 @@ export function AuditTab() {key: "elevation",label: t("portal.infrastructure.audit.filters.elevation"),},+ { key: "policy", label: t("portal.infrastructure.audit.filters.policy") },{key: "processing",label: t("portal.infrastructure.audit.filters.processing"),@@ -146,12 +147,12 @@ export function AuditTab() {value={data.summary.totalEvents.toLocaleString()}/><MetricCard- label={t("portal.infrastructure.audit.metrics.processing")}- value={data.summary.processing.toLocaleString()}+ label={t("portal.infrastructure.audit.metrics.policy")}+ value={data.summary.policy.toLocaleString()}/><MetricCard- label={t("portal.infrastructure.audit.metrics.elevation")}- value={data.summary.elevation.toLocaleString()}+ label={t("portal.infrastructure.audit.metrics.processing")}+ value={data.summary.processing.toLocaleString()}/><MetricCardlabel={t("portal.infrastructure.audit.metrics.config")}diff --git a/frontend/editor/src/portal/components/infrastructure/infraFormat.ts b/frontend/editor/src/portal/components/infrastructure/infraFormat.tsindex 975a3a61e4..8771712ecb 100644--- a/frontend/editor/src/portal/components/infrastructure/infraFormat.ts+++ b/frontend/editor/src/portal/components/infrastructure/infraFormat.ts@@ -121,6 +121,7 @@ export const AUDIT_CAT_LABEL: Record<AuditCategory, string> = {auth: "portal.infrastructure.auditCatLabel.auth",config: "portal.infrastructure.auditCatLabel.config",elevation: "portal.infrastructure.auditCatLabel.elevation",+ policy: "portal.infrastructure.auditCatLabel.policy",processing: "portal.infrastructure.auditCatLabel.processing",security: "portal.infrastructure.auditCatLabel.security",};@@ -129,6 +130,7 @@ export const AUDIT_CAT_TONE: Record<AuditCategory, StatusTone> = {auth: "info",config: "neutral",elevation: "purple",+ policy: "purple",processing: "success",security: "warning",};diff --git a/frontend/editor/src/portal/mocks/infrastructure.ts b/frontend/editor/src/portal/mocks/infrastructure.tsindex 85aac3eeea..412e6133bf 100644--- a/frontend/editor/src/portal/mocks/infrastructure.ts+++ b/frontend/editor/src/portal/mocks/infrastructure.ts@@ -901,6 +901,7 @@ export function auditLogFor(tier: Tier): AuditLogResponse {// (PortalInfraAuditService) computes it - so mocks and real data reconcile.const summary: AuditSummary = {totalEvents: events.length,+ policy: events.filter((e) => e.category === "policy").length,processing: events.filter((e) => e.category === "processing").length,elevation: events.filter((e) => e.category === "elevation").length,config: events.filter((e) => e.category === "config").length,