Avoid using racially linked language (#5190)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user