greptile review fixes

This commit is contained in:
x032205
2025-09-05 00:16:36 -04:00
parent 0c9ade33dd
commit ab2146367c
8 changed files with 25 additions and 11 deletions

View File

@@ -198,7 +198,11 @@ export async function down(knex: Knex): Promise<void> {
.merge();
}
await knex(TableName.AuditLogStream).whereNot("provider", "custom").orWhereNull("url").del();
await knex(TableName.AuditLogStream)
.where((qb) => {
void qb.whereNot("provider", "custom").orWhereNull("url");
})
.del();
await knex.schema.alterTable(TableName.AuditLogStream, (t) => {
t.string("url").notNullable().alter();

View File

@@ -120,9 +120,11 @@ export const registerV1EERoutes = async (server: FastifyZodProvider) => {
await auditLogStreamRouter.register(registerAuditLogStreamRouter);
// Provider-specific endpoints
for await (const [provider, router] of Object.entries(AUDIT_LOG_STREAM_REGISTER_ROUTER_MAP)) {
await auditLogStreamRouter.register(router, { prefix: `/${provider}` });
}
await Promise.all(
Object.entries(AUDIT_LOG_STREAM_REGISTER_ROUTER_MAP).map(([provider, router]) =>
auditLogStreamRouter.register(router, { prefix: `/${provider}` })
)
);
},
{ prefix: "/audit-log-streams" }
);

View File

@@ -1,3 +1,4 @@
import RE2 from "re2";
import { z } from "zod";
import { LogProvider } from "../audit-log-stream-enums";
@@ -7,8 +8,14 @@ export const CustomProviderCredentialsSchema = z.object({
url: z.string().url().trim().min(1).max(255),
headers: z
.object({
key: z.string().min(1),
value: z.string().min(1)
key: z
.string()
.min(1)
.refine((val) => new RE2(/^[^\n\r]+$/).test(val), "Header keys cannot contain newlines or carriage returns"),
value: z
.string()
.min(1)
.refine((val) => new RE2(/^[^\n\r]+$/).test(val), "Header values cannot contain newlines or carriage returns")
})
.array()
});

View File

@@ -14,7 +14,7 @@ function createPayload(event: Record<string, unknown>) {
return {
time: Math.floor(Date.now() / 1000),
host: new URL(appCfg.SITE_URL || "http://infisical").host,
...(appCfg.SITE_URL && { host: new URL(appCfg.SITE_URL).host }),
source: "infisical",
sourcetype: "_json",
event
@@ -29,7 +29,7 @@ async function createSplunkUrl(hostname: string) {
throw new BadRequestError({ message: `Invalid Splunk hostname provided: ${(error as Error).message}` });
}
await blockLocalAndPrivateIpAddresses(`https://${hostname}`);
await blockLocalAndPrivateIpAddresses(`https://${parsedHostname}`);
return `https://${parsedHostname}:8088/services/collector/event`;
}

View File

@@ -13,6 +13,7 @@ export const AUDIT_LOG_STREAM_PROVIDER_MAP: Record<
[LogProvider.Splunk]: { name: "Splunk", image: "Splunk.png", size: 65 }
};
// Strictly for showing to the client in the front-end
export function getProviderUrl(
logStream: DiscriminativePick<TAuditLogStream, "provider" | "credentials">
) {

View File

@@ -16,7 +16,7 @@ export const useCreateAuditLogStream = () => {
mutationFn: async ({ provider, ...params }: TCreateAuditLogStreamDTO) => {
const { data } = await apiRequest.post<{ auditLogStream: TAuditLogStream }>(
`/api/v1/audit-log-streams/${provider}`,
{ ...params, provider }
params
);
return data.auditLogStream;

View File

@@ -255,7 +255,7 @@ export const AuditLogStreamTable = () => {
{isPending && (
<TableSkeleton
innerKey="audit-log-streams-table"
columns={4}
columns={3}
key="audit-log-streams"
/>
)}

View File

@@ -92,7 +92,7 @@ export const LogStreamProviderSelect = ({ onSelect }: Props) => {
</button>
);
})}
{!filteredOptions?.length && (
{!filteredOptions.length && (
<EmptyState
className="col-span-full mt-40"
title="No providers match search"