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

Commit

Permalink
log USE_ON_DISK_DKT env var
Browse files Browse the repository at this point in the history
  • Loading branch information
RonaldEAM committed May 14, 2024
1 parent 737fe41 commit 52facc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/steps/vulnerabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
createIntegrationEntity,
Entity,
IntegrationError,
IntegrationInfoEventName,
IntegrationStep,
IntegrationStepExecutionContext,
RelationshipClass,
Expand All @@ -23,22 +24,7 @@ import {
} from '../types';
import { getAssetKey } from './assets';
import { open } from 'lmdb';

function formatMemoryUsage(data: number) {
return `${Math.round((data / 1024 / 1024) * 100) / 100} MB`;
}

function getMemoryUsage() {
const memoryData = process.memoryUsage();

const memoryUsage = {
rss: formatMemoryUsage(memoryData.rss), // Resident Set Size - total memory allocated for the process execution
heapTotal: formatMemoryUsage(memoryData.heapTotal), // total size of the allocated heap
heapUsed: formatMemoryUsage(memoryData.heapUsed), // actual memory used during the execution
external: formatMemoryUsage(memoryData.external), // V8 external memory
};
return memoryUsage;
}
import { getMemoryUsage } from '../utils';

function getAssetVulnerabilityKey(
assetId: string,
Expand Down Expand Up @@ -105,6 +91,12 @@ export async function fetchAssetVulnerabilityFindings(
context: IntegrationStepExecutionContext<IntegrationConfig>,
) {
const { logger, instance, jobState } = context;
if (process.env.USE_ON_DISK_DKT) {
logger.publishInfoEvent({
name: IntegrationInfoEventName.Info,
description: 'Using on-disk DKT',
});
}
const apiClient = createAPIClient(instance.config, logger);

const assetVulnCountMap =
Expand Down Expand Up @@ -223,7 +215,7 @@ export async function fetchAssetVulnerabilityFindings(
assetId,
);
if (jobState.hasKey(findingEntity._key)) {
return;
continue;
}
await jobState.addEntity(findingEntity);
debugCounts.findings++;
Expand Down
15 changes: 15 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function formatMemoryUsage(data: number) {
return `${Math.round((data / 1024 / 1024) * 100) / 100} MB`;
}

export function getMemoryUsage() {
const memoryData = process.memoryUsage();

const memoryUsage = {
rss: formatMemoryUsage(memoryData.rss), // Resident Set Size - total memory allocated for the process execution
heapTotal: formatMemoryUsage(memoryData.heapTotal), // total size of the allocated heap
heapUsed: formatMemoryUsage(memoryData.heapUsed), // actual memory used during the execution
external: formatMemoryUsage(memoryData.external), // V8 external memory
};
return memoryUsage;
}

0 comments on commit 52facc2

Please sign in to comment.