Final tweaks

This commit is contained in:
x032205
2025-07-03 22:18:40 -04:00
parent 5badb811e1
commit aea43c0a8e
2 changed files with 9 additions and 30 deletions
@@ -44,6 +44,8 @@ export const BitbucketSecretScanningFactory = () => {
TBitbucketConnection, TBitbucketConnection,
TBitbucketDataSourceCredentials TBitbucketDataSourceCredentials
> = async ({ connection, payload }, callback) => { > = async ({ connection, payload }, callback) => {
const cfg = getConfig();
const { email, apiToken } = connection.credentials; const { email, apiToken } = connection.credentials;
const authHeader = `Basic ${Buffer.from(`${email}:${apiToken}`).toString("base64")}`; const authHeader = `Basic ${Buffer.from(`${email}:${apiToken}`).toString("base64")}`;
@@ -51,7 +53,7 @@ export const BitbucketSecretScanningFactory = () => {
`${IntegrationUrls.BITBUCKET_API_URL}/2.0/workspaces/${payload.config.workspaceSlug}/hooks`, `${IntegrationUrls.BITBUCKET_API_URL}/2.0/workspaces/${payload.config.workspaceSlug}/hooks`,
{ {
description: "Infisical webhook for push events", description: "Infisical webhook for push events",
url: `https://tunnel.util.lol/secret-scanning/webhooks/bitbucket`, // TODO(andrey): Swap to ${cfg.SITE_URL} url: `${cfg.SITE_URL}/secret-scanning/webhooks/bitbucket`,
active: true, active: true,
events: ["repo:push"] events: ["repo:push"]
}, },
@@ -140,9 +142,9 @@ export const BitbucketSecretScanningFactory = () => {
filteredRepos.push(...repos.filter((repo) => includeRepos.includes(repo.full_name))); filteredRepos.push(...repos.filter((repo) => includeRepos.includes(repo.full_name)));
} }
return filteredRepos.map(({ slug, full_name }) => ({ return filteredRepos.map(({ full_name }) => ({
name: full_name, name: full_name,
externalId: slug.toString(), externalId: full_name,
type: SecretScanningResource.Repository type: SecretScanningResource.Repository
})); }));
}; };
@@ -176,10 +178,10 @@ export const BitbucketSecretScanningFactory = () => {
const getDiffScanResourcePayload: TSecretScanningFactoryGetDiffScanResourcePayload< const getDiffScanResourcePayload: TSecretScanningFactoryGetDiffScanResourcePayload<
TQueueBitbucketResourceDiffScan["payload"] TQueueBitbucketResourceDiffScan["payload"]
> = ({ repository, dataSourceId }) => { > = ({ repository }) => {
return { return {
name: repository.full_name, name: repository.full_name,
externalId: dataSourceId, externalId: repository.full_name,
type: SecretScanningResource.Repository type: SecretScanningResource.Repository
}; };
}; };
@@ -9,28 +9,6 @@ export const bitBucketSecretScanningService = (
secretScanningV2DAL: TSecretScanningV2DALFactory, secretScanningV2DAL: TSecretScanningV2DALFactory,
secretScanningV2Queue: Pick<TSecretScanningV2QueueServiceFactory, "queueResourceDiffScan"> secretScanningV2Queue: Pick<TSecretScanningV2QueueServiceFactory, "queueResourceDiffScan">
) => { ) => {
const handleInstallationDeletedEvent = async (installationId: number) => {
const dataSource = await secretScanningV2DAL.dataSources.findOne({
externalId: String(installationId),
type: SecretScanningDataSource.Bitbucket
});
if (!dataSource) {
logger.error(
`secretScanningV2RemoveEvent: Bitbucket - Could not find data source [installationId=${installationId}]`
);
return;
}
logger.info(
`secretScanningV2RemoveEvent: Bitbucket - installation deleted [installationId=${installationId}] [dataSourceId=${dataSource.id}]`
);
await secretScanningV2DAL.dataSources.updateById(dataSource.id, {
isDisconnected: true
});
};
const handlePushEvent = async (payload: TBitbucketPushEvent & { dataSourceId: string }) => { const handlePushEvent = async (payload: TBitbucketPushEvent & { dataSourceId: string }) => {
const { push, repository } = payload; const { push, repository } = payload;
@@ -44,7 +22,7 @@ export const bitBucketSecretScanningService = (
} }
const dataSource = (await secretScanningV2DAL.dataSources.findOne({ const dataSource = (await secretScanningV2DAL.dataSources.findOne({
externalId: payload.dataSourceId, id: payload.dataSourceId,
type: SecretScanningDataSource.Bitbucket type: SecretScanningDataSource.Bitbucket
})) as TBitbucketDataSource | undefined; })) as TBitbucketDataSource | undefined;
@@ -81,7 +59,6 @@ export const bitBucketSecretScanningService = (
}; };
return { return {
handlePushEvent, handlePushEvent
handleInstallationDeletedEvent
}; };
}; };