Skip to content

Commit

Permalink
Merge pull request #7 from polarityio/develop
Browse files Browse the repository at this point in the history
Updating Github Actions & Adding config.json
  • Loading branch information
ntsmith7 committed Jan 24, 2023
2 parents 0531b45 + e38d17d commit 2cf9935
Show file tree
Hide file tree
Showing 6 changed files with 793 additions and 74 deletions.
57 changes: 5 additions & 52 deletions .github/workflows/release-current-version.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,11 @@
# This workflow will run on merge of a PR or push to master
# It will run the integration developement checklist and if that passes
# creates a new release with the Release and Tag name both being the
# package.json version and will with a created tgz file and the SHA256 has in the release body


name: Release Current Version

on:
push:
branches: [ master ]
branches: [ master, main ]

jobs:
release-current-version:
runs-on: ubuntu-latest
container: 'centos:7'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Get NPM Version
id: package-version
uses: martinbeentjes/npm-get-version-action@95bc31c6dd3145896c110e382f840bb1e750d09c
- name: Create Build
id: create_build
run: |
npm install &&
cd .. &&
tar --exclude="./${{ github.event.repository.name }}/.git" --exclude="./${{ github.event.repository.name }}/.gitignore" --exclude="./${{ github.event.repository.name }}/package-lock.json" --exclude="./${{ github.event.repository.name }}/.github" -czvf "${{ github.event.repository.name }}-${{ steps.package-version.outputs.current-version }}.tgz" "./${{ github.event.repository.name }}" &&
echo "::set-output name=build_hash::$(sha256sum '${{ github.event.repository.name }}-${{ steps.package-version.outputs.current-version }}.tgz' | grep -oE '^[^ ]*' )" &&
cd ${{ github.event.repository.name }}
- name: Polarity Integration Development Checklist
id: int-dev-checklist
uses: polarityio/polarity-integration-development-checklist@v1.0.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Versioned Release
id: create_versioned_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.package-version.outputs.current-version}}
release_name: ${{ steps.package-version.outputs.current-version}}
body: |
SHA256: ${{ steps.create_build.outputs.build_hash }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_versioned_release.outputs.upload_url }}
asset_path: ../${{ github.event.repository.name }}-${{ steps.package-version.outputs.current-version}}.tgz
asset_name: ${{ github.event.repository.name }}-${{ steps.package-version.outputs.current-version}}.tgz
asset_content_type: application/gzip
Run:
uses: polarityio/polarity-github-actions/.github/workflows/release-server-versions-for-int-store.yml@master
# with:
# use-integration-development-checklist: false
10 changes: 3 additions & 7 deletions .github/workflows/run-int-dev-checklist.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# This workflow will run on a Pull Request is created on both master develop
# It run as series of checks from the Integration Developement Checklist


name: Run Integration Development Checklist

on:
pull_request:
branches: [ master, develop ]
branches: [ master, main, develop ]

jobs:
run-integration-development-checklist:
Expand All @@ -19,9 +15,9 @@ jobs:
- name: Test NPM Install
id: test-npm-install
run: |
npm install
npm ci
- name: Polarity Integration Development Checklist
id: int-dev-checklist
uses: polarityio/polarity-integration-development-checklist@v1.0.0
uses: polarityio/polarity-integration-development-checklist@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87 changes: 87 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"name": "American Registry for Internet Numbers (ARIN)",
"acronym": "ARIN",
"logging": {
"level": "info"
},
"entityTypes": [
"IPv4",
"IPv6"
],
"description": "ARIN Integration",
"defaultColor": "light-gray",
"styles": [
"./styles/arin.less"
],
"block": {
"component": {
"file": "./component/block.js"
},
"template": {
"file": "./template/block.hbs"
}
},
"summary": {
"component": {
"file": "./component/summary.js"
},
"template": {
"file": "./template/summary.hbs"
}
},
"request": {
"cert": "",
"key": "",
"passphrase": "",
"ca": "",
"proxy": "",
"rejectUnauthorized": true
},
"options": [
{
"key": "blocklist",
"name": "Blocklist IPs",
"description": "List of IPs that you never want sent to ARIN.",
"default": "",
"type": "text",
"userCanEdit": false,
"adminOnly": false
},
{
"key": "ipBlocklistRegex",
"name": "IP Block List Regex",
"description": "IPs that match the given regex will not be looked up (if blank, no IPs will be block listed)",
"default": "",
"type": "text",
"userCanEdit": false,
"adminOnly": false
},
{
"key": "allRegistries",
"name": "Display Regional Registry Ownership Information",
"description": "If checked, the integration will return a result when the IP address is controlled by one of the non-ARIN regional Internet registries (i.e., RIPE, APNIC, AFRINIC, LACNIC) as well as IANA. If unchecked, only IP addresses controlled by ARIN will be returned.",
"default": false,
"type": "boolean",
"userCanEdit": false,
"adminOnly": false
},
{
"key": "maxConcurrent",
"name": "Max Concurrent Requests",
"description": "Maximum number of concurrent requests. Integration must be restarted after changing this option. Defaults to 3.",
"default": 3,
"type": "number",
"userCanEdit": false,
"adminOnly": true
},
{
"key": "minTime",
"name": "Minimum Time Between Lookups",
"description": "Minimum amount of time in milliseconds between lookups (defaults to 250). Integration must be restarted after changing this option. Defaults to 250.",
"default": 250,
"type": "number",
"userCanEdit": false,
"adminOnly": true
}
]
}
20 changes: 10 additions & 10 deletions integration.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const request = require('request');
const request = require('postman-request');
const _ = require('lodash');
const { Address6 } = require('ip-address');
const Bottleneck = require('bottleneck');
Expand All @@ -15,7 +15,7 @@ let limiter = null;

const BASE_URI = 'https://whois.arin.net/rest/ip/';

function startup(logger) {
function startup (logger) {
log = logger;

let defaults = {};
Expand Down Expand Up @@ -47,7 +47,7 @@ function startup(logger) {
requestWithDefaults = request.defaults(defaults);
}

function _setupRegexBlocklists(options) {
function _setupRegexBlocklists (options) {
if (options.ipBlocklistRegex !== previousIpRegexAsString && options.ipBlocklistRegex.length === 0) {
log.debug('Removing IP Blocklist Regex Filtering');
previousIpRegexAsString = '';
Expand All @@ -61,7 +61,7 @@ function _setupRegexBlocklists(options) {
}
}

function isValidIpToLookup(entity, options) {
function isValidIpToLookup (entity, options) {
const blocklist = options.blocklist;

if (_.includes(blocklist, entity.value)) {
Expand All @@ -79,7 +79,7 @@ function isValidIpToLookup(entity, options) {
return false;
}

function _setupLimiter(options) {
function _setupLimiter (options) {
limiter = new Bottleneck({
maxConcurrent: Number.parseInt(options.maxConcurrent, 10), // no more than 5 lookups can be running at single time
highWater: 50, // no more than 50 lookups can be queued up
Expand All @@ -88,7 +88,7 @@ function _setupLimiter(options) {
});
}

function doLookup(entities, options, cb) {
function doLookup (entities, options, cb) {
const lookupResults = [];
const errors = [];
const blockedEntities = [];
Expand Down Expand Up @@ -136,7 +136,7 @@ function doLookup(entities, options, cb) {
lookupResults.push(result);
}

if (lookupResults.length + errors.length + blockedEntities.length === entities.length) {
if (lookupResults.length + errors.length + blockedEntities.length === entities.length) {
if (numConnectionResets > 0 || numThrottled > 0) {
log.warn(
{
Expand Down Expand Up @@ -167,7 +167,7 @@ function doLookup(entities, options, cb) {
}
}

function _processRequest(err, response, body, entityObj, options, cb) {
function _processRequest (err, response, body, entityObj, options, cb) {
if (err) {
log.error({ err: err }, 'Request Error');
cb(
Expand Down Expand Up @@ -292,7 +292,7 @@ function _processRequest(err, response, body, entityObj, options, cb) {
});
}

function _lookupEntity(entityObj, options, cb) {
function _lookupEntity (entityObj, options, cb) {
log.trace('Lookup started on ' + entityObj.value);
requestWithDefaults(
{
Expand Down Expand Up @@ -339,7 +339,7 @@ let _createJsonErrorObject = function (msg, pointer, httpCode, code, title, meta
return error;
};

function onMessage(payload, options, cb) {
function onMessage (payload, options, cb) {
doLookup([payload.entity], options, (err, lookupResults) => {
if (err) {
log.error({ err }, 'Error retrying lookup');
Expand Down
Loading

0 comments on commit 2cf9935

Please sign in to comment.