You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ho...@apache.org on 2026/10/22 07:40:27 UTC
(streampipes) branch add_audit_logging_pipeline created (now 03df595f16)
This is an automated email from the ASF dual-hosted git repository.
JHoelli pushed a change to branch add_audit_logging_pipeline
in repository https://gitbox.apache.org/repos/asf/streampipes.git
at 03df595f16 feat: add pipeline audit event tracking
This branch includes the following new commits:
new abe8e5e663 Merge branch 'dev' into add_audit_logging_pipeline
new 03df595f16 feat: add pipeline audit event tracking
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(streampipes) 01/02: Merge branch 'dev' into add_audit_logging_pipeline
Posted by ho...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
JHoelli pushed a commit to branch add_audit_logging_pipeline
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit abe8e5e663b6c48784d37fcd944e698bfc644e90
Merge: 873fe4b347 c4fd926352
Author: Jacqueline Höllig <j....@gmx.net>
AuthorDate: Thu Oct 22 08:36:29 2026 +0200
Merge branch 'dev' into add_audit_logging_pipeline
.../deploy/standalone/ui-custom-conf/default.conf | 15 ++
streampipes-messaging-nats/pom.xml | 4 +
streampipes-nats-extensions/pom.xml | 4 +
ui/deployment/i18n/de.json | 2 +
ui/deployment/i18n/en.json | 2 +
ui/deployment/i18n/pl.json | 2 +
ui/nginx_config/default.conf | 15 ++
ui/nginx_config/default.conf.template | 15 ++
ui/nginx_config/ssl.conf | 15 ++
ui/package.json | 2 +
.../src/lib/services/ui-update.service.spec.ts | 180 +++++++++++++++++++++
.../src/lib/services/ui-update.service.ts | 170 +++++++++++++++++++
.../streampipes/shared-ui/src/public-api.ts | 2 +
ui/scripts/write-build-version.cjs | 54 +++++++
ui/scripts/write-build-version.test.cjs | 81 ++++++++++
ui/src/app/app.component.ts | 3 +
16 files changed, 566 insertions(+)
(streampipes) 02/02: feat: add pipeline audit event tracking
Posted by ho...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
JHoelli pushed a commit to branch add_audit_logging_pipeline
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 03df595f1651eb04e95525af1511da3c5edada4c
Author: Jacqueline Höllig <j....@gmx.net>
AuthorDate: Thu Oct 22 09:40:05 2026 +0200
feat: add pipeline audit event tracking
---
.../audit/events/StandardAuditEvents.java | 16 +++-
.../events/pipeline/PipelineAuditRecorder.java | 54 +++++++++++
.../events/pipeline/PipelineCreatedDetails.java | 25 +++++
.../events/pipeline/PipelineEditedDetails.java | 30 ++++++
.../events/pipeline/PipelineLifecycleDetails.java | 24 +++++
streampipes-pipeline-management/pom.xml | 5 +
.../manager/pipeline/PipelineManager.java | 68 ++++++++++++--
.../pipeline/PipelineLifecycleAuditTest.java | 103 +++++++++++++++++++++
.../rest/impl/CompactPipelineResource.java | 3 +-
.../streampipes/rest/impl/PipelineResource.java | 24 ++++-
10 files changed, 337 insertions(+), 15 deletions(-)
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
index 77be74032a..37678d9a20 100644
--- a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/StandardAuditEvents.java
@@ -24,6 +24,9 @@ import org.apache.streampipes.audit.events.adapter.AdapterCreatedDetails;
import org.apache.streampipes.audit.events.adapter.AdapterEditedDetails;
import org.apache.streampipes.audit.events.adapter.AdapterLifecycleDetails;
import org.apache.streampipes.audit.events.authentication.AuthenticationDetails;
+import org.apache.streampipes.audit.events.pipeline.PipelineCreatedDetails;
+import org.apache.streampipes.audit.events.pipeline.PipelineEditedDetails;
+import org.apache.streampipes.audit.events.pipeline.PipelineLifecycleDetails;
import java.util.List;
@@ -38,6 +41,15 @@ public final class StandardAuditEvents implements AuditEventProvider {
public static final AuditEventDefinition<AdapterEditedDetails> ADAPTER_EDIT =
new AuditEventDefinition<>("sp.adapter.edit", AdapterEditedDetails.class, "adapter");
+ public static final AuditEventDefinition<PipelineCreatedDetails> PIPELINE_CREATE =
+ new AuditEventDefinition<>("sp.pipeline.create", PipelineCreatedDetails.class, "pipeline");
+ public static final AuditEventDefinition<PipelineLifecycleDetails> PIPELINE_START =
+ new AuditEventDefinition<>("sp.pipeline.start", PipelineLifecycleDetails.class, "pipeline");
+ public static final AuditEventDefinition<PipelineLifecycleDetails> PIPELINE_STOP =
+ new AuditEventDefinition<>("sp.pipeline.stop", PipelineLifecycleDetails.class, "pipeline");
+ public static final AuditEventDefinition<PipelineEditedDetails> PIPELINE_EDIT =
+ new AuditEventDefinition<>("sp.pipeline.edit", PipelineEditedDetails.class, "pipeline");
+
public static final AuditEventDefinition<AuthenticationDetails> AUTH_LOGIN =
new AuditEventDefinition<>("sp.auth.login", AuthenticationDetails.class);
public static final AuditEventDefinition<AuthenticationDetails> AUTH_LOGOUT =
@@ -45,7 +57,9 @@ public final class StandardAuditEvents implements AuditEventProvider {
private static final List<AuditEventDefinition<?>> EVENT_TYPES = List.of(
- ADAPTER_CREATE, ADAPTER_START, ADAPTER_STOP, ADAPTER_EDIT, AUTH_LOGIN, AUTH_LOGOUT);
+ ADAPTER_CREATE, ADAPTER_START, ADAPTER_STOP, ADAPTER_EDIT,
+ PIPELINE_CREATE, PIPELINE_START, PIPELINE_STOP, PIPELINE_EDIT,
+ AUTH_LOGIN, AUTH_LOGOUT);
@Override
public List<AuditEventDefinition<?>> eventTypes() {
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineAuditRecorder.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineAuditRecorder.java
new file mode 100644
index 0000000000..2d5fac17e4
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineAuditRecorder.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.pipeline;
+
+import org.apache.streampipes.audit.api.AuditOutcome;
+import org.apache.streampipes.audit.api.AuditService;
+import org.apache.streampipes.audit.events.StandardAuditEvents;
+
+import java.util.Objects;
+
+/** Pipeline audit publication and safe payload construction; outcomes are decided by the operation. */
+public final class PipelineAuditRecorder {
+ private final AuditService auditService;
+
+ public PipelineAuditRecorder(AuditService auditService) {
+ this.auditService = Objects.requireNonNull(auditService);
+ }
+
+ public void created(String actor, String pipelineId, AuditOutcome outcome) {
+ auditService.record(StandardAuditEvents.PIPELINE_CREATE, outcome, actor, pipelineId,
+ new PipelineCreatedDetails());
+ }
+
+ public void started(String actor, String pipelineId, AuditOutcome outcome) {
+ auditService.record(StandardAuditEvents.PIPELINE_START, outcome, actor, pipelineId, null);
+ }
+
+ public void stopped(String actor, String pipelineId, AuditOutcome outcome, boolean forced) {
+ auditService.record(StandardAuditEvents.PIPELINE_STOP, outcome, actor, pipelineId,
+ new PipelineLifecycleDetails(forced));
+ }
+
+ public void edited(String actor, String pipelineId, AuditOutcome outcome, PipelineEditedDetails details) {
+ if (details == null || !details.changes().isEmpty()) {
+ auditService.record(StandardAuditEvents.PIPELINE_EDIT, outcome, actor, pipelineId, details);
+ }
+ }
+}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineCreatedDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineCreatedDetails.java
new file mode 100644
index 0000000000..addef1e9a6
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineCreatedDetails.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.pipeline;
+
+import org.apache.streampipes.audit.api.AuditDetails;
+
+/** The pipeline ID is stored in the audit event envelope; no pipeline configuration is retained. */
+public record PipelineCreatedDetails() implements AuditDetails {
+}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineEditedDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineEditedDetails.java
new file mode 100644
index 0000000000..d4c538f49f
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineEditedDetails.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.pipeline;
+
+import org.apache.streampipes.audit.api.AuditDetails;
+import org.apache.streampipes.audit.events.AuditChange;
+
+import java.util.List;
+
+public record PipelineEditedDetails(List<AuditChange> changes) implements AuditDetails {
+ public PipelineEditedDetails {
+ changes = List.copyOf(changes);
+ }
+}
diff --git a/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineLifecycleDetails.java b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineLifecycleDetails.java
new file mode 100644
index 0000000000..660a36eeb2
--- /dev/null
+++ b/streampipes-audit-events/src/main/java/org/apache/streampipes/audit/events/pipeline/PipelineLifecycleDetails.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.audit.events.pipeline;
+
+import org.apache.streampipes.audit.api.AuditDetails;
+
+public record PipelineLifecycleDetails(boolean forced) implements AuditDetails {
+}
diff --git a/streampipes-pipeline-management/pom.xml b/streampipes-pipeline-management/pom.xml
index 4f9f0b82e3..102d8bce91 100644
--- a/streampipes-pipeline-management/pom.xml
+++ b/streampipes-pipeline-management/pom.xml
@@ -27,6 +27,11 @@
<artifactId>streampipes-pipeline-management</artifactId>
<dependencies>
+ <dependency>
+ <groupId>org.apache.streampipes</groupId>
+ <artifactId>streampipes-audit-events</artifactId>
+ <version>0.99.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.streampipes</groupId>
<artifactId>streampipes-commons</artifactId>
diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java
index b033705414..12a266f4a9 100644
--- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java
+++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/pipeline/PipelineManager.java
@@ -18,6 +18,9 @@
package org.apache.streampipes.manager.pipeline;
+import org.apache.streampipes.audit.api.AuditOutcome;
+import org.apache.streampipes.audit.api.AuditService;
+import org.apache.streampipes.audit.events.pipeline.PipelineAuditRecorder;
import org.apache.streampipes.commons.random.UUIDGenerator;
import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestManager;
import org.apache.streampipes.manager.execution.PipelineExecutor;
@@ -42,10 +45,12 @@ public class PipelineManager {
private final SpResourceManager resourceManager;
private final IPipelineStorage pipelineStorage;
+ private final PipelineAuditRecorder pipelineAudit;
public PipelineManager(SpResourceManager resourceManager) {
this.pipelineStorage = resourceManager.managePipelines().getDb();
this.resourceManager = resourceManager;
+ this.pipelineAudit = new PipelineAuditRecorder(auditService(resourceManager));
}
/**
@@ -82,13 +87,19 @@ public class PipelineManager {
String pipelineId = Objects.isNull(pipeline.getPipelineId())
? UUIDGenerator.generateUuid()
: pipeline.getPipelineId();
- preparePipelineBasics(principalSid, pipeline, pipelineId);
- new PipelineStorageService(pipelineStorage, pipeline).addPipeline();
-
- Permission permission = new PermissionManager().makePermission(pipeline, principalSid);
- resourceManager.managePermissions().create(permission);
-
- return pipelineId;
+ try {
+ preparePipelineBasics(principalSid, pipeline, pipelineId);
+ new PipelineStorageService(pipelineStorage, pipeline).addPipeline();
+
+ Permission permission = new PermissionManager().makePermission(pipeline, principalSid);
+ resourceManager.managePermissions().create(permission);
+
+ pipelineAudit.created(principalSid, pipelineId, AuditOutcome.SUCCEEDED);
+ return pipelineId;
+ } catch (RuntimeException e) {
+ pipelineAudit.created(principalSid, pipelineId, AuditOutcome.FAILED);
+ throw e;
+ }
}
/**
@@ -99,8 +110,21 @@ public class PipelineManager {
*/
public PipelineOperationStatus startPipeline(String pipelineId,
ExtensionServiceRequestManager requestManager) {
+ return startPipeline(pipelineId, requestManager, null);
+ }
+
+ public PipelineOperationStatus startPipeline(String pipelineId,
+ ExtensionServiceRequestManager requestManager,
+ String actor) {
Pipeline pipeline = getPipeline(pipelineId);
- return new PipelineExecutor(pipeline, requestManager, resourceManager).startPipeline();
+ try {
+ var status = new PipelineExecutor(pipeline, requestManager, resourceManager).startPipeline();
+ pipelineAudit.started(actor, pipelineId, outcome(status));
+ return status;
+ } catch (RuntimeException e) {
+ pipelineAudit.started(actor, pipelineId, AuditOutcome.FAILED);
+ throw e;
+ }
}
/**
@@ -117,9 +141,24 @@ public class PipelineManager {
boolean forceStop,
ExtensionServiceRequestManager requestManager
) {
- Pipeline pipeline = getPipeline(pipelineId);
+ return stopPipeline(pipelineId, forceStop, requestManager, null);
+ }
- return new PipelineExecutor(pipeline, requestManager, resourceManager).stopPipeline(forceStop);
+ public PipelineOperationStatus stopPipeline(
+ String pipelineId,
+ boolean forceStop,
+ ExtensionServiceRequestManager requestManager,
+ String actor
+ ) {
+ Pipeline pipeline = getPipeline(pipelineId);
+ try {
+ var status = new PipelineExecutor(pipeline, requestManager, resourceManager).stopPipeline(forceStop);
+ pipelineAudit.stopped(actor, pipelineId, outcome(status), forceStop);
+ return status;
+ } catch (RuntimeException e) {
+ pipelineAudit.stopped(actor, pipelineId, AuditOutcome.FAILED, forceStop);
+ throw e;
+ }
}
/**
@@ -177,6 +216,15 @@ public class PipelineManager {
);
}
+ private AuditOutcome outcome(PipelineOperationStatus status) {
+ return status.isSuccess() ? AuditOutcome.SUCCEEDED : AuditOutcome.FAILED;
+ }
+
+ private AuditService auditService(SpResourceManager resourceManager) {
+ var auditService = resourceManager.getAuditService();
+ return auditService == null ? AuditService.disabled() : auditService;
+ }
+
private void preparePipelineBasics(
String username,
Pipeline pipeline,
diff --git a/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/PipelineLifecycleAuditTest.java b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/PipelineLifecycleAuditTest.java
new file mode 100644
index 0000000000..743be81d7f
--- /dev/null
+++ b/streampipes-pipeline-management/src/test/java/org/apache/streampipes/manager/pipeline/PipelineLifecycleAuditTest.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.manager.pipeline;
+
+import org.apache.streampipes.audit.api.AuditOutcome;
+import org.apache.streampipes.audit.api.AuditService;
+import org.apache.streampipes.audit.events.StandardAuditEvents;
+import org.apache.streampipes.audit.events.pipeline.PipelineLifecycleDetails;
+import org.apache.streampipes.manager.execution.PipelineExecutor;
+import org.apache.streampipes.model.pipeline.Pipeline;
+import org.apache.streampipes.model.pipeline.PipelineOperationStatus;
+import org.apache.streampipes.resource.management.PipelineResourceManager;
+import org.apache.streampipes.resource.management.SpResourceManager;
+import org.apache.streampipes.storage.api.pipeline.IPipelineStorage;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockConstruction;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class PipelineLifecycleAuditTest {
+ private final AuditService audit = mock(AuditService.class);
+ private final IPipelineStorage storage = mock(IPipelineStorage.class);
+ private final Pipeline pipeline = new Pipeline();
+
+ @Test
+ void successfulStartRecordsTheAuthenticatedActor() {
+ var status = status(true);
+ var manager = manager();
+
+ try (var executors = mockConstruction(PipelineExecutor.class,
+ (executor, context) -> when(executor.startPipeline()).thenReturn(status))) {
+ assertSame(status, manager.startPipeline("pipeline-1", null, "user-1"));
+ }
+
+ verify(audit).record(StandardAuditEvents.PIPELINE_START, AuditOutcome.SUCCEEDED,
+ "user-1", "pipeline-1", null);
+ }
+
+ @Test
+ void failedStartRecordsTheFailureBeforeRethrowing() {
+ var manager = manager();
+
+ try (var executors = mockConstruction(PipelineExecutor.class,
+ (executor, context) -> when(executor.startPipeline()).thenThrow(new IllegalStateException()))) {
+ assertThrows(IllegalStateException.class, () -> manager.startPipeline("pipeline-1", null, "user-1"));
+ }
+
+ verify(audit).record(StandardAuditEvents.PIPELINE_START, AuditOutcome.FAILED,
+ "user-1", "pipeline-1", null);
+ }
+
+ @Test
+ void forcedStopRecordsItsRequestedMode() {
+ var status = status(false);
+ var manager = manager();
+
+ try (var executors = mockConstruction(PipelineExecutor.class,
+ (executor, context) -> when(executor.stopPipeline(true)).thenReturn(status))) {
+ assertSame(status, manager.stopPipeline("pipeline-1", true, null, "user-1"));
+ }
+
+ verify(audit).record(StandardAuditEvents.PIPELINE_STOP, AuditOutcome.FAILED,
+ "user-1", "pipeline-1", new PipelineLifecycleDetails(true));
+ }
+
+ private PipelineManager manager() {
+ var resources = mock(SpResourceManager.class);
+ var pipelines = mock(PipelineResourceManager.class);
+ pipeline.setPipelineId("pipeline-1");
+ when(resources.getAuditService()).thenReturn(audit);
+ when(resources.managePipelines()).thenReturn(pipelines);
+ when(pipelines.getDb()).thenReturn(storage);
+ when(storage.getElementById("pipeline-1")).thenReturn(pipeline);
+ return new PipelineManager(resources);
+ }
+
+ private PipelineOperationStatus status(boolean success) {
+ var status = new PipelineOperationStatus();
+ status.setSuccess(success);
+ return status;
+ }
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/CompactPipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/CompactPipelineResource.java
index d346ebee6f..c447b37c81 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/CompactPipelineResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/CompactPipelineResource.java
@@ -80,7 +80,8 @@ public class CompactPipelineResource extends AbstractAuthGuardedRestResource {
String pipelineId = pipelineManager.addPipeline(getAuthenticatedUserSid(), pipelineGenerationResult.pipeline());
if (compactPipeline.createOptions().start()) {
try {
- PipelineOperationStatus status = pipelineManager.startPipeline(pipelineId, requestManager);
+ PipelineOperationStatus status = pipelineManager.startPipeline(
+ pipelineId, requestManager, getAuthenticatedUserSid());
return ok(status);
} catch (Exception e) {
return statusMessage(Notifications.error(NotificationType.UNKNOWN_ERROR));
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
index b93f016064..b6e5ab406d 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineResource.java
@@ -18,6 +18,9 @@
package org.apache.streampipes.rest.impl;
+import org.apache.streampipes.audit.api.AuditOutcome;
+import org.apache.streampipes.audit.api.AuditService;
+import org.apache.streampipes.audit.events.pipeline.PipelineAuditRecorder;
import org.apache.streampipes.commons.exceptions.NoSuitableSepasAvailableException;
import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestManager;
import org.apache.streampipes.manager.execution.status.PipelineStatusManager;
@@ -96,6 +99,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
private final PipelineManager pipelineManager;
private final DataProcessorResourceManager dataProcessorResourceManager;
private final DataSinkResourceManager dataSinkResourceManager;
+ private final PipelineAuditRecorder pipelineAudit;
private final SpResourceManager resourceManager;
private final IPipelineElementDescriptionStorage descriptionStorage;
@@ -118,6 +122,7 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
this.pipelineManager = new PipelineManager(resourceManager);
this.dataProcessorResourceManager = resourceManager.manageDataProcessors();
this.dataSinkResourceManager = resourceManager.manageDataSinks();
+ this.pipelineAudit = new PipelineAuditRecorder(auditService(resourceManager));
}
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@@ -177,7 +182,8 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
@PreAuthorize("this.hasWriteAuthority() and hasPermission(#pipelineId, 'WRITE')")
public ResponseEntity<?> start(@PathVariable("pipelineId") String pipelineId) {
try {
- PipelineOperationStatus status = pipelineManager.startPipeline(pipelineId, requestManager);
+ PipelineOperationStatus status = pipelineManager.startPipeline(
+ pipelineId, requestManager, getAuthenticatedUserSid());
return ok(status);
} catch (Exception e) {
@@ -192,7 +198,8 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
public ResponseEntity<?> stop(@PathVariable("pipelineId") String pipelineId,
@RequestParam(value = "forceStop", defaultValue = "false") boolean forceStop) {
try {
- PipelineOperationStatus status = pipelineManager.stopPipeline(pipelineId, forceStop, requestManager);
+ PipelineOperationStatus status = pipelineManager.stopPipeline(
+ pipelineId, forceStop, requestManager, getAuthenticatedUserSid());
return ok(status);
} catch (Exception e) {
LOG.error(e.getMessage());
@@ -307,7 +314,13 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
storedPipeline.setHealthStatus(pipeline.getHealthStatus());
storedPipeline.setPipelineNotifications(pipeline.getPipelineNotifications());
storedPipeline.setValid(pipeline.isValid());
- new PipelineStorageService(resourceManager.managePipelines().getDb(), storedPipeline).updatePipeline();
+ try {
+ new PipelineStorageService(resourceManager.managePipelines().getDb(), storedPipeline).updatePipeline();
+ pipelineAudit.edited(getAuthenticatedUserSid(), pipelineId, AuditOutcome.SUCCEEDED, null);
+ } catch (RuntimeException e) {
+ pipelineAudit.edited(getAuthenticatedUserSid(), pipelineId, AuditOutcome.FAILED, null);
+ throw e;
+ }
SuccessMessage message = Notifications.success("Pipeline modified");
message.addNotification(new Notification("id", pipelineId));
return ok(message);
@@ -339,4 +352,9 @@ public class PipelineResource extends AbstractAuthGuardedRestResource {
public boolean hasWriteAuthority() {
return isAdminOrHasAnyAuthority(DefaultPrivilege.Constants.PRIVILEGE_WRITE_PIPELINE_VALUE);
}
+
+ private AuditService auditService(SpResourceManager resourceManager) {
+ var auditService = resourceManager.getAuditService();
+ return auditService == null ? AuditService.disabled() : auditService;
+ }
}