-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f35e9a8
commit 82c9fe9
Showing
58 changed files
with
16,576 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
BGPalerter was originally created in February 2019 at NTT Ltd. | ||
|
||
Here is a list of authors and contributors who patched or extended the code. | ||
If this list is not up to date, please contact NTT or one of the authors. | ||
|
||
- AUTHORS - | ||
|
||
Massimo Candela <massimo@ntt.net> | ||
NTT | ||
https://massimocandela.com/ | ||
|
||
- CONTRIBUTORS - | ||
Damian Zaremba, Fastly | ||
Mircea Ulinic, DigitalOcean | ||
Alan Haynes, Harbin Clinic | ||
Florian Domain, Criteo | ||
Louis Poinsignon, Cloudflare | ||
See complete list at https://github.com/nttgin/BGPalerter/graphs/contributors | ||
|
||
Special thanks to: | ||
Job Snijders <job@openbsd.org> for OpenBSD rpki-client (https://www.rpki-client.org/) | ||
RIPE NCC for the RIS live service (https://ris-live.ripe.net/). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
[![Build Status](https://github.com/nttgin/BGPalerter/workflows/Main/badge.svg)](https://github.com/nttgin/BGPalerter/actions?query=workflow%3AMain) | ||
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) | ||
|
||
# BGPalerter | ||
Self-configuring BGP monitoring tool, which allows you to monitor in **real-time** if: | ||
* any of your prefixes loses visibility; | ||
* any of your prefixes is hijacked; | ||
* your AS is announcing RPKI invalid prefixes (e.g., not matching prefix length); | ||
* your AS is announcing prefixes not covered by ROAs; | ||
* any of your ROAs is expiring; | ||
* ROAs covering your prefixes are no longer reachable; | ||
* RPKI Trust Anchors malfunctions; | ||
* a ROA involving any of your prefixes or ASes was deleted/added/edited; | ||
* your AS is announcing a new prefix that was never announced before; | ||
* an unexpected upstream (left-side) AS appears in an AS path; | ||
* an unexpected downstream (right-side) AS appears in an AS path; | ||
* one of the AS paths used to reach your prefix matches a specific condition defined by you. | ||
|
||
You just run it. You don't need to provide any data source or connect it to anything in your network since it connects to [public repos](docs/datasets.md). | ||
|
||
It can deliver alerts on files, email, kafka, slack, and more. | ||
|
||
![BGPalerter](http://massimocandela.com/img/bgpalerter_github_image.png) | ||
|
||
> BGPalerter connects to public BGP data repos (not managed by NTT), and the entire monitoring is done directly in the application (there are no NTT servers involved). | ||
## TL;DR (1 minute setup) | ||
> This section is useful if you don't care about the source code, but you just want to start monitoring. | ||
Instead, if you want to run the source code or develop, skip to the documentation below. | ||
|
||
1. Download the binary [here](https://github.com/nttgin/BGPalerter/releases) (be sure to select the one for your OS) | ||
|
||
2. Execute the binary (e.g., `chmod +x bgpalerter-linux-x64 && ./bgpalerter-linux-x64`) | ||
The first time you run it, the auto-configuration will start. | ||
|
||
|
||
If something happens (e.g., a hijack) you will see the alerts in `logs/reports.log`. | ||
In `config.yml` you can find other reporting mechanisms (e.g., email, Slack, Kafka) in addition to logging on files. Uncomment the related section and configure according to your needs. | ||
|
||
If the installation doesn't go smoothly, read [here](docs/installation.md). Read the documentation below for more options. | ||
|
||
> If you are looking for a BGP and RPKI monitoring service based on BGPalerter, try [PacketVis](https://packetvis.com) | ||
## Documentation | ||
|
||
- [Installation](docs/installation.md) | ||
- [Requirements](docs/installation.md#requirements) | ||
- [Run from binary](docs/installation.md#running-bgpalerter-from-binaries) | ||
- [Run from source code](docs/installation.md#running-bgpalerter-from-the-source-code) | ||
- [Build Debian Package](docs/installation.md#build-debian-package) | ||
- [Run in Docker](docs/installation.md#running-bgpalerter-in-docker) | ||
- [Run as a Linux service](docs/linux-service.md) | ||
- [Command line options](docs/installation.md#bgpalerter-parameters) | ||
- [Monitored prefixes list](docs/prefixes.md#prefixes) | ||
- [Generate prefix list](docs/prefixes.md#generate) | ||
- [Prefix attributes description](docs/prefixes.md#prefixes-fields) | ||
- [Configuration](docs/configuration.md) | ||
- [Composition](docs/configuration.md#composition) | ||
- [Monitor for](docs/configuration.md#monitors) | ||
- [Hijacks](docs/configuration.md#monitorhijack) | ||
- [Path neighbors (downstream/upstream peers)](docs/path-neighbors.md) | ||
- [Visibility loss](docs/configuration.md#monitorvisibility) | ||
- [RPKI invalid announcements](docs/configuration.md#monitorrpki) | ||
- [RPKI ROAs diffs, ROAs expirations, and TA malfunctions](docs/configuration.md#monitorroas) | ||
- [Announcements of more specifics](docs/configuration.md#monitornewprefix) | ||
- [Announcements of new prefixes](docs/configuration.md#monitoras) | ||
- [Path matching](docs/configuration.md#monitorpath) | ||
- [Send alerts to](docs/reports.md#reports) | ||
- [File](docs/reports.md#reportfile) | ||
- [E-mail](docs/reports.md#reportemail) | ||
- [Slack](docs/reports.md#reportslack) | ||
- [Kafka](docs/reports.md#reportkafka) | ||
- [Syslog](docs/reports.md#reportsyslog) | ||
- [Alerta dashboard](docs/reports.md#reportalerta) | ||
- [Webex](docs/reports.md#reportwebex) | ||
- [Telegram](docs/reports.md#reporttelegram) | ||
- [Mattermost](docs/reports.md#mattermost) | ||
- [Pushover](docs/report-http.md#pushover) | ||
- [Microsoft Teams](docs/report-http.md#ms-teams) | ||
- [Matrix](docs/reports.md#reportmatrix) | ||
- [HTTP URL (push)](docs/reports.md#reporthttp) | ||
- [REST API (pull)](docs/reports.md#reportpullapi) | ||
- [Test report configuration](docs/installation.md#bgpalerter-parameters) | ||
- [Process/Uptime monitoring](docs/process-monitors.md) | ||
- [Notification user groups](docs/usergroups.md) | ||
- [RPKI configuration](docs/rpki.md) | ||
- [Staging/testing ROAs](docs/rpki.md#stagingtesting-roas) | ||
- [HTTP/HTTPS proxy](docs/http-proxy.md) | ||
- [Update to latest version](docs/update.md) | ||
- [More information for developers](docs/develop.md) | ||
- [All npm commands](docs/develop.md#all-npm-commands) | ||
- [Reports/alerts templates](docs/context.md) | ||
- [Release process and Git flow](docs/release-process.md) | ||
- [BGPalerter for researchers](docs/research.md) | ||
|
||
|
||
|
||
If you are using BGPalerter, feel free to sign here: [Who is using BGPalerter](docs/friends.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
"use strict"; | ||
|
||
var _yargs = _interopRequireDefault(require("yargs")); | ||
var _fs2 = _interopRequireDefault(require("fs")); | ||
var _jsYaml = _interopRequireDefault(require("js-yaml")); | ||
var _os = _interopRequireDefault(require("os")); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } | ||
/* | ||
* BSD 3-Clause License | ||
* | ||
* Copyright (c) 2019, NTT Ltd. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* | ||
* Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
var params = _yargs["default"].usage('Usage: $0 <command> [options]').command('$0', 'Run BGPalerter (default)', function () { | ||
_yargs["default"].alias('v', 'version').nargs('v', 0).describe('v', 'Show version number').alias('c', 'config').nargs('c', 1).describe('c', 'Config file to load').alias('t', 'test').nargs('t', 0).describe('t', 'Test the configuration with fake BGP updates').alias('M', 'skip-memory-check').nargs('M', 0).describe('M', 'Skip memory check').alias('d', 'data-volume').nargs('d', 1).describe('d', 'A directory where configuration and data is persisted'); | ||
}).command('generate', 'Generate prefixes to monitor', function () { | ||
_yargs["default"].alias('v', 'version').nargs('v', 0).describe('v', 'Show version number').alias('o', 'output').nargs('o', 1).describe('o', 'Write to file').alias('a', 'asn').nargs('a', 1).describe('a', 'AS number to monitor').alias('e', 'exclude').nargs('e', 1).describe('e', 'Comma-separated list of prefixes to exclude').alias('p', 'prefixes').nargs('p', 1).describe('p', 'Comma-separated list of prefixes to include').alias('l', 'prefixes-file').nargs('l', 1).describe('l', 'File containing the prefixes to include in the monitoring. One prefix for each line').alias('i', 'ignore-delegated').nargs('i', 0).describe('i', 'Ignore delegated prefixes').alias('s', 'monitor-as').nargs('s', 1).describe('s', 'List of monitored ASes to be added for generic monitoring in options.monitorASns.').alias('m', 'monitor-as-origin').nargs('m', 0).describe('m', 'Automatically generate list of monitored ASes (options.monitorASns) from prefix origins.').alias('x', 'proxy').nargs('x', 1).describe('x', 'HTTP/HTTPS proxy to use').alias('g', 'group').nargs('g', 1).describe('x', 'Define a user group for all the generated rules.').alias('A', 'append').nargs('A', 0).describe('A', 'Append the new configuration to the previous one.').alias('D', 'debug').nargs('D', 0).describe('D', 'Provide verbose output for debugging').alias('H', 'historical').nargs('H', 0).describe('H', 'Use historical visibility data for generating prefix list (prefixes visible in the last week).').alias('u', 'upstreams').nargs('u', 0).describe('u', 'Detect a list of allowed upstream ASes and enable detection of new left-side ASes').alias('n', 'downstreams').nargs('n', 0).describe('n', 'Detect a list of allowed downstream ASes and enable detection of new right-side ASes.').demandOption(['o']); | ||
}).example('$0 generate -a 2914 -o prefixes.yml', 'Generate prefixes for AS2914').help('h').alias('h', 'help').epilog('Copyright (c) 2019, NTT Ltd').argv; | ||
switch (params._[0]) { | ||
case "generate": | ||
var generatePrefixes = require("./src/generatePrefixesList"); | ||
var debug = !!params.D; | ||
var historical = !!params.H; | ||
var prefixes = null; | ||
var monitoredASes = false; | ||
if (params.pf) { | ||
throw new Error("The argument --pf has been deprecated. Use -l instead"); | ||
} | ||
if (params.p && params.l) { | ||
throw new Error("The argument -p is not compatible with the argument -l"); | ||
} else if (params.p) { | ||
prefixes = params.p.split(","); | ||
} else if (params.l) { | ||
var _fs = require("fs"); | ||
if (_fs.existsSync(params.l)) { | ||
prefixes = _fs.readFileSync(params.l, 'utf8').split(/\r?\n/).filter(function (i) { | ||
return i && true; | ||
}); | ||
} else { | ||
throw new Error("The prefix list file (-l) is not readable"); | ||
} | ||
} | ||
if (params.s && params.m) { | ||
throw new Error("You can specify -s or -m, not both"); | ||
} else if (params.s) { | ||
monitoredASes = params.s ? params.s.toString().split(",") : null; | ||
} else if (params.m) { | ||
monitoredASes = true; | ||
} | ||
var inputParameters = { | ||
asnList: params.a ? params.a.toString().split(",") : null, | ||
outputFile: params.o, | ||
exclude: params.e ? params.e.toString().split(",") : null, | ||
excludeDelegated: params.i || false, | ||
prefixes: prefixes, | ||
monitoredASes: monitoredASes, | ||
httpProxy: params.x || null, | ||
debug: debug, | ||
historical: historical, | ||
group: params.g || null, | ||
append: !!params.A, | ||
logger: null, | ||
upstreams: !!params.u, | ||
downstreams: !!params.n, | ||
getCurrentPrefixesList: function getCurrentPrefixesList() { | ||
return Promise.resolve(_jsYaml["default"].load(_fs2["default"].readFileSync(params.o, "utf8"))); | ||
} | ||
}; | ||
if (!inputParameters.outputFile) { | ||
throw new Error("Output file not specified"); | ||
} | ||
generatePrefixes(inputParameters).then(function (content) { | ||
_fs2["default"].writeFileSync(params.o, _jsYaml["default"].dump(content)); | ||
process.exit(0); | ||
}); | ||
break; | ||
default: | ||
// Run monitor | ||
|
||
if (!params.M && _os["default"].totalmem() < 4294967296) { | ||
throw new Error("You need 4GB of RAM to run BGPalerter"); | ||
} | ||
global.DRY_RUN = !!params.t; | ||
if (global.DRY_RUN) console.log("Testing BGPalerter configuration. WARNING: remove -t option for production monitoring."); | ||
var Worker = require("./src/worker")["default"]; | ||
module.exports = new Worker({ | ||
configFile: params.c, | ||
volume: params.d, | ||
groupFile: params.E | ||
}); | ||
} |
Oops, something went wrong.