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

Commit

Permalink
validate repository object outside converter
Browse files Browse the repository at this point in the history
  • Loading branch information
RonaldEAM committed Jul 15, 2024
1 parent 50b68a7 commit 827f1e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
16 changes: 6 additions & 10 deletions src/steps/secretScanningAlerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,15 @@ export async function fetchSecretScanningAlerts({
const restClient = getOrCreateRestClient(config, logger);

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

const repoEntityKey =
alert.repository?.node_id &&
getRepositoryEntityKey(alert.repository.node_id);

if (repoEntityKey && jobState.hasKey(repoEntityKey)) {
const repoEntityKey = getRepositoryEntityKey(alert.repository.node_id);
if (jobState.hasKey(repoEntityKey)) {
await jobState.addRelationship(
createDirectRelationship({
_class: RelationshipClass.HAS,
Expand Down
3 changes: 0 additions & 3 deletions src/sync/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,6 @@ export function getSecretScanningAlertKey(
export function createSecretScanningAlertEntity(
data: SecretScanningAlertQueryResponse,
) {
if (!data.repository) {
return;
}
return createIntegrationEntity({
entityData: {
source: data,
Expand Down

0 comments on commit 827f1e8

Please sign in to comment.