safelist build status image requests coming from github
Currently almost all calls against API are being rate limited, including build status images. This leads to common requesters such as GitHub's camo proxy to get rate limited and receive a 429 response code. This patch attempts to allow those requests.
This commit is contained in:
parent
1f56dcc645
commit
0156671fc8
|
@ -31,12 +31,18 @@ class Rack::Attack
|
|||
"/auth/post_message/iframe"
|
||||
]
|
||||
|
||||
IMAGE_PATTERN = /^\/([a-z0-9_-]+)\/([a-z0-9_-]+)\.(png|svg)$/
|
||||
|
||||
####
|
||||
# Whitelisted IP addresses
|
||||
whitelist('whitelist client requesting from redis') do |request|
|
||||
Travis.redis.sismember(:api_whitelisted_ips, request.ip)
|
||||
end
|
||||
|
||||
whitelist('safelist build status images when requested by github') do |request|
|
||||
request.user_agent and request.user_agent.start_with?('github-camo') and IMAGE_PATTERN.match(request.path)
|
||||
end
|
||||
|
||||
####
|
||||
# Ban based on: IP address
|
||||
# Ban time: indefinite
|
||||
|
|
Loading…
Reference in New Issue
Block a user