Skip to content

Commit

Permalink
Merge branch 'master' into security-headers-no-follow-redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
repo-ranger[bot] authored Feb 27, 2021
2 parents 7c2bf8c + cd3774a commit fc0dd32
Show file tree
Hide file tree
Showing 8 changed files with 2,271 additions and 1,502 deletions.
3,668 changes: 2,207 additions & 1,461 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"graphql": "^14.7.0",
"graphql-tag": "^2.11.0",
"heroku-client": "^3.1.0",
"ioredis": "4.22.0",
"ioredis": "4.23.0",
"joi": "17.4.0",
"joi-extension-semver": "5.0.0",
"js-yaml": "^4.0.0",
Expand All @@ -55,10 +55,10 @@
"pretty-bytes": "^5.5.0",
"priorityqueuejs": "^2.0.0",
"prom-client": "^13.1.0",
"query-string": "^6.14.0",
"query-string": "^6.14.1",
"request": "~2.88.2",
"semver": "~7.3.4",
"simple-icons": "4.11.0",
"simple-icons": "4.12.0",
"webextension-store-meta": "^1.0.3",
"xmldom": "~0.4.0",
"xpath": "~0.0.32"
Expand Down Expand Up @@ -142,9 +142,9 @@
"devDependencies": {
"@babel/core": "^7.12.17",
"@babel/polyfill": "^7.12.1",
"@babel/register": "7.12.13",
"@babel/register": "7.13.0",
"@mapbox/react-click-to-select": "^2.2.0",
"@types/chai": "^4.2.14",
"@types/chai": "^4.2.15",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.groupby": "^4.6.6",
"@types/mocha": "^8.2.1",
Expand All @@ -165,9 +165,9 @@
"chai-string": "^1.4.0",
"child-process-promise": "^2.2.1",
"clipboard-copy": "^4.0.1",
"concurrently": "^5.3.0",
"concurrently": "^6.0.0",
"cypress": "^6.5.0",
"danger": "^10.6.2",
"danger": "^10.6.3",
"danger-plugin-no-test-shortcuts": "^2.0.0",
"deepmerge": "^4.2.2",
"eslint": "^7.20.0",
Expand All @@ -178,7 +178,7 @@
"eslint-plugin-chai-friendly": "^0.6.0",
"eslint-plugin-cypress": "^2.11.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^31.6.0",
"eslint-plugin-jsdoc": "^32.2.0",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-no-extension-in-require": "^0.2.0",
"eslint-plugin-node": "^11.1.0",
Expand All @@ -188,14 +188,14 @@
"eslint-plugin-sort-class-members": "^1.9.0",
"fetch-ponyfill": "^7.1.0",
"form-data": "^4.0.0",
"gatsby": "2.32.3",
"gatsby": "2.32.8",
"gatsby-plugin-catch-links": "^2.3.10",
"gatsby-plugin-page-creator": "^2.10.0",
"gatsby-plugin-react-helmet": "^3.3.9",
"gatsby-plugin-remove-trailing-slashes": "^2.3.10",
"gatsby-plugin-styled-components": "^3.3.9",
"gatsby-plugin-styled-components": "^3.10.0",
"gatsby-plugin-typescript": "^2.12.0",
"got": "11.8.1",
"got": "11.8.2",
"humanize-string": "^2.1.0",
"husky": "^4.3.8",
"icedfrisby": "4.0.0",
Expand All @@ -207,7 +207,7 @@
"lodash.debounce": "^4.0.8",
"lodash.difference": "^4.5.0",
"minimist": "^1.2.5",
"mocha": "^8.2.1",
"mocha": "^8.3.0",
"mocha-env-reporter": "^4.0.0",
"mocha-junit-reporter": "^2.0.0",
"mocha-yaml-loader": "^1.0.3",
Expand All @@ -233,7 +233,7 @@
"sazerac": "^2.0.0",
"sinon": "^9.2.4",
"sinon-chai": "^3.5.0",
"snap-shot-it": "^7.9.4",
"snap-shot-it": "^7.9.6",
"start-server-and-test": "1.12.0",
"styled-components": "^5.2.1",
"ts-mocha": "^8.0.0",
Expand Down
17 changes: 17 additions & 0 deletions services/coveralls/coveralls-redirector.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const { redirector } = require('..')

module.exports = [
redirector({
name: 'CoverallsGitHubRedirect',
category: 'coverage',
route: {
base: 'coveralls',
pattern: ':user((?!github|bitbucket).*)/:repo/:branch*',
},
transformPath: ({ user, repo, branch }) =>
`/coveralls/github/${user}/${repo}${branch ? `/${branch}` : ''}`,
dateAdded: new Date('2021-02-23'),
}),
]
13 changes: 13 additions & 0 deletions services/coveralls/coveralls-redirector.tester.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

const { ServiceTester } = require('../tester')

const t = (module.exports = new ServiceTester({
id: 'CoverallsGitHubRedirect',
title: 'Coveralls GitHub Redirector',
pathPrefix: '/coveralls',
}))

t.create('Coveralls VCS type missing')
.get('/lemurheavy/coveralls-ruby.svg')
.expectRedirect('/coveralls/github/lemurheavy/coveralls-ruby.svg')
27 changes: 5 additions & 22 deletions services/coveralls/coveralls.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,25 @@ module.exports = class Coveralls extends BaseJsonService {
static category = 'coverage'
static route = {
base: 'coveralls',
pattern: ':vcsType(github|bitbucket)?/:user/:repo/:branch*',
pattern: ':vcsType(github|bitbucket)/:user/:repo/:branch*',
}

static examples = [
{
title: 'Coveralls github',
pattern: ':vcsType/:user/:repo',
title: 'Coveralls',
namedParams: { vcsType: 'github', user: 'jekyll', repo: 'jekyll' },
pattern: ':vcsType(github|bitbucket)/:user/:repo',
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls github branch',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'github',
user: 'lemurheavy',
repo: 'coveralls-ruby',
branch: 'master',
},
staticPreview: this.render({ coverage: 91.81 }),
},
{
title: 'Coveralls bitbucket',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'bitbucket', user: 'pyKLIP', repo: 'pyklip' },
staticPreview: this.render({ coverage: 86 }),
},
{
title: 'Coveralls bitbucket branch',
pattern: ':vcsType/:user/:repo/:branch',
title: 'Coveralls branch',
namedParams: {
vcsType: 'bitbucket',
user: 'pyKLIP',
repo: 'pyklip',
branch: 'master',
},
pattern: ':vcsType(github|bitbucket)/:user/:repo/:branch',
staticPreview: this.render({ coverage: 96 }),
},
]
Expand Down
4 changes: 0 additions & 4 deletions services/coveralls/coveralls.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ t.create('github branch coverage')
.get('/github/lemurheavy/coveralls-ruby/master.json')
.expectBadge({ label: 'coverage', message: isIntegerPercentage })

t.create('github coverage for legacy link')
.get('/jekyll/jekyll.json')
.expectBadge({ label: 'coverage', message: isIntegerPercentage })

t.create('bitbucket coverage')
.get('/bitbucket/pyKLIP/pyklip.json')
.expectBadge({ label: 'coverage', message: isIntegerPercentage })
9 changes: 8 additions & 1 deletion services/endpoint/endpoint.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ module.exports = class Endpoint extends BaseJsonService {
}

async handle(namedParams, { url }) {
const { protocol, hostname } = new URL(url)
let protocol, hostname
try {
const parsedUrl = new URL(url)
protocol = parsedUrl.protocol
hostname = parsedUrl.hostname
} catch (e) {
throw new InvalidParameter({ prettyMessage: 'invalid url' })
}
if (protocol !== 'https:') {
throw new InvalidParameter({ prettyMessage: 'please use https' })
}
Expand Down
9 changes: 8 additions & 1 deletion services/endpoint/endpoint.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,18 @@ t.create('Blocked domain')
.expectBadge({ label: 'custom badge', message: 'domain is blocked' })

// https://github.com/badges/shields/issues/3780
t.create('Invalid url').get('.json?url=https:/').expectBadge({
t.create('Invalid url (1)').get('.json?url=https:/').expectBadge({
label: 'custom badge',
message: 'invalid query parameter: url',
})

t.create('Invalid url (2)')
.get('.json?url=https%3A//shields.io%foo')
.expectBadge({
label: 'custom badge',
message: 'invalid url',
})

// https://github.com/badges/shields/issues/5868
t.create('gzipped endpoint')
.get('.json?url=https://example.com/badge')
Expand Down

0 comments on commit fc0dd32

Please sign in to comment.