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

INT-6423 Asset tags support #215

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 22 additions & 2 deletions src/steps/vulnerabilities/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import {
IntegrationLogger,
parseTimePropertyValue,
} from '@jupiterone/integration-sdk-core';

import { Entities } from '../constants';
import { AssetExport, VulnerabilityExport } from '../../tenable/client';
import {
AssetExport,
AssetExportTag,
VulnerabilityExport,
} from '../../tenable/client';
import { generateEntityKey } from '../../utils/generateKey';
import { TargetEntity } from '../../utils/targetEntities';

Expand All @@ -31,6 +36,21 @@ export function getLargestItemKeyAndByteSize(data: any): KeyAndSize {
return largestItem;
}

export function getTagProperties(data?: AssetExportTag[]) {
if (!data) return {};

let tagKey;
return data.reduce((obj, curTag) => {
tagKey = `tags.${curTag.key}`;
if (Object.keys(obj).indexOf(tagKey) != -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not tagKey in obj?

obj[tagKey] = [...obj[tagKey], curTag.value];
} else {
obj[tagKey] = [curTag.value];
}
return obj;
}, {});
}

export function createAssetEntity(
data: AssetExport,
logger: IntegrationLogger,
Expand Down Expand Up @@ -124,7 +144,7 @@ export function createAssetEntity(
servicenowSysid: data.servicenow_sysid,
// bigfix
bigfixAssetId: data.bigfix_asset_id,
tags: data.tags?.map((tag) => `${tag.key}=${tag.value}`),
...getTagProperties(data.tags),
// TODO Add sources, tags, networkInterfaces
// sources: data.sources,
// networkInterfaces: data.network_interfaces,
Expand Down