1
0
mirror of https://github.com/Infisical/infisical.git synced 2025-03-25 14:05:03 +00:00

Compare commits

..

7 Commits

Author SHA1 Message Date
5b9c0438a2 Merge pull request from Infisical/fix-ph-events
remove certain python sdk events
2024-02-04 16:24:38 -05:00
11399d73dc fix eslint errors 2024-02-04 16:24:01 -05:00
38ed39c2f8 remove certain python sdk events 2024-02-04 09:37:56 -08:00
0d6ea0d69e Update values.yaml 2024-02-03 14:37:24 -05:00
237979a1c6 Merge pull request from Infisical/fix-ph-events
fix posthog events
2024-02-03 14:26:34 -05:00
4a566cf83f remove existent authData 2024-02-03 14:24:28 -05:00
654b8ab5ca fix posthog events 2024-02-03 11:09:49 -08:00
5 changed files with 45 additions and 44 deletions
.github
backend/src
db
lib/config
main.ts
server/routes/v3

2
.github/values.yaml vendored

@ -23,7 +23,7 @@ infisical:
image:
repository: infisical/staging_infisical
tag: "latest"
pullPolicy: IfNotPresent
pullPolicy: Always
deploymentAnnotations:
secrets.infisical.com/auto-reload: "false"

@ -1,23 +1,11 @@
import knex from "knex";
export type TDbClient = ReturnType<typeof initDbConnection>;
export const initDbConnection = ({
dbConnectionUri,
dbRootCert
}: {
dbConnectionUri: string;
dbRootCert?: string;
}) => {
export const initDbConnection = (dbConnectionUri: string) => {
const db = knex({
client: "pg",
connection: {
connectionString: dbConnectionUri,
ssl: dbRootCert ? {
rejectUnauthorized: true,
ca: Buffer.from(dbRootCert, 'base64').toString('ascii')
} : false
}
connection: dbConnectionUri
});
return db;
};
};

@ -15,8 +15,7 @@ const envSchema = z
PORT: z.coerce.number().default(4000),
REDIS_URL: zpStr(z.string()),
HOST: zpStr(z.string().default("localhost")),
DB_CONNECTION_URI: zpStr(z.string().describe("Postgres database connection string")),
DB_ROOT_CERT: zpStr(z.string().describe("Postgres database base64-encoded CA cert").optional()),
DB_CONNECTION_URI: zpStr(z.string().describe("Postgres database conntection string")),
NODE_ENV: z.enum(["development", "test", "production"]).default("production"),
SALT_ROUNDS: z.coerce.number().default(10),
// TODO(akhilmhdh): will be changed to one

@ -12,11 +12,7 @@ dotenv.config();
const run = async () => {
const logger = await initLogger();
const appCfg = initEnvConfig(logger);
const db = initDbConnection({
dbConnectionUri: appCfg.DB_CONNECTION_URI,
dbRootCert: appCfg.DB_ROOT_CERT
});
const db = initDbConnection(appCfg.DB_CONNECTION_URI);
const smtp = smtpServiceFactory(formatSmtpConfig());
const queue = queueServiceFactory(appCfg.REDIS_URL);

@ -13,6 +13,7 @@ import { EventType } from "@app/ee/services/audit-log/audit-log-types";
import { CommitType } from "@app/ee/services/secret-approval-request/secret-approval-request-types";
import { BadRequestError } from "@app/lib/errors";
import { removeTrailingSlash } from "@app/lib/fn";
import { getUserAgentType } from "@app/server/plugins/audit-log";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { ActorType, AuthMode } from "@app/services/auth/auth-type";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
@ -107,6 +108,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId,
environment,
secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -188,6 +190,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId,
environment,
secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -255,7 +258,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -322,7 +325,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -384,7 +387,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -467,18 +470,33 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
}
});
server.services.telemetry.sendPostHogEvents({
event: PostHogEventTypes.SecretPulled,
distinctId: getDistinctId(req),
properties: {
numberOfSecrets: secrets.length,
workspaceId: req.query.workspaceId,
environment: req.query.environment,
secretPath: req.query.secretPath,
...req.auditLogInfo
// TODO: Move to telemetry plugin
let shouldRecordK8Event = false;
if (req.headers["user-agent"] === "k8-operator") {
const randomNumber = Math.random();
if (randomNumber > 0.95) {
shouldRecordK8Event = true;
}
});
}
const shouldCapture =
req.query.workspaceId !== "650e71fbae3e6c8572f436d4" &&
(req.headers["user-agent"] !== "k8-operator" || shouldRecordK8Event);
const approximateNumberTotalSecrets = secrets.length * 20;
if (shouldCapture) {
server.services.telemetry.sendPostHogEvents({
event: PostHogEventTypes.SecretPulled,
distinctId: getDistinctId(req),
properties: {
numberOfSecrets: shouldRecordK8Event ? approximateNumberTotalSecrets : secrets.length,
workspaceId: req.query.workspaceId,
environment: req.query.environment,
secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
}
return { secrets, imports };
}
@ -550,7 +568,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.query.workspaceId,
environment: req.query.environment,
secretPath: req.query.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -711,7 +729,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -890,7 +908,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -1005,7 +1023,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -1123,7 +1141,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -1240,7 +1258,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});
@ -1345,7 +1363,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
workspaceId: req.body.workspaceId,
environment: req.body.environment,
secretPath: req.body.secretPath,
channel: getUserAgentType(req.headers["user-agent"]),
...req.auditLogInfo
}
});