mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-18 00:51:15 +00:00
Addressed greptlie comments and suggestions
This commit is contained in:
+11
-11
@@ -110,7 +110,7 @@ const buildSubjectDN = (commonName: string, properties?: TPkiSubscriberPropertie
|
||||
const emailAddress = sanitizeComponent(properties?.emailAddress);
|
||||
if (emailAddress) {
|
||||
// Enhanced email validation for DN usage
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
const emailRegex = new RE2(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/);
|
||||
if (emailRegex.test(emailAddress) && emailAddress.length > 5 && emailAddress.length < 64) {
|
||||
subject += `,E=${emailAddress}`;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ const submitCertificateRequest = async (
|
||||
}
|
||||
|
||||
// Check for immediate certificate issuance
|
||||
const certMatch = responseText.match(/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/);
|
||||
const certMatch = responseText.match(new RE2("-----BEGIN CERTIFICATE-----[\\s\\S]*?-----END CERTIFICATE-----"));
|
||||
if (certMatch) {
|
||||
// Clean up the certificate format
|
||||
certificate = certMatch[0].replace(new RE2("\\\\r\\\\n", "g"), "\n").replace(new RE2("\\\\r", "g"), "\n").trim();
|
||||
@@ -325,15 +325,15 @@ const submitCertificateRequest = async (
|
||||
// General error extraction
|
||||
else {
|
||||
const errorPatterns = [
|
||||
/The disposition message is "([^"]*)/i,
|
||||
/Denied by Policy Module[^"]*"([^"]*)/i,
|
||||
/<p[^>]*class[^>]*error[^>]*>(.*?)<\/p>/i,
|
||||
/<div[^>]*class[^>]*error[^>]*>(.*?)<\/div>/i,
|
||||
/<span[^>]*class[^>]*error[^>]*>(.*?)<\/span>/i,
|
||||
/error[^<]*:([^<]*)/i,
|
||||
/denied[^<]*:([^<]*)/i,
|
||||
/The\s+request\s+contains\s+no\s+certificate\s+template\s+information/i,
|
||||
/The\s+template\s+is\s+missing/i
|
||||
new RE2('The disposition message is "([^"]*)"', "i"),
|
||||
new RE2('Denied by Policy Module[^"]*"([^"]*)"', "i"),
|
||||
new RE2("<p[^>]*class[^>]*error[^>]*>(.*?)<\\/p>", "i"),
|
||||
new RE2("<div[^>]*class[^>]*error[^>]*>(.*?)<\\/div>", "i"),
|
||||
new RE2("<span[^>]*class[^>]*error[^>]*>(.*?)<\\/span>", "i"),
|
||||
new RE2("error[^<]*:([^<]*)", "i"),
|
||||
new RE2("denied[^<]*:([^<]*)", "i"),
|
||||
new RE2("The\\s+request\\s+contains\\s+no\\s+certificate\\s+template\\s+information", "i"),
|
||||
new RE2("The\\s+template\\s+is\\s+missing", "i")
|
||||
];
|
||||
|
||||
// Try each pattern to find the error message
|
||||
|
||||
+10
-5
@@ -11,11 +11,16 @@ export const AzureAdCsCertificateAuthorityConfigurationSchema = z.object({
|
||||
azureAdcsConnectionId: z.string().uuid().trim().describe("Azure ADCS Connection ID")
|
||||
});
|
||||
|
||||
export const AzureAdCsCertificateAuthorityCredentialsSchema = z.object({
|
||||
clientId: z.string(),
|
||||
clientSecret: z.string().optional(),
|
||||
certificateThumbprint: z.string().optional()
|
||||
});
|
||||
export const AzureAdCsCertificateAuthorityCredentialsSchema = z
|
||||
.object({
|
||||
clientId: z.string(),
|
||||
clientSecret: z.string().optional(),
|
||||
certificateThumbprint: z.string().optional()
|
||||
})
|
||||
.refine((data) => data.clientSecret || data.certificateThumbprint, {
|
||||
message: "At least one authentication method (clientSecret or certificateThumbprint) must be provided",
|
||||
path: ["clientSecret"]
|
||||
});
|
||||
|
||||
export const AzureAdCsCertificateAuthoritySchema = BaseCertificateAuthoritySchema.extend({
|
||||
type: z.literal(CaType.AZURE_AD_CS),
|
||||
|
||||
-2
@@ -8,8 +8,6 @@ import {
|
||||
|
||||
export type TAzureAdCsCertificateAuthority = z.infer<typeof AzureAdCsCertificateAuthoritySchema>;
|
||||
|
||||
export type TAzureAdCsCertificateAuthorityInput = z.infer<typeof CreateAzureAdCsCertificateAuthoritySchema>;
|
||||
|
||||
export type TCreateAzureAdCsCertificateAuthorityDTO = z.infer<typeof CreateAzureAdCsCertificateAuthoritySchema>;
|
||||
|
||||
export type TUpdateAzureAdCsCertificateAuthorityDTO = z.infer<typeof UpdateAzureAdCsCertificateAuthoritySchema>;
|
||||
|
||||
@@ -12,11 +12,7 @@ export const CERTIFICATE_AUTHORITIES_CAPABILITIES_MAP: Record<CaType, CaCapabili
|
||||
CaCapability.REVOKE_CERTIFICATES,
|
||||
CaCapability.RENEW_CERTIFICATES
|
||||
],
|
||||
[CaType.ACME]: [
|
||||
CaCapability.ISSUE_CERTIFICATES,
|
||||
CaCapability.REVOKE_CERTIFICATES,
|
||||
CaCapability.RENEW_CERTIFICATES
|
||||
],
|
||||
[CaType.ACME]: [CaCapability.ISSUE_CERTIFICATES, CaCapability.REVOKE_CERTIFICATES, CaCapability.RENEW_CERTIFICATES],
|
||||
[CaType.AZURE_AD_CS]: [
|
||||
CaCapability.ISSUE_CERTIFICATES,
|
||||
CaCapability.RENEW_CERTIFICATES
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TAcmeCertificateAuthority, TAcmeCertificateAuthorityInput } from "./acme/acme-certificate-authority-types";
|
||||
import {
|
||||
TAzureAdCsCertificateAuthority,
|
||||
TAzureAdCsCertificateAuthorityInput
|
||||
TCreateAzureAdCsCertificateAuthorityDTO
|
||||
} from "./azure-ad-cs/azure-ad-cs-certificate-authority-types";
|
||||
import { CaType } from "./certificate-authority-enums";
|
||||
import {
|
||||
@@ -17,7 +17,7 @@ export type TCertificateAuthority =
|
||||
export type TCertificateAuthorityInput =
|
||||
| TInternalCertificateAuthorityInput
|
||||
| TAcmeCertificateAuthorityInput
|
||||
| TAzureAdCsCertificateAuthorityInput;
|
||||
| TCreateAzureAdCsCertificateAuthorityDTO;
|
||||
|
||||
export type TCreateCertificateAuthorityDTO = Omit<TCertificateAuthority, "id">;
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ const buildSubjectDN = (commonName: string, properties?: TPkiSubscriberPropertie
|
||||
const emailAddress = sanitizeComponent(properties?.emailAddress);
|
||||
if (emailAddress) {
|
||||
// Enhanced email validation for DN usage
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
const emailRegex = new RE2(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/);
|
||||
if (emailRegex.test(emailAddress) && emailAddress.length > 5 && emailAddress.length < 64) {
|
||||
subject += `,E=${emailAddress}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user