Avoid using racially linked language (#5190)

This commit is contained in:
Paul Melnikow
2020-06-08 22:28:53 -04:00
committed by GitHub
parent 36e1d30631
commit 4582ea1c56
2 changed files with 4 additions and 4 deletions

View File

@@ -20,12 +20,12 @@ function setRoutes({ rateLimit }, { server, metricInstance }) {
const ipRateLimit = new RateLimit({
// Exclude IPs for GitHub Camo, determined experimentally by running e.g.
// `curl --insecure -u ":shields-secret" https://s0.shields-server.com/sys/rate-limit`
whitelist: /^(?:192\.30\.252\.\d+)|(?:140\.82\.115\.\d+)$/,
safelist: /^(?:192\.30\.252\.\d+)|(?:140\.82\.115\.\d+)$/,
})
const badgeTypeRateLimit = new RateLimit({ maxHitsPerPeriod: 3000 })
const refererRateLimit = new RateLimit({
maxHitsPerPeriod: 300,
whitelist: /^https?:\/\/shields\.io\/$/,
safelist: /^https?:\/\/shields\.io\/$/,
})
server.handle((req, res, next) => {

View File

@@ -10,7 +10,7 @@ module.exports = class RateLimit {
this.maxHitsPerPeriod = options.maxHitsPerPeriod || 500
this.banned = new Set()
this.bannedUrls = new Set()
this.whitelist = options.whitelist || /(?!)/ // Matches nothing by default.
this.safelist = options.safelist || /(?!)/ // Matches nothing by default.
this.interval = setInterval(this.resetHits.bind(this), this.period * 1000)
}
@@ -29,7 +29,7 @@ module.exports = class RateLimit {
const hitsInCurrentPeriod = this.hits.get(reqParam) || 0
if (
reqParam != null &&
!this.whitelist.test(reqParam) &&
!this.safelist.test(reqParam) &&
hitsInCurrentPeriod > this.maxHitsPerPeriod
) {
this.banned.add(reqParam)