Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add product filter

Thiago Araujo da Silva6dca89060166
diff --git a/backend/src/db/migrations/20260617120000_audit-log-stream-filters.ts b/backend/src/db/migrations/20260617120000_audit-log-stream-filters.ts
new file mode 100644
index 0000000000..dabead7793
--- /dev/null
+++ b/backend/src/db/migrations/20260617120000_audit-log-stream-filters.ts
@@ -0,0 +1,34 @@
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+const FILTERS_COLUMN = "filters";
+
+export async function up(knex: Knex): Promise<void> {
+ if (await knex.schema.hasTable(TableName.AuditLogStream)) {
+ const hasFilters = await knex.schema.hasColumn(TableName.AuditLogStream, FILTERS_COLUMN);
+
+ if (!hasFilters) {
+ // Structured jsonb describing which audit logs the stream should receive, e.g.
+ // { "products": ["cert-manager", "organization"] }
+ // NULL (the default for every existing stream) means "stream everything", so the change is
+ // backwards compatible — no behavior change until a filter is explicitly configured. Modeled
+ // as jsonb (not text[]) so future filter dimensions can be added without another migration.
+ await knex.schema.alterTable(TableName.AuditLogStream, (t) => {
+ t.jsonb(FILTERS_COLUMN).nullable();
+ });
+ }
+ }
+}
+
+export async function down(knex: Knex): Promise<void> {
+ if (await knex.schema.hasTable(TableName.AuditLogStream)) {
+ const hasFilters = await knex.schema.hasColumn(TableName.AuditLogStream, FILTERS_COLUMN);
+
+ if (hasFilters) {
+ await knex.schema.alterTable(TableName.AuditLogStream, (t) => {
+ t.dropColumn(FILTERS_COLUMN);
+ });
+ }
+ }
+}
diff --git a/backend/src/db/schemas/audit-log-streams.ts b/backend/src/db/schemas/audit-log-streams.ts
index 3c961734eb..9e588e55e6 100644
--- a/backend/src/db/schemas/audit-log-streams.ts
+++ b/backend/src/db/schemas/audit-log-streams.ts
@@ -22,7 +22,8 @@ export const AuditLogStreamsSchema = z.object({
updatedAt: z.date(),
provider: z.string().default("custom"),
encryptedCredentials: zodBuffer,
- streamMode: z.string().default("batch")
+ streamMode: z.string().default("batch"),
+ filters: z.unknown().nullable().optional()
});
export type TAuditLogStreams = z.infer<typeof AuditLogStreamsSchema>;
diff --git a/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-endpoints.ts b/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-endpoints.ts
index 223bfd62ed..f564f98a2c 100644
--- a/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-endpoints.ts
+++ b/backend/src/ee/routes/v1/audit-log-stream-routers/audit-log-stream-endpoints.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import { LogProvider, StreamMode } from "@app/ee/services/audit-log-stream/audit-log-stream-enums";
+import { AuditLogStreamFiltersSchema } from "@app/ee/services/audit-log-stream/audit-log-stream-schemas";
import { TAuditLogStream } from "@app/ee/services/audit-log-stream/audit-log-stream-types";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
@@ -26,6 +27,12 @@ export const registerAuditLogStreamEndpoints = <T extends TAuditLogStream>({
}>;
sanitizedResponseSchema: z.ZodTypeAny;
}) => {
+ // Product scoping is common to every provider, so it's merged onto each provider's body schema
+ // here rather than duplicated across all five provider schemas.
+ const FiltersBodySchema = z.object({
+ filters: AuditLogStreamFiltersSchema.nullish()
+ });
+
server.route({
method: "GET",
url: "/:logStreamId",
@@ -59,7 +66,7 @@ export const registerAuditLogStreamEndpoints = <T extends TAuditLogStream>({
rateLimit: writeLimit
},
schema: {
- body: createSchema,
+ body: createSchema.and(FiltersBodySchema),
response: {
200: z.object({
auditLogStream: sanitizedResponseSchema
@@ -68,12 +75,13 @@ export const registerAuditLogStreamEndpoints = <T extends TAuditLogStream>({
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const { credentials } = req.body;
+ const { credentials, filters } = req.body;
const auditLogStream = await server.services.auditLogStream.create(
{
provider,
- credentials
+ credentials,
+ filters
},
req.permission
);
@@ -101,7 +109,7 @@ export const registerAuditLogStreamEndpoints = <T extends TAuditLogStream>({
params: z.object({
logStreamId: z.string().uuid()
}),
- body: updateSchema,
+ body: updateSchema.and(FiltersBodySchema),
response: {
200: z.object({
auditLogStream: sanitizedResponseSchema
@@ -111,14 +119,15 @@ export const registerAuditLogStreamEndpoints = <T extends TAuditLogStream>({
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
const { logStreamId } = req.params;
- const { credentials, streamMode } = req.body;
+ const { credentials, streamMode, filters } = req.body;
const auditLogStream = await server.services.auditLogStream.updateById(
{
logStreamId,
provider,
credentials,
- streamMode
+ streamMode,
+ filters
},
req.permission
);
diff --git a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.test.ts b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.test.ts
index bf0a05e174..e2900c215e 100644
--- a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.test.ts
+++ b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.test.ts
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, test, vi } from "vitest";
-import { LogProvider, StreamMode } from "../audit-log-stream/audit-log-stream-enums";
+import { AuditLogStreamProduct, LogProvider, StreamMode } from "../audit-log-stream/audit-log-stream-enums";
import { auditLogStreamOutboxServiceFactory } from "./audit-log-stream-outbox-service";
import { AuditLogStreamOutboxStatus, TAuditLogStreamOutboxRow } from "./audit-log-stream-outbox-types";
@@ -80,15 +80,20 @@ const createService = () => {
}))
};
+ const projectDAL = {
+ findIncludingExpired: vi.fn(async () => [])
+ };
+
const service = auditLogStreamOutboxServiceFactory({
auditLogStreamOutboxDAL: auditLogStreamOutboxDAL as never,
auditLogStreamDAL: auditLogStreamDAL as never,
+ projectDAL: projectDAL as never,
kmsService: {} as never,
keyStore: {} as never,
queueService: {} as never
});
- return { service, auditLogStreamOutboxDAL, auditLogStreamDAL };
+ return { service, auditLogStreamOutboxDAL, auditLogStreamDAL, projectDAL };
};
describe("audit-log-stream-outbox-service drainStream failure handling", () => {
@@ -318,6 +323,10 @@ describe("audit-log-stream-outbox-service enqueueForLogs batch fanout", () => {
findById: vi.fn()
};
+ const projectDAL = {
+ findIncludingExpired: vi.fn(async () => [])
+ };
+
// Win the debounce SETNX so the flush job is always enqueued in these tests.
const keyStore = { setItemWithExpiryNX: vi.fn(async () => true) };
const queueService = { queue: vi.fn(async () => undefined) };
@@ -325,12 +334,13 @@ describe("audit-log-stream-outbox-service enqueueForLogs batch fanout", () => {
const service = auditLogStreamOutboxServiceFactory({
auditLogStreamOutboxDAL: auditLogStreamOutboxDAL as never,
auditLogStreamDAL: auditLogStreamDAL as never,
+ projectDAL: projectDAL as never,
kmsService: {} as never,
keyStore: keyStore as never,
queueService: queueService as never
});
- return { service, auditLogStreamOutboxDAL, auditLogStreamDAL, keyStore, queueService };
+ return { service, auditLogStreamOutboxDAL, auditLogStreamDAL, projectDAL, keyStore, queueService };
};
const log = (id: string, orgId?: string) => ({ id, orgId }) as TAuditLogStreamOutboxRow["payload"];
@@ -389,6 +399,68 @@ describe("audit-log-stream-outbox-service enqueueForLogs batch fanout", () => {
expect(auditLogStreamOutboxDAL.batchInsert).not.toHaveBeenCalled();
expect(keyStore.setItemWithExpiryNX).not.toHaveBeenCalled();
});
+
+ // A log carrying a projectId, used to exercise product-scoped streams.
+ const projectLog = (id: string, orgId: string, projectId: string) =>
+ ({ id, orgId, projectId }) as TAuditLogStreamOutboxRow["payload"];
+
+ test("no stream has a product filter → project types are never resolved (zero-overhead path)", async () => {
+ const { service, auditLogStreamDAL, auditLogStreamOutboxDAL, projectDAL } = buildService();
+ auditLogStreamDAL.find.mockResolvedValue([{ id: "sA", orgId: "orgA", provider: PROVIDER }] as never);
+
+ await service.enqueueForLogs([projectLog("1", "orgA", "projPki")]);
+
+ expect(projectDAL.findIncludingExpired).not.toHaveBeenCalled();
+ expect(auditLogStreamOutboxDAL.batchInsert.mock.calls[0][0]).toHaveLength(1);
+ });
+
+ test("product-scoped stream only receives logs whose product matches", async () => {
+ const { service, auditLogStreamDAL, auditLogStreamOutboxDAL, projectDAL, keyStore, queueService } = buildService();
+
+ // One stream scoped to PKI + org-level events.
+ auditLogStreamDAL.find.mockResolvedValue([
+ {
+ id: "sA",
+ orgId: "orgA",
+ provider: PROVIDER,
+ filters: { products: [AuditLogStreamProduct.CertificateManager, AuditLogStreamProduct.Organization] }
+ }
+ ] as never);
+
+ projectDAL.findIncludingExpired.mockResolvedValue([
+ { id: "projPki", type: AuditLogStreamProduct.CertificateManager },
+ { id: "projSecrets", type: AuditLogStreamProduct.SecretManager }
+ ] as never);
+
+ await service.enqueueForLogs([
+ projectLog("pki", "orgA", "projPki"), // matches (cert-manager)
+ projectLog("secrets", "orgA", "projSecrets"), // filtered out (secret-manager)
+ log("orgLevel", "orgA") // matches (organization, no projectId)
+ ]);
+
+ expect(projectDAL.findIncludingExpired).toHaveBeenCalledTimes(1);
+ const inserted = auditLogStreamOutboxDAL.batchInsert.mock.calls[0][0] as { payload: { id: string } }[];
+ expect(inserted.map((r) => r.payload.id).sort()).toEqual(["orgLevel", "pki"]);
+ // The stream received rows, so it is woken exactly once.
+ expect(keyStore.setItemWithExpiryNX).toHaveBeenCalledTimes(1);
+ expect(queueService.queue).toHaveBeenCalledTimes(1);
+ });
+
+ test("a stream whose every log is filtered out is not inserted or woken", async () => {
+ const { service, auditLogStreamDAL, auditLogStreamOutboxDAL, projectDAL, keyStore } = buildService();
+
+ auditLogStreamDAL.find.mockResolvedValue([
+ { id: "sA", orgId: "orgA", provider: PROVIDER, filters: { products: [AuditLogStreamProduct.KMS] } }
+ ] as never);
+ projectDAL.findIncludingExpired.mockResolvedValue([
+ { id: "projPki", type: AuditLogStreamProduct.CertificateManager }
+ ] as never);
+
+ await service.enqueueForLogs([projectLog("pki", "orgA", "projPki")]);
+
+ expect(auditLogStreamOutboxDAL.batchInsert).not.toHaveBeenCalled();
+ expect(keyStore.setItemWithExpiryNX).not.toHaveBeenCalled();
+ });
});
describe("audit-log-stream-outbox-service pruneDeliveredRows", () => {
diff --git a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts
index 6acdd372f6..33f25569f0 100644
--- a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts
+++ b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts
@@ -8,12 +8,18 @@ import {
} from "@app/lib/telemetry/metrics";
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TProjectDALFactory } from "@app/services/project/project-dal";
import { chunkAuditLogsByBatchLimit } from "../audit-log-stream/audit-log-stream-batching";
import { TAuditLogStreamDALFactory } from "../audit-log-stream/audit-log-stream-dal";
import { LogProvider, StreamMode } from "../audit-log-stream/audit-log-stream-enums";
import { LOG_STREAM_FACTORY_MAP } from "../audit-log-stream/audit-log-stream-factory";
-import { decryptLogStreamCredentials } from "../audit-log-stream/audit-log-stream-fns";
+import {
+ auditLogMatchesStreamFilter,
+ decryptLogStreamCredentials,
+ resolveAuditLogProduct
+} from "../audit-log-stream/audit-log-stream-fns";
+import { TAuditLogStreamFilters } from "../audit-log-stream/audit-log-stream-schemas";
import { TAuditLogStreamOutboxDALFactory } from "./audit-log-stream-outbox-dal";
import {
TAuditLogStreamFlushJobData,
@@ -63,6 +69,7 @@ const computeBackoffMs = (attemptsAfterIncrement: number): number => {
export type TAuditLogStreamOutboxServiceFactoryDep = {
auditLogStreamOutboxDAL: TAuditLogStreamOutboxDALFactory;
auditLogStreamDAL: Pick<TAuditLogStreamDALFactory, "find" | "findById">;
+ projectDAL: Pick<TProjectDALFactory, "findIncludingExpired">;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
keyStore: Pick<TKeyStoreFactory, "setItemWithExpiryNX">;
queueService: TQueueServiceFactory;
@@ -78,6 +85,7 @@ export type TAuditLogStreamOutboxServiceFactory = {
export const auditLogStreamOutboxServiceFactory = ({
auditLogStreamOutboxDAL,
auditLogStreamDAL,
+ projectDAL,
kmsService,
keyStore,
queueService
@@ -141,12 +149,44 @@ export const auditLogStreamOutboxServiceFactory = ({
// One lookup for every org in the batch instead of a query per org — the common case is
// that most orgs have no streams configured, so a per-org loop is mostly empty round-trips.
const streams = await auditLogStreamDAL.find({ $in: { orgId: [...logsByOrg.keys()] } });
+
+ // Product scoping needs each log's product, which is its project's type. Only pay for that
+ // resolution when at least one stream actually filters by product — the common case (no
+ // product-scoped streams) keeps the original zero-extra-query fanout.
+ const hasProductFilter = streams.some(
+ (stream) => ((stream.filters as TAuditLogStreamFilters | null)?.products?.length ?? 0) > 0
+ );
+
+ let projectTypeById = new Map<string, string>();
+ if (hasProductFilter) {
+ const projectIds = new Set<string>();
+ for (const logs of logsByOrg.values()) {
+ for (const log of logs) {
+ if (log.projectId) projectIds.add(log.projectId);
+ }
+ }
+ if (projectIds.size > 0) {
+ const projects = await projectDAL.findIncludingExpired({ $in: { id: [...projectIds] } });
+ projectTypeById = new Map(projects.map((project) => [project.id, project.type]));
+ }
+ }
+
for (const stream of streams) {
const logs = logsByOrg.get(stream.orgId);
- if (logs) {
- for (const log of logs) {
- outboxRows.push({ streamId: stream.id, orgId: stream.orgId, payload: log });
+ if (!logs) continue;
+
+ const filters = stream.filters as TAuditLogStreamFilters | null;
+ let streamReceivedRow = false;
+ for (const log of logs) {
+ if (hasProductFilter && !auditLogMatchesStreamFilter(resolveAuditLogProduct(log, projectTypeById), filters)) {
+ continue;
}
+ outboxRows.push({ streamId: stream.id, orgId: stream.orgId, payload: log });
+ streamReceivedRow = true;
+ }
+
+ // Only wake a stream that actually received rows — a fully-filtered-out stream has nothing to flush.
+ if (streamReceivedRow) {
streamsToFlush.set(stream.id, { orgId: stream.orgId, provider: stream.provider as LogProvider });
}
}
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts
index 659885f47a..111bed68e6 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-enums.ts
@@ -12,3 +12,17 @@ export enum StreamMode {
// A JSON array of events POSTed per request (default for all new streams).
Batch = "batch"
}
+
+// Products an audit log stream can be scoped to. The product-named values are kept 1:1 with
+// ProjectType (src/db/schemas/models.ts) so a project's `type` maps directly to a product, plus
+// an "organization" value for org-level events that don't belong to any product project.
+// Used in the stream's `filters.products` list — an absent/empty list means "stream all products".
+export enum AuditLogStreamProduct {
+ SecretManager = "secret-manager",
+ CertificateManager = "cert-manager",
+ KMS = "kms",
+ SecretScanning = "secret-scanning",
+ PAM = "pam",
+ // Org-level events (no associated project), e.g. SSO, org settings, user/identity management.
+ Organization = "organization"
+}
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts
index 07d833030a..03e76d3a36 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-fns.ts
@@ -1,7 +1,9 @@
-import { TAuditLogStreams } from "@app/db/schemas";
+import { TAuditLogs, TAuditLogStreams } from "@app/db/schemas";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
import { KmsDataKey } from "@app/services/kms/kms-types";
+import { AuditLogStreamProduct } from "./audit-log-stream-enums";
+import { TAuditLogStreamFilters } from "./audit-log-stream-schemas";
import { TAuditLogStream, TAuditLogStreamCredentials } from "./audit-log-stream-types";
import { getAzureProviderListItem } from "./azure/azure-provider-fns";
import { getCriblProviderListItem } from "./cribl/cribl-provider-fns";
@@ -61,6 +63,31 @@ export const decryptLogStreamCredentials = async ({
return JSON.parse(decryptedPlainTextBlob.toString()) as TAuditLogStreamCredentials;
};
+// The product an audit log belongs to. A log created inside a project belongs to that project's
+// product (project `type` values are 1:1 with AuditLogStreamProduct); a log with no project is an
+// org-level event. A project whose type can't be resolved (e.g. hard-deleted) falls back to
+// Organization so it still reaches org-scoped streams rather than being silently dropped.
+export const resolveAuditLogProduct = (
+ log: Pick<TAuditLogs, "projectId">,
+ projectTypeById: Map<string, string>
+): AuditLogStreamProduct => {
+ if (!log.projectId) return AuditLogStreamProduct.Organization;
+ return (
+ (projectTypeById.get(log.projectId) as AuditLogStreamProduct | undefined) ?? AuditLogStreamProduct.Organization
+ );
+};
+
+// Whether a stream with the given filters should receive a log of the given product. A null filter
+// or an absent/empty `products` list means "stream everything" (backwards-compatible default).
+export const auditLogMatchesStreamFilter = (
+ product: AuditLogStreamProduct,
+ filters?: TAuditLogStreamFilters | null
+): boolean => {
+ const products = filters?.products;
+ if (!products || products.length === 0) return true;
+ return products.includes(product);
+};
+
export const decryptLogStream = async (
logStream: TAuditLogStreams,
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-schemas.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-schemas.ts
index 4fba791078..097f4d866b 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-schemas.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-schemas.ts
@@ -1,9 +1,25 @@
+import { z } from "zod";
+
import { AuditLogStreamsSchema } from "@app/db/schemas";
+import { AuditLogStreamProduct } from "./audit-log-stream-enums";
+
+// Scopes which audit logs a stream receives. An absent/empty `products` list means "stream every
+// product" — the same as a NULL `filters` column. Modeled as an object so new filter dimensions
+// (event types, actors, environments, ...) can be added later without a schema migration.
+export const AuditLogStreamFiltersSchema = z.object({
+ products: z.nativeEnum(AuditLogStreamProduct).array().optional()
+});
+
+export type TAuditLogStreamFilters = z.infer<typeof AuditLogStreamFiltersSchema>;
+
export const BaseProviderSchema = AuditLogStreamsSchema.omit({
encryptedCredentials: true,
provider: true,
+ // Re-added below with a typed schema (the generated column type is z.unknown()).
+ filters: true,
+
// Old "archived" values
encryptedHeadersAlgorithm: true,
encryptedHeadersCiphertext: true,
@@ -11,4 +27,6 @@ export const BaseProviderSchema = AuditLogStreamsSchema.omit({
encryptedHeadersKeyEncoding: true,
encryptedHeadersTag: true,
url: true
+}).extend({
+ filters: AuditLogStreamFiltersSchema.nullable().optional()
});
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
index f48e01e794..e6922425cc 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-service.ts
@@ -35,7 +35,7 @@ export const auditLogStreamServiceFactory = ({
licenseService,
kmsService
}: TAuditLogStreamServiceFactoryDep) => {
- const create = async ({ provider, credentials }: TCreateAuditLogStreamDTO, actor: OrgServiceActor) => {
+ const create = async ({ provider, credentials, filters }: TCreateAuditLogStreamDTO, actor: OrgServiceActor) => {
const plan = await licenseService.getPlan(actor.orgId);
if (!plan.auditLogStreams) {
throw new BadRequestError({
@@ -76,14 +76,16 @@ export const auditLogStreamServiceFactory = ({
encryptedCredentials,
// All new streams use batch delivery. "single" is reachable only by existing
// custom/cribl streams that were migrated, and only as a one-way upgrade away from it.
- streamMode: StreamMode.Batch
+ streamMode: StreamMode.Batch,
+ // null when unset -> stream all products.
+ filters: filters ?? null
});
return { ...logStream, credentials: validatedCredentials } as TAuditLogStream;
};
const updateById = async (
- { logStreamId, provider, credentials, streamMode }: TUpdateAuditLogStreamDTO,
+ { logStreamId, provider, credentials, streamMode, filters }: TUpdateAuditLogStreamDTO,
actor: OrgServiceActor
) => {
const plan = await licenseService.getPlan(actor.orgId);
@@ -164,7 +166,9 @@ export const auditLogStreamServiceFactory = ({
const updatedLogStream = await auditLogStreamDAL.updateById(logStreamId, {
encryptedCredentials,
// Only persist a mode change when provided (the validated single -> batch upgrade).
- ...(streamMode ? { streamMode } : {})
+ ...(streamMode ? { streamMode } : {}),
+ // `undefined` leaves the existing filter untouched; `null`/empty clears it (stream all).
+ ...(filters !== undefined ? { filters } : {})
});
return { ...updatedLogStream, credentials: validatedCredentials } as TAuditLogStream;
diff --git a/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts b/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts
index cdd4f33c2e..5d882a997a 100644
--- a/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts
+++ b/backend/src/ee/services/audit-log-stream/audit-log-stream-types.ts
@@ -1,6 +1,7 @@
import { TAuditLogs } from "@app/db/schemas";
import { LogProvider, StreamMode } from "./audit-log-stream-enums";
+import { TAuditLogStreamFilters } from "./audit-log-stream-schemas";
import { TAzureProvider, TAzureProviderCredentials } from "./azure/azure-provider-types";
import { TCriblProvider, TCriblProviderCredentials } from "./cribl/cribl-provider-types";
import { TCustomProvider, TCustomProviderCredentials } from "./custom/custom-provider-types";
@@ -19,6 +20,8 @@ export type TAuditLogStreamCredentials =
export type TCreateAuditLogStreamDTO = {
provider: LogProvider;
credentials: TAuditLogStreamCredentials;
+ // Products the stream is scoped to. Omitted/empty -> stream all products.
+ filters?: TAuditLogStreamFilters | null;
};
export type TUpdateAuditLogStreamDTO = {
@@ -27,6 +30,9 @@ export type TUpdateAuditLogStreamDTO = {
credentials: TAuditLogStreamCredentials;
// Optional one-way upgrade from "single" to "batch". Downgrades are rejected.
streamMode?: StreamMode;
+ // Products the stream is scoped to. Omitted leaves the existing filter unchanged; pass null or an
+ // empty product list to clear it (stream all products).
+ filters?: TAuditLogStreamFilters | null;
};
export type TLogStreamFactoryValidateCredentials<C extends TAuditLogStreamCredentials> = (input: {
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 331a1ce0f2..cae5ec4985 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -956,6 +956,7 @@ export const registerRoutes = async (
const auditLogStreamOutboxService = auditLogStreamOutboxServiceFactory({
auditLogStreamOutboxDAL,
auditLogStreamDAL,
+ projectDAL,
kmsService,
keyStore,
queueService
diff --git a/frontend/src/components/v2/FilterableSelect/FilterableSelect.tsx b/frontend/src/components/v2/FilterableSelect/FilterableSelect.tsx
index 714779f222..2a8838c64f 100644
--- a/frontend/src/components/v2/FilterableSelect/FilterableSelect.tsx
+++ b/frontend/src/components/v2/FilterableSelect/FilterableSelect.tsx
@@ -104,7 +104,7 @@ export const FilterableSelect = <T,>({
clearIndicator: () => "p-1 hover:text-red text-bunker-400",
indicatorSeparator: () => "bg-bunker-400",
dropdownIndicator: () => "text-bunker-200 p-1",
- menuList: () => "flex flex-col gap-1",
+ menuList: () => "flex flex-col gap-1 max-h-[18rem] overflow-y-auto thin-scrollbar",
menu: () =>
"my-2 p-2 border text-sm text-mineshaft-200 thin-scrollbar bg-mineshaft-900 border-mineshaft-600 rounded-md",
groupHeading: () => "ml-3 mt-2 mb-1 text-mineshaft-400 text-sm",
diff --git a/frontend/src/hooks/api/auditLogStreams/enums.ts b/frontend/src/hooks/api/auditLogStreams/enums.ts
index f8a5c1af66..63788a5366 100644
--- a/frontend/src/hooks/api/auditLogStreams/enums.ts
+++ b/frontend/src/hooks/api/auditLogStreams/enums.ts
@@ -13,3 +13,12 @@ export enum StreamMode {
// A JSON array of events POSTed per request. Default for all new streams.
Batch = "batch"
}
+
+export enum AuditLogStreamProduct {
+ SecretManager = "secret-manager",
+ CertificateManager = "cert-manager",
+ KMS = "kms",
+ SecretScanning = "secret-scanning",
+ PAM = "pam",
+ Organization = "organization"
+}
diff --git a/frontend/src/hooks/api/auditLogStreams/types/index.ts b/frontend/src/hooks/api/auditLogStreams/types/index.ts
index f08fd32cc1..362cb1fbc6 100644
--- a/frontend/src/hooks/api/auditLogStreams/types/index.ts
+++ b/frontend/src/hooks/api/auditLogStreams/types/index.ts
@@ -4,8 +4,11 @@ import { TCriblProviderLogStream } from "./providers/cribl-provider";
import { TCustomProviderLogStream } from "./providers/custom-provider";
import { TDatadogProviderLogStream } from "./providers/datadog-provider";
import { TQRadarProviderLogStream } from "./providers/qradar-provider";
+import { TAuditLogStreamFilters } from "./providers/root-provider";
import { TSplunkProviderLogStream } from "./providers/splunk-provider";
+export type { TAuditLogStreamFilters };
+
export type TAuditLogStream =
| TCustomProviderLogStream
| TDatadogProviderLogStream
@@ -22,12 +25,17 @@ export type TAuditLogStreamProviderMap = {
[LogProvider.QRadar]: TQRadarProviderLogStream;
};
-export type TCreateAuditLogStreamDTO = Pick<TAuditLogStream, "provider" | "credentials">;
+export type TCreateAuditLogStreamDTO = Pick<TAuditLogStream, "provider" | "credentials"> & {
+ // Products the stream is scoped to. Omitted/empty -> stream all products.
+ filters?: TAuditLogStreamFilters | null;
+};
export type TUpdateAuditLogStreamDTO = Pick<TAuditLogStream, "credentials"> & {
provider: LogProvider;
auditLogStreamId: string;
// One-way upgrade from "single" to "batch" (custom streams only).
streamMode?: StreamMode;
+ // Products the stream is scoped to. Omitted/empty -> stream all products.
+ filters?: TAuditLogStreamFilters | null;
};
export type TDeleteAuditLogStreamDTO = {
provider: LogProvider;
diff --git a/frontend/src/hooks/api/auditLogStreams/types/providers/root-provider.ts b/frontend/src/hooks/api/auditLogStreams/types/providers/root-provider.ts
index f86dba23a6..9109bc6843 100644
--- a/frontend/src/hooks/api/auditLogStreams/types/providers/root-provider.ts
+++ b/frontend/src/hooks/api/auditLogStreams/types/providers/root-provider.ts
@@ -1,4 +1,8 @@
-import { StreamMode } from "../../enums";
+import { AuditLogStreamProduct, StreamMode } from "../../enums";
+
+export type TAuditLogStreamFilters = {
+ products?: AuditLogStreamProduct[];
+};
export type TRootProviderLogStream = {
id: string;
@@ -6,4 +10,5 @@ export type TRootProviderLogStream = {
createdAt: string;
updatedAt: string;
streamMode: StreamMode;
+ filters?: TAuditLogStreamFilters | null;
};
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx
index bff4936e2a..203fa341cb 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamForm.tsx
@@ -2,6 +2,7 @@ import { createNotification } from "@app/components/notifications";
import { AUDIT_LOG_STREAM_PROVIDER_MAP } from "@app/helpers/auditLogStreams";
import { useCreateAuditLogStream, useUpdateAuditLogStream } from "@app/hooks/api";
import { LogProvider, StreamMode } from "@app/hooks/api/auditLogStreams/enums";
+import { TAuditLogStreamFilters } from "@app/hooks/api/auditLogStreams/types";
import { TAuditLogStream } from "@app/hooks/api/types";
import { DiscriminativePick } from "@app/types";
@@ -13,14 +14,21 @@ import { DatadogProviderAuditLogStreamForm } from "./DatadogProviderAuditLogStre
import { SplunkProviderAuditLogStreamForm } from "./SplunkProviderAuditLogStreamForm";
// Provider forms submit their provider + credentials; the custom form may also submit a
-// one-way streamMode upgrade (single -> batch).
+// one-way streamMode upgrade (single -> batch). Every form may submit product filters.
export type AuditLogStreamFormData = DiscriminativePick<
TAuditLogStream,
"provider" | "credentials"
> & {
streamMode?: StreamMode;
+ filters?: TAuditLogStreamFilters | null;
};
+// An empty product selection means "stream everything", which the API represents as a null filter.
+const normalizeFilters = (formData: AuditLogStreamFormData): AuditLogStreamFormData => ({
+ ...formData,
+ filters: formData.filters?.products?.length ? formData.filters : null
+});
+
type FormProps = {
onComplete: (auditLogStream: TAuditLogStream) => void;
};
@@ -35,7 +43,7 @@ const CreateForm = ({ provider, onComplete }: CreateFormProps) => {
const { name: providerName } = AUDIT_LOG_STREAM_PROVIDER_MAP[provider];
const onSubmit = async (formData: AuditLogStreamFormData) => {
- const logStream = await createAuditLogStream.mutateAsync(formData);
+ const logStream = await createAuditLogStream.mutateAsync(normalizeFilters(formData));
createNotification({
text: `Successfully created ${providerName} Log Stream`,
type: "success"
@@ -66,7 +74,7 @@ const UpdateForm = ({ auditLogStream, onComplete }: UpdateFormProps) => {
const onSubmit = async (formData: AuditLogStreamFormData) => {
const connection = await updateAuditLogStream.mutateAsync({
auditLogStreamId: auditLogStream.id,
- ...formData
+ ...normalizeFilters(formData)
});
createNotification({
text: `Successfully updated ${providerName} Log Stream`,
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamProductsField.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamProductsField.tsx
new file mode 100644
index 0000000000..e6ef1cedef
--- /dev/null
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AuditLogStreamProductsField.tsx
@@ -0,0 +1,165 @@
+import { useEffect, useRef, useState } from "react";
+import { useController, useFormContext } from "react-hook-form";
+import { components, MultiValue, OptionProps } from "react-select";
+import {
+ Building2Icon,
+ CheckIcon,
+ GlobeIcon,
+ KeyIcon,
+ LockIcon,
+ type LucideIcon,
+ ScanSearchIcon,
+ ShieldCheckIcon,
+ UsersIcon
+} from "lucide-react";
+import { z } from "zod";
+
+import { FilterableSelect, FormControl } from "@app/components/v2";
+import { AuditLogStreamProduct } from "@app/hooks/api/auditLogStreams/enums";
+
+// Shared across every provider form so product scoping stays consistent. Re-exported into each
+// provider's form schema (`...auditLogStreamFiltersSchema.shape`) and rendered via <ProductsField />.
+export const auditLogStreamFiltersSchema = z.object({
+ filters: z
+ .object({
+ products: z.nativeEnum(AuditLogStreamProduct).array().optional()
+ })
+ .nullish()
+});
+
+// Display labels for each product. Shared with the stream table so naming stays consistent.
+export const AUDIT_LOG_STREAM_PRODUCT_LABELS: Record<AuditLogStreamProduct, string> = {
+ [AuditLogStreamProduct.SecretManager]: "Secret Management",
+ [AuditLogStreamProduct.CertificateManager]: "Certificate Manager (PKI)",
+ [AuditLogStreamProduct.KMS]: "KMS",
+ [AuditLogStreamProduct.SecretScanning]: "Secret Scanning",
+ [AuditLogStreamProduct.PAM]: "PAM",
+ [AuditLogStreamProduct.Organization]: "Organization"
+};
+
+const PRODUCT_ICONS: Record<AuditLogStreamProduct, LucideIcon> = {
+ [AuditLogStreamProduct.SecretManager]: KeyIcon,
+ [AuditLogStreamProduct.CertificateManager]: ShieldCheckIcon,
+ [AuditLogStreamProduct.KMS]: LockIcon,
+ [AuditLogStreamProduct.SecretScanning]: ScanSearchIcon,
+ [AuditLogStreamProduct.PAM]: UsersIcon,
+ [AuditLogStreamProduct.Organization]: Building2Icon
+};
+
+const PRODUCTS = [
+ AuditLogStreamProduct.Organization,
+ AuditLogStreamProduct.SecretManager,
+ AuditLogStreamProduct.CertificateManager,
+ AuditLogStreamProduct.KMS,
+ AuditLogStreamProduct.SecretScanning,
+ AuditLogStreamProduct.PAM
+];
+
+// Sentinel for the pinned "All products" entry — the default (no filter = stream everything).
+// It's never stored; selecting it just clears the product list.
+const ALL_VALUE = "__all__";
+
+type ProductOption = {
+ value: AuditLogStreamProduct | typeof ALL_VALUE;
+ label: string;
+};
+
+const ALL_OPTION: ProductOption = { value: ALL_VALUE, label: "All products" };
+
+const PRODUCT_OPTIONS: ProductOption[] = PRODUCTS.map((product) => ({
+ value: product,
+ label: AUDIT_LOG_STREAM_PRODUCT_LABELS[product]
+}));
+
+type FilterFormShape = {
+ filters?: { products?: AuditLogStreamProduct[] } | null;
+};
+
+const ProductOptionItem = ({ isSelected, children, ...props }: OptionProps<ProductOption>) => {
+ // The "All products" row is pinned to the top and divided from the rest. It reads as selected
+ // whenever no specific products are chosen (the default).
+ if (props.data.value === ALL_VALUE) {
+ const isAllProducts = (props.getValue() as ProductOption[]).length === 0;
+
+ return (
+ <div className="border-b border-mineshaft-600">
+ <components.Option {...props} isSelected={isAllProducts}>
+ <div className="flex flex-row items-center gap-2">
+ <GlobeIcon className="size-4 shrink-0 text-mineshaft-300" />
+ <p className="mr-auto truncate">{children}</p>
+ {isAllProducts && <CheckIcon className="ml-2 size-4 shrink-0 text-primary" />}
+ </div>
+ </components.Option>
+ </div>
+ );
+ }
+
+ const Icon = PRODUCT_ICONS[props.data.value];
+
+ return (
+ <components.Option isSelected={isSelected} {...props}>
+ <div className="flex flex-row items-center gap-2">
+ <Icon className="size-4 shrink-0 text-mineshaft-300" />
+ <p className="mr-auto truncate">{children}</p>
+ {isSelected && <CheckIcon className="ml-2 size-4 shrink-0 text-primary" />}
+ </div>
+ </components.Option>
+ );
+};
+
+export const ProductsField = () => {
+ const { control } = useFormContext<FilterFormShape>();
+ const { field } = useController({ control, name: "filters.products" });
+ const containerRef = useRef<HTMLDivElement>(null);
+ // Portal the menu into the enclosing modal so it can overflow the modal's scrollable body
+ // instead of being clipped. Targeting the dialog (not document.body) keeps it inside Radix's
+ // focus trap so options stay clickable. Falls back to inline rendering outside a modal.
+ const [menuPortalTarget, setMenuPortalTarget] = useState<HTMLElement | null>(null);
+
+ useEffect(() => {
+ setMenuPortalTarget(containerRef.current?.closest<HTMLElement>('[role="dialog"]') ?? null);
+ }, []);
+
+ const selected = field.value ?? [];
+ const value = PRODUCT_OPTIONS.filter((option) =>
+ selected.includes(option.value as AuditLogStreamProduct)
+ );
+
+ return (
+ <FormControl
+ label="Products"
+ isOptional
+ tooltipText="Only stream audit logs for the selected products. Leave empty to stream every product. Select 'Organization' to include org-level events (e.g. SSO, members, settings)."
+ >
+ <div ref={containerRef}>
+ <FilterableSelect
+ isMulti
+ value={value}
+ options={[ALL_OPTION, ...PRODUCT_OPTIONS]}
+ onChange={(newValue, actionMeta) => {
+ // Picking "All products" clears the filter (= stream everything).
+ if (actionMeta.action === "select-option" && actionMeta.option?.value === ALL_VALUE) {
+ field.onChange([]);
+ return;
+ }
+
+ const next = (newValue as MultiValue<ProductOption>)
+ .map((option) => option.value)
+ .filter((productValue): productValue is AuditLogStreamProduct =>
+ productValue !== ALL_VALUE
+ );
+ // Empty selection is "stream everything" — selecting every product is the same intent,
+ // so normalize it back to an empty list.
+ field.onChange(next.length === PRODUCTS.length ? [] : next);
+ }}
+ placeholder="All products"
+ getOptionValue={(option) => option.value}
+ getOptionLabel={(option) => option.label}
+ components={{ Option: ProductOptionItem }}
+ menuPortalTarget={menuPortalTarget ?? undefined}
+ menuPlacement="auto"
+ />
+ </div>
+ </FormControl>
+ );
+};
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AzureProviderAuditLogStreamForm.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AzureProviderAuditLogStreamForm.tsx
index 1da55a1392..b888f5493f 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AzureProviderAuditLogStreamForm.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/AzureProviderAuditLogStreamForm.tsx
@@ -6,6 +6,8 @@ import { Button, FormControl, Input, ModalClose, SecretInput } from "@app/compon
import { LogProvider } from "@app/hooks/api/auditLogStreams/enums";
import { TAzureProviderLogStream } from "@app/hooks/api/auditLogStreams/types/providers/azure-provider";
+import { auditLogStreamFiltersSchema, ProductsField } from "./AuditLogStreamProductsField";
+
type Props = {
auditLogStream?: TAzureProviderLogStream;
onSubmit: (formData: FormData) => void;
@@ -23,7 +25,8 @@ const formSchema = z.object({
.trim()
.regex(/^dcr-[0-9a-f]{32}$/, "DCR ID must be in dcr-*** format"),
cltName: z.string().trim().min(1).max(255)
- })
+ }),
+ ...auditLogStreamFiltersSchema.shape
});
type FormData = z.infer<typeof formSchema>;
@@ -135,6 +138,9 @@ export const AzureProviderAuditLogStreamForm = ({ auditLogStream, onSubmit }: Pr
</FormControl>
)}
/>
+ <div className="mt-6">
+ <ProductsField />
+ </div>
<div className="mt-8 flex items-center">
<Button
className="mr-4"
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CriblProviderAuditLogStreamForm.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CriblProviderAuditLogStreamForm.tsx
index 7df3c6a99f..d0d706fa4e 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CriblProviderAuditLogStreamForm.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CriblProviderAuditLogStreamForm.tsx
@@ -16,6 +16,8 @@ import {
import { LogProvider, StreamMode } from "@app/hooks/api/auditLogStreams/enums";
import { TCriblProviderLogStream } from "@app/hooks/api/auditLogStreams/types/providers/cribl-provider";
+import { auditLogStreamFiltersSchema, ProductsField } from "./AuditLogStreamProductsField";
+
type Props = {
auditLogStream?: TCriblProviderLogStream;
onSubmit: (formData: FormData) => void;
@@ -27,7 +29,8 @@ const formSchema = z.object({
url: z.string().url().trim().min(1).max(255),
token: z.string().trim().min(21).max(255)
}),
- streamMode: z.nativeEnum(StreamMode).optional()
+ streamMode: z.nativeEnum(StreamMode).optional(),
+ ...auditLogStreamFiltersSchema.shape
});
type FormData = z.infer<typeof formSchema>;
@@ -153,6 +156,10 @@ export const CriblProviderAuditLogStreamForm = ({ auditLogStream, onSubmit }: Pr
</div>
)}
+ <div className="mt-6">
+ <ProductsField />
+ </div>
+
<div className="mt-8 flex items-center">
<Button
className="mr-4"
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CustomProviderAuditLogStreamForm.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CustomProviderAuditLogStreamForm.tsx
index d86b2b967a..d642f5cadb 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CustomProviderAuditLogStreamForm.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/CustomProviderAuditLogStreamForm.tsx
@@ -18,6 +18,8 @@ import {
import { LogProvider, StreamMode } from "@app/hooks/api/auditLogStreams/enums";
import { TCustomProviderLogStream } from "@app/hooks/api/auditLogStreams/types/providers/custom-provider";
+import { auditLogStreamFiltersSchema, ProductsField } from "./AuditLogStreamProductsField";
+
type Props = {
auditLogStream?: TCustomProviderLogStream;
onSubmit: (formData: FormData) => void;
@@ -34,7 +36,8 @@ const formSchema = z.object({
})
.array()
}),
- streamMode: z.nativeEnum(StreamMode).optional()
+ streamMode: z.nativeEnum(StreamMode).optional(),
+ ...auditLogStreamFiltersSchema.shape
});
type FormData = z.infer<typeof formSchema>;
@@ -219,6 +222,10 @@ export const CustomProviderAuditLogStreamForm = ({ auditLogStream, onSubmit }: P
</div>
)}
+ <div className="mt-6">
+ <ProductsField />
+ </div>
+
<div className="mt-8 flex items-center">
<Button
className="mr-4"
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/DatadogProviderAuditLogStreamForm.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/DatadogProviderAuditLogStreamForm.tsx
index f5499e55a0..f812a75b6f 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/DatadogProviderAuditLogStreamForm.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/DatadogProviderAuditLogStreamForm.tsx
@@ -13,6 +13,8 @@ import {
import { LogProvider } from "@app/hooks/api/auditLogStreams/enums";
import { TDatadogProviderLogStream } from "@app/hooks/api/auditLogStreams/types/providers/datadog-provider";
+import { auditLogStreamFiltersSchema, ProductsField } from "./AuditLogStreamProductsField";
+
type Props = {
auditLogStream?: TDatadogProviderLogStream;
onSubmit: (formData: FormData) => void;
@@ -26,7 +28,8 @@ const formSchema = z.object({
.string()
.trim()
.regex(/^[a-fA-F0-9]{32}$/, "Invalid Datadog API key format")
- })
+ }),
+ ...auditLogStreamFiltersSchema.shape
});
type FormData = z.infer<typeof formSchema>;
@@ -109,6 +112,9 @@ export const DatadogProviderAuditLogStreamForm = ({ auditLogStream, onSubmit }:
</FormControl>
)}
/>
+ <div className="mt-6">
+ <ProductsField />
+ </div>
<div className="mt-8 flex items-center">
<Button
className="mr-4"
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/SplunkProviderAuditLogStreamForm.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/SplunkProviderAuditLogStreamForm.tsx
index f256c23b1c..e344ee0374 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/SplunkProviderAuditLogStreamForm.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/AuditLogStreamForm/SplunkProviderAuditLogStreamForm.tsx
@@ -6,6 +6,8 @@ import { Button, FormControl, Input, ModalClose, SecretInput } from "@app/compon
import { LogProvider } from "@app/hooks/api/auditLogStreams/enums";
import { TSplunkProviderLogStream } from "@app/hooks/api/auditLogStreams/types/providers/splunk-provider";
+import { auditLogStreamFiltersSchema, ProductsField } from "./AuditLogStreamProductsField";
+
type Props = {
auditLogStream?: TSplunkProviderLogStream;
onSubmit: (formData: FormData) => void;
@@ -41,7 +43,8 @@ const formSchema = z.object({
}
}),
token: z.string().uuid().trim().min(1)
- })
+ }),
+ ...auditLogStreamFiltersSchema.shape
});
type FormData = z.infer<typeof formSchema>;
@@ -97,6 +100,9 @@ export const SplunkProviderAuditLogStreamForm = ({ auditLogStream, onSubmit }: P
</FormControl>
)}
/>
+ <div className="mt-6">
+ <ProductsField />
+ </div>
<div className="mt-8 flex items-center">
<Button
className="mr-4"
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamRow.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamRow.tsx
index bfbee82cab..dfa02652d6 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamRow.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamRow.tsx
@@ -13,11 +13,14 @@ import {
Tooltip,
Tr
} from "@app/components/v2";
+import { Badge } from "@app/components/v3";
import { OrgPermissionSubjects } from "@app/context";
import { OrgPermissionActions } from "@app/context/OrgPermissionContext/types";
import { AUDIT_LOG_STREAM_PROVIDER_MAP, getProviderUrl } from "@app/helpers/auditLogStreams";
import { TAuditLogStream } from "@app/hooks/api/types";
+import { AUDIT_LOG_STREAM_PRODUCT_LABELS } from "../AuditLogStreamForm/AuditLogStreamProductsField";
+
type Props = {
logStream: TAuditLogStream;
onDelete: (logStream: TAuditLogStream) => void;
@@ -30,6 +33,8 @@ export const AuditLogStreamRow = ({ logStream, onDelete, onEditCredentials }: Pr
const providerDetails = AUDIT_LOG_STREAM_PROVIDER_MAP[provider];
const url = getProviderUrl(logStream);
+ const products = logStream.filters?.products ?? [];
+
return (
<Tr
className={twMerge("group h-12 transition-colors duration-100 hover:bg-mineshaft-700")}
@@ -61,6 +66,20 @@ export const AuditLogStreamRow = ({ logStream, onDelete, onEditCredentials }: Pr
<p className="truncate">{url}</p>
</div>
</Td>
+ <Td>
+ {products.length === 0 ? (
+ <span className="text-sm text-mineshaft-400">All products</span>
+ ) : (
+ <Tooltip
+ content={products.map((product) => AUDIT_LOG_STREAM_PRODUCT_LABELS[product]).join(", ")}
+ >
+ <div className="flex w-fit flex-wrap items-center gap-1">
+ <Badge variant="info">{AUDIT_LOG_STREAM_PRODUCT_LABELS[products[0]]}</Badge>
+ {products.length > 1 && <Badge variant="info">{`+${products.length - 1}`}</Badge>}
+ </div>
+ </Tooltip>
+ )}
+ </Td>
<Td>
<div className="flex items-center justify-end gap-2">
<Tooltip className="max-w-sm text-center" content="Options">
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamTable.tsx b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamTable.tsx
index ee47f8c0f3..ce0c8102e2 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamTable.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/AuditLogStreamTab/components/AuditLogStreamTable.tsx
@@ -248,6 +248,8 @@ export const AuditLogStreamTable = () => {
</div>
</Th>
+ <Th>Products</Th>
+
<Th className="w-5" />
</Tr>
</THead>
@@ -255,7 +257,7 @@ export const AuditLogStreamTable = () => {
{isPending && (
<TableSkeleton
innerKey="audit-log-streams-table"
- columns={3}
+ columns={4}
key="audit-log-streams"
/>
)}