Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
add repo id to secret scanning finding _key
Browse files Browse the repository at this point in the history
  • Loading branch information
RonaldEAM committed Jul 15, 2024
1 parent d17a531 commit 50b68a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/steps/secretScanningAlerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ export async function fetchSecretScanningAlerts({
const restClient = getOrCreateRestClient(config, logger);

await restClient.iterateSecretScanningAlerts(async (alert) => {
const secretScanningAlertEntity = (await jobState.addEntity(
createSecretScanningAlertEntity(alert),
)) as SecretScanningFindingEntity;
const secretScanningAlertEntity = createSecretScanningAlertEntity(
alert,
) as SecretScanningFindingEntity;
if (!secretScanningAlertEntity) {
return;
}
await jobState.addEntity(secretScanningAlertEntity);

const repoEntityKey =
alert.repository?.node_id &&
Expand Down
13 changes: 10 additions & 3 deletions src/sync/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,27 @@ export function createCodeScanningFindingEntity(
});
}

export function getSecretScanningAlertKey(id: string) {
return `github_secret_scanning_finding:${id}`;
export function getSecretScanningAlertKey(
data: SecretScanningAlertQueryResponse,
) {
return `github_secret_scanning_finding:${data.repository!.node_id}:${
data.number
}`;
}

export function createSecretScanningAlertEntity(
data: SecretScanningAlertQueryResponse,
) {
if (!data.repository) {
return;
}
return createIntegrationEntity({
entityData: {
source: data,
assign: {
_class: GithubEntities.GITHUB_SECRET_SCANNING_ALERT._class,
_type: GithubEntities.GITHUB_SECRET_SCANNING_ALERT._type,
_key: getSecretScanningAlertKey(String(data.number)),
_key: getSecretScanningAlertKey(data),
displayName: data.secret_type_display_name,
name: data.secret_type_display_name,
severity: 'CRITICAL',
Expand Down

0 comments on commit 50b68a7

Please sign in to comment.