Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
slight tweak to make blacklisting two tiered, first is a file block a…
Browse files Browse the repository at this point in the history
…nd is non-permanent

second is a repo block, permanent until appealed
  • Loading branch information
schme16 committed Feb 27, 2018
1 parent 5bdb272 commit 006a0ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var favicon = require('zlib').gzipSync(require('fs').readFileSync('website/favic
cdnURL = 'cdn.gitcdn.link',
cache = {},
blacklist = [],
tempBlacklist = [],
collectGarbageInterval = 15000


Expand Down Expand Up @@ -93,7 +94,7 @@ function repoFunc (req, res) {
if (meta.gist) meta.raw.shift()
meta.branch = meta.raw.shift()
meta.filePath = meta.raw.join('/')
if (blacklist.indexOf(meta.user + '/' + meta.repo) > -1 ) {
if (blacklist.indexOf(meta.user + '/' + meta.repo) > -1 || tempBlacklist.indexOf(meta.filePath) > -1) {
res.status(403).send("Forbidden - This repo/gist is on the blacklist. If you wish to appeal, please open an issue here: https://github.com/schme16/gitcdn.xyz/issues, with why you feel this repo should not be on the blacklist.")
return false
}
Expand Down Expand Up @@ -129,14 +130,13 @@ function repoFunc (req, res) {
else { //Error
if (!refreshCache) res.sendStatus(500)
console.log("Error: " + 'SHA1 hash is missing in /repo -> request: ' + req.originalUrl + ' JSON=' + JSON.stringify(body))
blacklist.push(meta.user + '/' + meta.repo)
tempBlacklist.push(meta.filePath)//meta.user + '/' + meta.repo)

}
}
else { //Error
if (!refreshCache) res.sendStatus(500)
console.log("Error: " + 'Status 500: ' + meta.user + '/' + meta.repo + '/' + body.sha + '/' + meta.filePath)
//blacklist.push(meta.user + '/' + meta.repo)

}
meta = null
Expand All @@ -159,7 +159,7 @@ function lastCall (meta, sha, req, res, cacheing) {
else {
if (!cacheing) res.sendStatus(500)
console.log("Error: " + 'Status 500: SHA1 hash is missing in lastCall() || ' + meta.user + '/' + meta.repo + '/' + sha + '/' + meta.filePath)
blacklist.push(meta.user + '/' + meta.repo)
tempBlacklist.push(meta.filePath)//meta.user + '/' + meta.repo)
}
}

Expand Down

0 comments on commit 006a0ff

Please sign in to comment.