Skip to content

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

Address greptile comments

Carlos Monastyrskie06e43a03c55
diff --git a/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.test.ts b/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.test.ts
index 1e6afa6320..657d5b0c07 100644
--- a/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.test.ts
+++ b/backend/src/ee/services/pki-discovery/pki-discovery-host-scan-fns.test.ts
@@ -84,7 +84,8 @@ test("writeHostFile names a new installation after the hostname and links its ce
})
).rawData
);
- const tx = {};
+ const savepoint = {};
+ const tx = { transaction: (callback: (trx: unknown) => unknown) => callback(savepoint) };
const create = vi.fn().mockResolvedValue({ id: "installation-1" });
const upsertCertLink = vi.fn().mockResolvedValue(undefined);
const deps = {
@@ -113,7 +114,7 @@ test("writeHostFile names a new installation after the hostname and links its ce
deps
);
- expect(create).toHaveBeenCalledWith(expect.objectContaining({ name: "web-01:/etc/ssl/a.pem" }), tx);
+ expect(create).toHaveBeenCalledWith(expect.objectContaining({ name: "web-01:/etc/ssl/a.pem" }), savepoint);
expect(upsertCertLink).toHaveBeenCalledWith("installation-1", "cert-1", { lastSeenAt: ctx.scanTime }, tx);
});
diff --git a/docs/documentation/platform/pki/discovery/linux-server.mdx b/docs/documentation/platform/pki/discovery/linux-server.mdx
index fd789a9ca1..2face8e231 100644
--- a/docs/documentation/platform/pki/discovery/linux-server.mdx
+++ b/docs/documentation/platform/pki/discovery/linux-server.mdx
@@ -82,8 +82,9 @@ If a folder still can't be read, the scan completes and the job shows which fold
<Step>
Set the options:
- **Folder Depth**: how many levels below each search folder to search (defaults to 8)
- - **Largest File (KB)**: files bigger than this are skipped and listed in the scan results (defaults to 512)
- - **Import CA Certificates Found on Their Own**: also import CA certificates from files that hold no leaf certificate
+ - **Include trust stores and CA bundles**: also import CA certificates from files that hold no leaf certificate
+
+ Files larger than 512 KB are skipped and listed in the scan results. To raise that limit, set `maxFileSizeKb` on the job through the [API](/api-reference/endpoints/pki-discovery/update).
</Step>
<Step>
Enter a **Name** and an optional **Description**. To run the job on a schedule, turn on **Scan on a Schedule** and pick a **Scan Interval**.
@@ -124,7 +125,7 @@ To set the password through the API, call [the endpoint that updates an installa
<AccordionGroup>
<Accordion title="Why does the job show a warning after a scan?">
- The scan completed, but some files or folders couldn't be read, or the scan stopped early. The job lists what happened. For folders or files the SSH user can't open, [give the SSH user read access](#give-the-ssh-user-read-access). For files over the size limit, raise **Largest File (KB)**. If the scan stopped after 5,000 files, narrow the search folders or add skip folders.
+ The scan completed, but some files or folders couldn't be read, or the scan stopped early. The job lists what happened. For folders or files the SSH user can't open, [give the SSH user read access](#give-the-ssh-user-read-access). For files over the 512 KB size limit, raise `maxFileSizeKb` on the job through the [API](/api-reference/endpoints/pki-discovery/update). If the scan stopped after 5,000 files, narrow the search folders or add skip folders.
</Accordion>
</AccordionGroup>
diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx
index 09f01abdb0..f2c7446a03 100644
--- a/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx
+++ b/frontend/src/pages/cert-manager/DiscoveryPage/components/DiscoveryJobSheet/DiscoveryJobForm.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
-import { FieldPath, FormProvider, useForm } from "react-hook-form";
+import { FieldErrors, FieldPath, FormProvider, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import {
@@ -202,9 +202,19 @@ export const DiscoveryJobForm = ({
onComplete();
};
+ const goToFirstErrorStep = (errors: FieldErrors<TDiscoveryJobForm>) => {
+ const erroredFields = Object.keys(errors);
+ const errorStepIndex = steps.findIndex((key) =>
+ STEP_FIELDS[key].some((field) => erroredFields.includes(field))
+ );
+ if (errorStepIndex >= 0) setStepIndex(errorStepIndex);
+ };
+
+ const submitForm = () => handleSubmit(onSubmit, goToFirstErrorStep)().catch(() => undefined);
+
const handleNext = async () => {
if (isFinalStep) {
- await handleSubmit(onSubmit)().catch(() => undefined);
+ await submitForm();
return;
}
const isValid = await trigger(STEP_FIELDS[currentKey]);
@@ -293,7 +303,7 @@ export const DiscoveryJobForm = ({
<Button
type="button"
variant="project"
- onClick={() => handleSubmit(onSubmit)().catch(() => undefined)}
+ onClick={submitForm}
isPending={isPending}
isDisabled={!formState.isDirty || isPending}
>