Skip to content

Commit

Permalink
Simplifying usage monitor email format
Browse files Browse the repository at this point in the history
  • Loading branch information
tstibbs committed Oct 14, 2023
1 parent 9a503f5 commit 1d7999b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion aws/environment-setup/src/ip-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ export async function getIpInfo(ips) {
risk = 'medium'
}
let description = `${entry.country} > ${entry.region} > ${entry.city} (${entry.org})`
let shortDescription = `${entry.country} (${entry.org})`
return [
ip,
{
risk,
description
description,
shortDescription
}
]
})
Expand Down
8 changes: 4 additions & 4 deletions aws/environment-setup/src/usage-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,17 @@ function formatResultsForEmail(allResults, ipInfo) {
let {count, sourceIp, geoBlocked} = stackResult
let ipDescriptor = sourceIp
if (sourceIp in ipInfo) {
let {description, risk} = ipInfo[sourceIp]
let {shortDescription, risk} = ipInfo[sourceIp]
risk = `${risk} risk`
if (geoBlocked) {
risk = `${risk} (${geoBlocked})`
}
let descriptionRegex = /^([^\(]+\()AS\d+ (.+\))$/
let regexMatch = description.match(descriptionRegex)
let regexMatch = shortDescription.match(descriptionRegex)
if (regexMatch != null) {
description = `${regexMatch[1]}${regexMatch[2]}`
shortDescription = `${regexMatch[1]}${regexMatch[2]}`
}
ipDescriptor = `${risk}: ${description}`
ipDescriptor = `${risk}: ${shortDescription}`
}
if (!(ipDescriptor in ipsToCount)) {
ipsToCount[ipDescriptor] = 0
Expand Down

0 comments on commit 1d7999b

Please sign in to comment.