npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

azure-nsg-ban-ips

v0.3.2

Published

Block malicious IPs for some days, perfect for Azure Kubernetes (AKS)

Downloads

24

Readme

azure-nsg-ban-ips

Block attacker IPs for some days, perfect for Azure Kubernetes (AKS).a

This is much better than banning IPs e.g. in NGINX, because attackers don't reach any services at all.

Node.js: npm package

Usage: Code

const nsg = require( 'azure-nsg-ban-ips' )

nsg.login( SERVICE_PRICIPAL_ID, SECRET_KEY, AAD_ID, SUBSCRIPTION_ID, RESSOURCE_GROUP, NSG_NAME )

// clean up and keep ban rules 4 days
await nsg.cleanupOldBlacklists( 4 )

// add IPs to todays blacklist
let todaysBlacklist = await nsg.addIpAddrArrToBlacklist( ['1.2.3.4','6.6.6.6'] )
console.log( 'Todays IPs', todaysBlacklist )

Details: see example.js

Usage: Container

There is a ready to use

  • Node.js App
  • Docker Container
  • Kubernetes Pod (using the Docker container) here: https://github.com/ma-ha/aks-nsg-ingress-ban-ip

This reads the NginX Ingress Controller logs, identify attacks and bans the IP addresses in the NSG.

CI code is provided for easy end-to-end set up of EventHub, LogAnalytics log feed-out etc.

API

Init and get credentials for all following operations first:

login( SERVICE_PRICIPAL_ID, SECRET_KEY, AAD_ID, SUBSCRIPTION_ID, RESSOURCE_GROUP, NSG_NAME )

Clean up NSG rules. Optional parameter: keep ban rules X days, default is 2, max is 13:

cleanupOldBlacklists()
cleanupOldBlacklists( 4 )

Add IP array to todays NSG rule. Returns an array of banned IPs in todays NSG rule.

addIpAddrArrToBlacklist( IP_ADDRESS_ARRAY )

Read and return all secuirity rules in the NSG:

getNsgRules()

Set the base prio number for blacklist rules, e.g.


setNsgBasePrioConfig( 10000 )

Behind the Scenes

This package creates NSG security rules, for example for the NSG which comes with your AKS.

About the rules:

  • one rule is created per day
  • rule names are blacklistYYYYMMDD, for example blacklist20201108
  • rules use prio 1000...1365 (1000 + day in year)
  • rule description field contains created by blacklist job

The description is also used as a filter in the cleanupOldBlacklists() to identify old blacklists to delete.

If you need to set up whitelist rules, you should use a prio with e.g. 200.