Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Oct 4, 2019
2 parents 670921e + 7a0c058 commit 0be673a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you want to know more about the source code (which is completely open) please

1. Download the binary [here](https://github.com/nttgin/BGPalerter/releases) (be sure to select the one for your OS)

2. Download [`config.yml.example`](https://raw.githubusercontent.com/nttgin/BGPalerter/master/config.yml.example) as `config.yaml` and [`prefixes.yml`](https://raw.githubusercontent.com/nttgin/BGPalerter/master/prefixes.yml.example) as `prefixes.yml`, and place them in the same directory of the executable (if you skip this step, some default configuration files will be generated during the first execution)
2. Download [`config.yml.example`](https://raw.githubusercontent.com/nttgin/BGPalerter/master/config.yml.example) as `config.yaml` and [`prefixes.yml.example`](https://raw.githubusercontent.com/nttgin/BGPalerter/master/prefixes.yml.example) as `prefixes.yml`, and place them in the same directory of the executable (if you skip this step, some default configuration files will be generated during the first execution)

3. Modify `prefixes.yml` and add the prefixes you want to monitor (or see below how to auto generate this file)

Expand Down
3 changes: 3 additions & 0 deletions connectors/connectorRIS.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ export default class ConnectorRIS extends Connector{
if (message["path"] && message["path"].length) {
path = new Path(message["path"].map(i => new AS(i)));
originAS = path.getLast();
} else {
path = new Path([]);
originAS = null;
}

for (let announcement of announcements) {
Expand Down
20 changes: 16 additions & 4 deletions generatePrefixesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
return Promise.all(list.map(i => generateRule(i.prefix, asn, false, null, false)))
.then(() => list.map(i => i.prefix))
})

};

const validatePrefix = (asn, prefix) => {
Expand Down Expand Up @@ -148,7 +149,6 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
} else {
someNotValidatedPrefixes = true;
}

})
};

Expand All @@ -159,11 +159,20 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
return batchPromises(20, prefixes, prefix => {
return getAnnouncedMoreSpecifics(prefix)
.then((items) => Promise
.all(items.map(item => generateRule(item.prefix, item.asn, true, item.description, excludeDelegated))));
.all(items.map(item => generateRule(item.prefix, item.asn, true, item.description, excludeDelegated))))
.catch((e) => {
console.log("Cannot download more specific prefixes of", prefix, e);
})
})
.catch((e) => {
console.log("Cannot download more specific prefixes", e);
})
})
.then(() => {
return Promise.all(Object.keys(generateList).map(prefix => validatePrefix(generateList[prefix].asn[0], prefix)))
.catch((e) => {
console.log("ROA check failed due to error", e);
})
})
.then(() => {
const yamlContent = yaml.dump(generateList);
Expand All @@ -173,6 +182,9 @@ module.exports = function generatePrefixes(asns, outputFile, exclude, excludeDel
console.log("WARNING: The generated configuration is a snapshot of what is currently announced by " + asns + " but some of the prefixes don't have ROA objects associated. Please, verify the config file by hand!");
}
console.log("Done!");
});
})
.catch((e) => {
console.log("Something went wrong", e);
})

}
};
4 changes: 2 additions & 2 deletions inputs/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export default class Input {

const lessSpecifics = [];

lessSpecifics.push(prefixes.pop());
lessSpecifics.push(prefixes[prefixes.length - 1]);


for (let p1 of prefixes) {
for (let p1 of prefixes.slice(0, -1)) {
if (!this._isAlreadyContained(p1.prefix, lessSpecifics)){
lessSpecifics.push(p1);
}
Expand Down
1 change: 1 addition & 0 deletions monitors/monitorPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class MonitorPath extends Monitor {
};

squashAlerts = (alerts) => {
alerts = alerts.filter(i => i.matchedRule && i.matchedRule.path);
const lengthViolation = (alerts.some(i => i.extra.lengthViolation)) ? "(including length violation) " : "";
return `Matched ${alerts[0].matchedRule.path.matchDescription} on prefix ${alerts[0].matchedMessage.prefix} ${lengthViolation}${alerts.length} times.`;
};
Expand Down

0 comments on commit 0be673a

Please sign in to comment.