mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 21:27:31 +00:00
Tweaks
This commit is contained in:
-17
@@ -83,7 +83,6 @@ export const BitBucketSecretScanningFactory = () => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(andrey): Finish
|
|
||||||
const getFullScanPath: TSecretScanningFactoryGetFullScanPath<TBitBucketDataSourceWithConnection> = async ({
|
const getFullScanPath: TSecretScanningFactoryGetFullScanPath<TBitBucketDataSourceWithConnection> = async ({
|
||||||
dataSource,
|
dataSource,
|
||||||
resourceName,
|
resourceName,
|
||||||
@@ -131,8 +130,6 @@ export const BitBucketSecretScanningFactory = () => {
|
|||||||
}
|
}
|
||||||
} = dataSource;
|
} = dataSource;
|
||||||
|
|
||||||
console.log("getDiffScanFindingsPayload");
|
|
||||||
|
|
||||||
const { commits, repository } = payload;
|
const { commits, repository } = payload;
|
||||||
|
|
||||||
const allFindings: SecretMatch[] = [];
|
const allFindings: SecretMatch[] = [];
|
||||||
@@ -175,16 +172,11 @@ export const BitBucketSecretScanningFactory = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(1);
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-continue
|
// eslint-disable-next-line no-continue
|
||||||
if (!patch) continue;
|
if (!patch) continue;
|
||||||
console.log(2);
|
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const findings = await scanContentAndGetFindings(replaceNonChangesWithNewlines(`\n${patch}`), configPath);
|
const findings = await scanContentAndGetFindings(replaceNonChangesWithNewlines(`\n${patch}`), configPath);
|
||||||
console.log(3);
|
|
||||||
console.log(findings);
|
|
||||||
|
|
||||||
const adjustedFindings = findings.map((finding) => {
|
const adjustedFindings = findings.map((finding) => {
|
||||||
const startLine = convertPatchLineToFileLineNumber(patch, finding.StartLine);
|
const startLine = convertPatchLineToFileLineNumber(patch, finding.StartLine);
|
||||||
@@ -195,9 +187,6 @@ export const BitBucketSecretScanningFactory = () => {
|
|||||||
const startColumn = finding.StartColumn - 1; // subtract 1 for +
|
const startColumn = finding.StartColumn - 1; // subtract 1 for +
|
||||||
const endColumn = finding.EndColumn - 1; // subtract 1 for +
|
const endColumn = finding.EndColumn - 1; // subtract 1 for +
|
||||||
|
|
||||||
console.log("finding");
|
|
||||||
console.log(finding.Link);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...finding,
|
...finding,
|
||||||
StartLine: startLine,
|
StartLine: startLine,
|
||||||
@@ -215,17 +204,11 @@ export const BitBucketSecretScanningFactory = () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("adjusted");
|
|
||||||
console.log(adjustedFindings);
|
|
||||||
|
|
||||||
allFindings.push(...adjustedFindings);
|
allFindings.push(...adjustedFindings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("HEREEE");
|
|
||||||
console.log(allFindings);
|
|
||||||
|
|
||||||
return allFindings.map(
|
return allFindings.map(
|
||||||
({
|
({
|
||||||
// discard match and secret as we don't want to store
|
// discard match and secret as we don't want to store
|
||||||
|
|||||||
@@ -13,6 +13,5 @@ export const SECRET_SCANNING_DATA_SOURCE_CONNECTION_MAP: Record<SecretScanningDa
|
|||||||
|
|
||||||
export const AUTO_SYNC_DESCRIPTION_HELPER: Record<SecretScanningDataSource, { verb: string; noun: string }> = {
|
export const AUTO_SYNC_DESCRIPTION_HELPER: Record<SecretScanningDataSource, { verb: string; noun: string }> = {
|
||||||
[SecretScanningDataSource.GitHub]: { verb: "push", noun: "repositories" },
|
[SecretScanningDataSource.GitHub]: { verb: "push", noun: "repositories" },
|
||||||
// TODO(andrey): May need change
|
|
||||||
[SecretScanningDataSource.BitBucket]: { verb: "push", noun: "repositories" }
|
[SecretScanningDataSource.BitBucket]: { verb: "push", noun: "repositories" }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,4 +63,6 @@ export const registerSecretScanningV2Webhooks = async (server: FastifyZodProvide
|
|||||||
return res.send("ok");
|
return res.send("ok");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO(andrey): Register a webhook for BitBucket
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,16 +46,29 @@ export const validateBitBucketConnectionCredentials = async (config: TBitBucketC
|
|||||||
export const listBitBucketRepositories = async (appConnection: TBitBucketConnection) => {
|
export const listBitBucketRepositories = async (appConnection: TBitBucketConnection) => {
|
||||||
const { email, apiToken } = appConnection.credentials;
|
const { email, apiToken } = appConnection.credentials;
|
||||||
|
|
||||||
// TODO(andrey): Support pagination for cases where a token has access to over 100 repos
|
const headers = {
|
||||||
const { data } = await request.get<{ values: TBitBucketRepo[] }>(
|
Authorization: `Basic ${Buffer.from(`${email}:${apiToken}`).toString("base64")}`,
|
||||||
`${IntegrationUrls.BITBUCKET_API_URL}/2.0/repositories?role=member&pagelen=100`,
|
Accept: "application/json"
|
||||||
{
|
};
|
||||||
headers: {
|
|
||||||
Authorization: `Basic ${Buffer.from(`${email}:${apiToken}`).toString("base64")}`,
|
|
||||||
Accept: "application/json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return data.values;
|
let allRepos: TBitBucketRepo[] = [];
|
||||||
|
let nextUrl: string | undefined = `${IntegrationUrls.BITBUCKET_API_URL}/2.0/repositories?role=member&pagelen=100`;
|
||||||
|
let iterationCount = 0;
|
||||||
|
|
||||||
|
// Limit to 10 iterations, fetching at most 10 * 100 = 1000 repositories
|
||||||
|
while (nextUrl && iterationCount < 10) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
const { data }: { data: { values: TBitBucketRepo[]; next?: string } } = await request.get<{
|
||||||
|
values: TBitBucketRepo[];
|
||||||
|
next?: string;
|
||||||
|
}>(nextUrl, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
|
||||||
|
allRepos = allRepos.concat(data.values);
|
||||||
|
nextUrl = data.next;
|
||||||
|
iterationCount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return allRepos;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export const bitBucketConnectionService = (getAppConnection: TGetAppConnectionFu
|
|||||||
|
|
||||||
const repositories = await listBitBucketRepositories(appConnection);
|
const repositories = await listBitBucketRepositories(appConnection);
|
||||||
|
|
||||||
// TODO(andrey): May need to change from slug to ID or something
|
|
||||||
return repositories.map((repo) => ({ id: repo.slug, name: repo.full_name }));
|
return repositories.map((repo) => ({ id: repo.slug, name: repo.full_name }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user