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

Add port number to the vulnerability key #238

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/steps/vulnerabilities/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,27 +244,6 @@ export function createVulnerabilityEntity(
): Entity {
const numericPriority = vuln.plugin.vpr && vuln.plugin.vpr.score;
const priority = numericPriority && getPriority(numericPriority);
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer necessary. SDK manages this.

const size = Buffer.byteLength(JSON.stringify(vuln));
if (size > 1048576) {
logger.info(
{
asset_uuid: vuln.asset.uuid,
cves: vuln.plugin.cve,
scanId: vuln.scan.uuid,
pluginId: vuln.plugin.id,
totalSize: size,
largetsItem: getLargestItemKeyAndByteSize(vuln),
},
'Encountered entity of size > 1MB',
);
}
} catch (err) {
logger.warn({ err }, 'Encountered error when checking entity size');
}
// The output property is often _very_ large.
// We may in the future come up with some use-cases for this property and may
// want to do some more fine-grained trimming of this property

delete vuln.output;

Expand All @@ -274,7 +253,7 @@ export function createVulnerabilityEntity(
assign: {
_key: generateEntityKey(
Entities.VULNERABILITY._type,
`${vuln.scan.uuid}_${vuln.plugin.id}_${vuln.asset.uuid}`,
`${vuln.scan.uuid}_${vuln.plugin.id}_${vuln.asset.uuid}_${vuln.port.port}`,
),
_type: Entities.VULNERABILITY._type,
_class: Entities.VULNERABILITY._class,
Expand Down
2 changes: 1 addition & 1 deletion src/steps/vulnerabilities/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('fetch-vulnerabilities', () => {
await fetchVulnerabilities(context);

const vulnerabilityEntities = context.jobState.collectedEntities;
expect(vulnerabilityEntities.length).toBe(58);
expect(vulnerabilityEntities.length).toBe(101);

/* // TODO (INT-4010): add required props
expect(vulnerabilityEntities).toMatchGraphObjectSchema({
Expand Down
Loading