Skip to content

Commit

Permalink
Merge pull request #23 from polarityio/develop
Browse files Browse the repository at this point in the history
Add summary tags to REST API output
  • Loading branch information
sarus committed Apr 29, 2024
2 parents 92dda31 + b705e94 commit ed8568d
Show file tree
Hide file tree
Showing 4 changed files with 831 additions and 705 deletions.
40 changes: 38 additions & 2 deletions integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function buildLookupResults(entity, options, cb) {
entity: result.entity,
isVolatile: true,
data: {
summary: [],
summary: ['Not Found'],
details: {
canSubmitUrl
}
Expand All @@ -369,14 +369,50 @@ function buildLookupResults(entity, options, cb) {
cb(null, {
entity,
data: {
summary: [],
summary: getSummaryTags(result.body),
details: result.body
}
});
}
});
}

function getSummaryTags(details) {
const tags = [];
let overallVerdict = _.get(details, 'results.0.verdicts.overall', {});
if (overallVerdict.malicious) {
tags.push('Malicious');
} else {
tags.push('Not Malicious');
}

if (typeof overallVerdict.score !== 'undefined') {
tags.push(`Score: ${overallVerdict.score}`);
}

if (Array.isArray(overallVerdict.tags)) {
overallVerdict.tags.forEach((tag) => tags.push(`Verdict: ${tag}`));
}

if (Array.isArray(overallVerdict.categories)) {
overallVerdict.categories.forEach((tag) => tags.push(`Category: ${tag}`));
}

if (Array.isArray(overallVerdict.brands)) {
overallVerdict.brands.forEach((brand) => tags.push(`Brand: ${brand}`));
}

if (details.total) {
tags.push(`Results: ${details.total}`);
}

if (details.searchLimitTag) {
tags.push(`Daily Searches Remmaining: ${details.searchLimitTag}`);
}

return tags;
}

function searchIndicator(entity, options, cb) {
let requestOptions = {
uri: `${API_URL}/v1/search`,
Expand Down
Loading

0 comments on commit ed8568d

Please sign in to comment.