Commit Graph

173 Commits

Author SHA1 Message Date
Pierre-Yves B
9c7baa26ab Deprecate [Bintray] service (#6423) 2021-04-24 18:05:59 +01:00
chris48s
22fb91fa36 use \r\n linebreaks when writing raw HTTP (#6386) 2021-04-19 18:29:40 +01:00
chris48s
7d452472de return a 408 Request Timeout response for timed out requests (#6371) 2021-04-11 21:29:13 +01:00
chris48s
b1fc492592 add setting which allows us to set a timeout on HTTP requests (#6364)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-04-05 17:56:32 +00:00
chris48s
e0510ca761 Revert request --> got migration (for now) (#6277)
* Revert "send custom user agent when using got (#6256)"
This reverts commit fd7eddc7bb.

* Revert "Migrate request to got (part 1 of many) (#6160)"
This reverts commit 2359eb278b.

* install got as a prod dependency, allow npm 7
2021-03-17 20:10:38 +00:00
chris48s
9d404bc2b0 use got to push influx metrics (#6257) 2021-03-12 19:38:11 +00:00
chris48s
fd7eddc7bb send custom user agent when using got (#6256) 2021-03-10 19:38:41 +00:00
chris48s
2359eb278b Migrate request to got (part 1 of many) (#6160)
* install new packages

* migrate request to got

* update dynamic json test

This is a behavioural difference between request and got

request will send the request, then we'll get a
`400 Bad Request` back and re-throw at as invalid

got will pick up that the URL is invalid and throw
`RequestError: URI malformed` before attempting to send it
which we'll re-throw as inaccessible

* fix OPM service

* fix wordpress querystring

Got doesn't natively support assmebling a querystring
from nested objects because it uses node's URLSearchParams
internally. Use qs and pass qs a string.

Wordpress is the only service that needs this,
so we could build the string manually in this case
if we don't want to take qs as a prod dependency.
It is mostly hard-coded values anyway.

* fix wercker

got overwrites any ?foo=bar in the URL string if
searchParams is also passed whereas request appends
see https://github.com/sindresorhus/got#url

* fix keybase

* add tests for got wrapper

* bootstrap global agent in server start
2021-03-09 20:03:52 +00:00
chris48s
06464008cc ensure redirect target path is correctly encoded (#6229)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-02-28 16:28:20 +00:00
danielle
0d463b42e5 [Bitbucket] Server Adding Auth Tokens and Resolving Pull Request api … (#6076)
* [Bitbucket Server] Adding Auth Tokens and Resolving Pull Request api issue.  Added the bitbucket_server_username & bitbucket_server_password variables to the /core/server/server.js file.  Also changed the user variable in the /services/bitbucket/bitbucket/bitbucket-pull-request.service.js the api documentation (https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html#idm8287391664) defines the parameter as requiring the project name that the repository is contained in not the user name.

* [Bitbucket Server] Adding Auth Tokens and Resolving Pull Request api issue.  Added the bitbucket_server_username & bitbucket_server_password variables to the /core/server/server.js file.  Also changed the user variable in the /services/bitbucket/bitbucket/bitbucket-pull-request.service.js the api documentation (https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-rest.html#idm8287391664) defines the parameter as requiring the project name that the repository is contained in not the user name.

* Update bitbucket-pull-request.service.js

Updating the label as Bitbucket and Bitbucket Server have different parameters in the Api call.  Changing to compound name per @calebcartwright  recomendation.

* Update server.js

Removing code that was refactored and caught in my Pull Request

* Reversing commit back on bitbucket-pull-request.service.js to its previous state.

Co-authored-by: danielle <185722+danielle@users.noreply.github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-01-26 22:57:37 -06:00
chris48s
4fea056421 improve debug output for API calls with query strings (#6075)
* improve debug output for API calls with query strings

* update test

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-01-22 18:16:19 +00:00
Caleb Cartwright
2d9ac83bb4 fix: remove erroneous clearRequestCache call (#6067)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-01-16 17:42:32 +00:00
Paul Melnikow
46b98c40be Remove the in-memory cache (#6037)
Shields has long had an in-memory cache with some complex logic for determining when the cached values are used and when they are flushed. At the time this was implemented, squeezing cache performance was helpful since there was no downstream cache. For years now we've used Cloudflare as a CDN, so trying to cache onboard is less useful than before. Furthermore, since the cache is very small and only used in fairly restrictive ways, it probably has very little impact on performance.
2021-01-11 15:53:36 -05:00
dependabot-preview[bot]
3a31721631 Build(deps): bump js-yaml from 3.14.1 to 4.0.0; run [DynamicYaml] (#6026)
* Build(deps): bump js-yaml from 3.14.1 to 4.0.0

Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.14.1 to 4.0.0.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/3.14.1...4.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* deps: apply js-yaml v4 changes

* deps: js-yaml v4 updates in gatsby config

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-01-10 15:23:32 +00:00
SeaHOH
8d94869bf8 Fixed escapes single '_' of badge urls; affects [static website] (#5979)
Fixed escapes inline single '_' of badge urls

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2020-12-25 18:20:42 +00:00
dependabot-preview[bot]
e202b73c3c Build(deps): bump prom-client from 11.5.3 to 13.0.0 (#5962)
* Build(deps): bump prom-client from 11.5.3 to 13.0.0

Bumps [prom-client](https://github.com/siimon/prom-client) from 11.5.3 to 13.0.0.
- [Release notes](https://github.com/siimon/prom-client/releases)
- [Changelog](https://github.com/siimon/prom-client/blob/master/CHANGELOG.md)
- [Commits](https://github.com/siimon/prom-client/compare/v11.5.3...v13.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* deps: apply updates for prom version bump

* register.getMetricsAsJSON is async now

* PrometheusMetrics#metrics is async

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
Co-authored-by: Marcin Mielnicki <marcin.mielnicki@gmail.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-12-23 23:32:08 +00:00
dependabot-preview[bot]
d0b93b4103 Build(deps): bump path-to-regexp from 5.0.0 to 6.2.0, run [Appveyor Bitbucket Circle GitHub GitLab ScrutinizerBuild] (#5684)
* Build(deps): bump path-to-regexp from 5.0.0 to 6.2.0

Bumps [path-to-regexp](https://github.com/pillarjs/path-to-regexp) from 5.0.0 to 6.2.0.
- [Release notes](https://github.com/pillarjs/path-to-regexp/releases)
- [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md)
- [Commits](https://github.com/pillarjs/path-to-regexp/compare/v5.0.0...v6.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* deps: apply path-to-regexp breaking changes

* fix: path-to-regexp types in frontend

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-12-23 22:59:31 +00:00
Marcin Mielnicki
b748e62e0a Test for server running with metrics enabled (#5975)
* Test server running with metrics enabled

* Verify custom metric was send

* Extra code removed

* Tests moved to core/server/server.spec.js

* tickAsync value based on push interval

* Trigger Build

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-12-23 18:52:08 +00:00
chris48s
8dd6da3cf9 Configure max-age header for frontend (#5775)
* upgrade scoutcamp

* set max age for static content, add tests

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-11-12 20:04:20 +00:00
Paul Melnikow
f1a5dd9427 Align style prop of coalesceBadge() with internal makeBadge() (#5726)
This is an analogous change to #5719 for `’template’` and `’style’`. (See the top comment for more explanation.)
2020-10-20 19:16:38 -04:00
Paul Melnikow
1184938ed1 Align label and message props of coalesceBadge() with internal makeBadge() (#5719)
There is an internal `makeBadge()` function which is called from a few places in the server and from the public `makeBadge()` function which is a light wrapper. (Eventually we want to dogfood the public API: that's the work of #4950, and this helps with it by aligning the interfaces.)

Related to that is #3370, which is about aligning the `serviceData` schema (i.e. the result of `handle()`) with the public `makeBadge()` function.

A legacy quirk of the _private_ `makeBadge()` function is accepting a `text: ['label', 'message']` array instead of separate `{ label, message }` props like the rest of the codebase. `coalesceBadge()` has to translate from `{ label, message }` to `text: ['label', message']`. This removes that bit of indirection.

It also rewrites most of the tests of `coalesceBadge()` to use `.includes()`, providing IMO a slight improvement in readability.
2020-10-16 18:06:32 -04:00
Paul Melnikow
cbd8eba2c4 Fix REQUIRE_CLOUDFLARE for Heroku (#5712)
Ref #3027
2020-10-15 19:27:07 -04:00
Paul Melnikow
1fab1a7140 When configured, require requests to come from Cloudflare (#5666)
This is the code part of #3027, following [this article](https://www.viget.com/articles/heroku-cloudflare-the-right-way/) and using [this middleware](https://github.com/clive-io/cloudflare-middleware).

I pulled in the `addHandlerAtIndex()` function @chris48s wrote for #5574.

The middleware isn't perfect for scoutcamp, since it relies on `req.ip` which is something set by Express. However, the other solutions I found were either explicitly deprecated ([cloudflare-ip](https://www.npmjs.com/package/cloudflare-ip)) or relied on dynamically fetching the list of Cloudflare hosts ([cloudflare-ips](https://www.npmjs.com/package/cloudflare-ips)), which seems unnecessary as this list has not changed in several years.

I've left this off to start, so we can test it in production using an env var before we make it the production default.
2020-10-12 12:36:42 -04:00
Paul Melnikow
564a9145e9 Remove FsTokenPersistence (#5671)
Closes #5665
2020-10-10 21:59:52 +00:00
Paul Melnikow
f0b8480280 Inject shieldsSecret into GitHub token admin endpoint (#5631)
Ref #3393
2020-10-01 23:12:22 -04:00
chris48s
504015c0ba migrate hapi/joi to joi (#5624)
* update joi + joi-extension-semver

* @hapi/joi --> joi

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-09-30 17:51:02 +00:00
Paul Melnikow
86366588a2 Minor coverage cleanup (#5630) 2020-09-29 21:33:28 -04:00
Paul Melnikow
eb9743c25c Remove obsolete peer-to-peer GitHub token-sharing code (#5628)
Prevent tokens from being sent to the OVH servers. Instead, add them directly to the Redis DB.

Ref #3393
2020-09-29 21:22:30 -04:00
Paul Melnikow
bdc41670a9 Remove obsolete WebSocket logs monitor (#5629)
This never worked in prod (see #1460)
2020-09-29 21:05:55 -04:00
Pratapi Hemant
108a819c3a [GITHUB] Badge for total stars of an user / org (#5507)
* added badge for total stars of an user / org
* Added a transformJson method in graphql-base to handle partial data


Co-authored-by: Pratapi Hemant Patel <pratpatel@expedia.com>
Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2020-09-19 12:07:23 +01:00
chris48s
38322e1412 redirect /endpoint with no query params to endpoint docs (#5137)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-09-06 17:21:58 +00:00
Paul Melnikow
7c226456fe Adopt static fields in [amo] and core (#5440)
Since we've upgraded production to Node 12 (#5436) we can finally adopt static fields!

This starts the process by updating core and one of the service families.
2020-08-19 14:49:29 -04:00
Pierre-Yves B
135b842946 Migrate [Discord] implementation to use bot token (#5346)
* Migrate [Discord] implementation to use bot token

* Rework authorization field creation

* Revert "Rework authorization field creation"

This reverts commit caf65bde5d.

* Add LGTM exclusion for hardcoded credentials
2020-07-24 18:04:12 +02:00
Pierre-Yves B
1639417a55 Fix [Twitch] Client-ID header (#5217) 2020-06-17 19:18:25 +02:00
Pierre-Yves B
0fd557d7bb Implement [YouTube] badge (#5132)
* Implement [YouTube] badge

* Update production-hosting.md with account owner

* Add votes badge variant

* Add links to tests

* Switch to social badge style
2020-06-10 18:44:21 +02:00
Paul Melnikow
4582ea1c56 Avoid using racially linked language (#5190) 2020-06-09 02:28:53 +00:00
Viktor Szépe
88ea1f9149 Fix invalid Cache-Control header, run [Endpoint] (#5139)
* Fix invalid Cache-Control header
* Update endpoint.tester.js
* Update legacy-request-handler.spec.js

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2020-05-31 14:04:37 +01:00
dependabot-preview[bot]
fc6390d62e Build(deps-dev): bump eslint-plugin-jsdoc from 24.0.6 to 25.4.1 (#5085)
* Build(deps-dev): bump eslint-plugin-jsdoc from 24.0.6 to 25.4.1

Bumps [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) from 24.0.6 to 25.4.1.
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases)
- [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v24.0.6...v25.4.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* fix errors identified by new linting rules

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: chris48s <chris.shaw480@gmail.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-05-17 15:00:21 +00:00
chris48s
13d75e0607 upgrade to prettier 2 (#5051)
* arrowParens: avoid
* remove trailingComma setting
2020-05-05 21:07:43 +01:00
chris48s
1c736f2159 send s-maxage cache header (#5046)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-05-05 18:55:22 +01:00
chris48s
0129eba673 show link previews on /dev/styles page (#5045) 2020-05-03 15:47:56 +01:00
chris48s
4d275e0642 upgrade to got 11 (#5008) 2020-05-02 17:39:23 +01:00
Paul Melnikow
f0030a4025 Fill GitHub token pool on startup (#4987)
We're still seeing a few "Token pool is exhausted" errors at the moment the dynos are coming up. I'm wondering if this might help.

Ref #3771
2020-04-30 23:39:01 -04:00
Paul Melnikow
6e76fabe26 Upgrade to Mocha 7 (#4976)
For some reason the `--delay` version is not working in Mocha 7. I'm not sure why that is. Although, invoking Mocha the normal synchronous way seems to be working fine, so maybe `--delay` just isn't necessary anymore for what we're doing in Shields.

I don't see anything in the changelog about this 🤷‍♂️

Closes #4842
2020-04-29 17:20:17 -04:00
Paul Melnikow
f9d5f57f49 Delay start until the server is ready (#4959)
Fixes #4958

Fixes, but only in Heroku, #3771, so let's keep that open.
2020-04-27 22:45:19 -04:00
Caleb Cartwright
4fe80bb150 Get data for [Discord] badges via OVH server proxies (#4956) 2020-04-27 09:39:57 -04:00
chris48s
3ba05cb184 📦 version 3 (#4756)
* Validate input to BadgeFactory.create() (#3875)

* validate input to create()

* remove deprecated properties (#3881)

* remove BadgeFactory class (#3884)

* Template literal templates (#4459)

- Remove use of the doT template library and move to generating SVG output using javascript template literals.
- Drop SVGO and mostly manually implement the optimisations.
- Add a bunch more tests

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>

* drop raster support in package CLI (#4523)

* drop raster support in package CLI
* update docs

* rename gh-badges package to badge-maker

* rename gh-badges dir to badge-maker

* update relative imports and other refs to in parent dir

'gh-badges' --> 'badge-maker'

* update snyk service tests

This change is only tangentially related

We've used the shields repo as an example for these tests so
moving files around in our repo has a knock-on effect on them

* add missing type hints to dev style page

* write the changelog/migration guide for v3

* use extension in README CLI example

* update CLI help

whoops - missed this in #4523

* bump version

* update for self-hosting users

* README updates

* drop .format param from CLI, always output SVG

* Change text[] to label and message, Remove JSON output

- Change text[] to label and message
- Fix message only badge
- Remove JSON output format
- Update the docs

* update package-lock

* rename 'template' to 'style'

* handle invalid styles in coalesceBadge

* ensure makeBadge is passed a string for template in coalesceBadge()

issue #4925

* fix (logo/no label text/label color specified) case

issue #4926

* add example of (logo/no label text/label color specified) to style debug page

* update type defs

* padding fix for FTB style

Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
2020-04-23 20:05:48 +01:00
Marcin Mielnicki
b64987d2dd Do not log errors in influx tests (#4931) 2020-04-22 16:58:11 -05:00
Marcin Mielnicki
e66cfa3c21 📈 PaaS-friendly metrics (#4874)
* prom-client JSON to InfluxDB line protocol converter

* Converts a metric with separate names

* prom-client JSON to InfluxDB line protocol (version 2) converter

* Server has instance id

* Read the instance id from an environment variable

* More unit tests for instance-metadata

* Log instance id

* Push influx metrics

* INSTANCE_ID with dyno metadata

* Prepare influx metrics in one place

* Influx metrics endpoint should return metrics

* More readable tests

* Env added to instance metadata

* hostname as an instance label value

* HEROKU_DYNO_ID as an instance id for heroku

* Instance env can be set by env variable

* HEROKU_APP_NAME as an instance env

* Log instance metadata as a JSON

* Typo fix

* Code refactoring in tests

* wait-for-expect dev dependency added

* Test for pushing metrics

* Test for pushing metrics

* Use basic authentication for pushing metrics

* intervalSeconds=2 for development env

* Using existing methods

* TODOs removed

* Schema for influx credentials

* Influx config removed from config files

* Require username and password when influx metrics are enabled

* Unused args removed

* pushing component should log errors

* Speed up tests

* should log error responses

* InstanceMetadata class replaces by simple object

* Influx metrics can be configuredd by env variables

* Use application label name instead of service

* Unused code removed

* Integration test for prom-client and converter

* metrics.influx.enabled configuration option added

* Improved influx configuration schema

* instanceMetadata validation

* Typo fix

* Default value for env

* metrics.infux.hostnameAsAInstanceId added

* should add hostname as an instance label when hostnameAsAInstanceId is enabled

* Default values for influx configuration

* flatMap is not available in Node.js 9.4

* Env vars removed from Procfile

* Better instance metadata values in tests

* Typo fix

* lodash.groupby added to prod dependencies

* Allow other keys in private config

* Missing test - should allow other private keys when influx metrics are enabled

* Missing test - should require private metrics config when influx configuration is enabled

* log.error instead of console.log

* metrics.influx.uri -> metrics.influx.url

* Unused arguments removed

* async removed

* promisify sendMetrics

* Allow to disable prometheus metrics

* Create test server with custom config

* 'metrics-influx' resource removed

* 'metrics-influx' resource removed

* Private config schema flattened out

* Extra code removed in Prometheus tests

* promisify moved outside of the class

* Do not throw errors from got in a specific test

* hostnameAliases added

* instanceIdFrom added

* instanceIdEnvVarName added

* envLabel added to schema

* instanceMetadata is not used by InfluxMetrics

* Instance metadata removed

* hostnameAsAnInstanceId removed

* A comment added

* waitForExpect removed

* Unused code removed
2020-04-19 20:03:00 +02:00
Pierre-Yves B
097bf87e41 Make it easier to benchmark and profile the code (#4780)
* Make it easier to benchmark and profile the code

* Remove unnecessary escape

* Clarify that the backend server is started without the frontend

* Add missing NODE_CONFIG_ENV environment variable

* Add error message when user has not included console.time statements

* Fix lint issue

* Handle multiple console.time statements

* Switch NODE_CONFIG_ENV to test

* Switch to const as variable never re-assigned
2020-03-22 20:45:53 +01:00