Skip to content

Commit

Permalink
Merge pull request #7 from polarityio/develop
Browse files Browse the repository at this point in the history
INT-1054: Add user-agent string to requests to prevent 403 error
  • Loading branch information
sarus committed Jun 12, 2023
2 parents 92a20f1 + f262d1d commit b9cc1a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ const request = require('postman-request');
const config = require('./config/config');
const async = require('async');
const fs = require('fs');
const { version: packageVersion } = require('./package.json');

let Logger;
let requestDefault;

const MAX_CATEGORY_SUMMARY_TAGS = 3;
const USER_AGENT = `abuseipdb-polarity-integration-v${packageVersion}`;

// Categories are returned by the API as Integer IDs. We map those IDs to human readable strings here
// This information comes from: https://www.abuseipdb.com/categories
Expand Down Expand Up @@ -60,7 +62,8 @@ function doLookup(entities, options, cb) {
verbose: true
},
headers: {
Key: options.apiKey
Key: options.apiKey,
'User-Agent': USER_AGENT
},
qs: {
ipAddress: entity.value
Expand Down Expand Up @@ -217,7 +220,10 @@ function _generateTags(result, categories, options) {
let tags = [];

if (typeof result.abuseConfidenceScore !== 'undefined') {
if (result.abuseConfidenceScore >= options.baselineInvestigationThreshold && options.baselineInvestigationThreshold !== -1) {
if (
result.abuseConfidenceScore >= options.baselineInvestigationThreshold &&
options.baselineInvestigationThreshold !== -1
) {
tags.push({
type: 'danger',
text: `Confidence of Abuse: ${result.abuseConfidenceScore}%`
Expand All @@ -233,7 +239,7 @@ function _generateTags(result, categories, options) {
tags.push(`Associated Domain: ${result.domain}`);
}
if (typeof result.totalReports !== 'undefined' && typeof result.numDistinctUsers !== 'undefined') {
if(result.totalReports > 0){
if (result.totalReports > 0) {
tags.push(`${result.totalReports} reports from ${result.numDistinctUsers} distinct users`);
} else {
tags.push('No reports');
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AbuseIPDB",
"version": "3.3.1",
"version": "3.3.2",
"main": "./integration.js",
"private": true,
"dependencies": {
Expand Down

0 comments on commit b9cc1a8

Please sign in to comment.