Skip to content

Commit

Permalink
fix: replace url-regex with is-rul-superb
Browse files Browse the repository at this point in the history
Addresses security vulnerability described at kevva/url-regex#70
  • Loading branch information
asteffey committed Jun 24, 2020
1 parent 56aaa97 commit c04f448
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -9,9 +9,9 @@
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"is-url-superb": "^4.0.0",
"mongodb": "^3.5.9",
"mongoose": "^5.9.18",
"url-regex": "^5.0.0"
"mongoose": "^5.9.18"
},
"devDependencies": {
"@babel/cli": "^7.10.1",
Expand Down
4 changes: 2 additions & 2 deletions src/routes/newUrl.ts
@@ -1,4 +1,4 @@
import urlRegex from 'url-regex'
import isUrl from 'is-url-superb'
import { Router } from 'express'
import { urlencoded } from 'body-parser'
import { baseUrl } from '../config'
Expand All @@ -9,7 +9,7 @@ const newUrl = Router()
newUrl.use(urlencoded({ extended: false }))

newUrl.post('/', ({ body: { url } }, res, next) => {
if (urlRegex({ exact: true }).test(url)) {
if (isUrl(url)) {
ShortUrl.newShortUrl(url)
.then(({ originalUrl, shortId }) => res.json({
original_url: originalUrl,
Expand Down
23 changes: 5 additions & 18 deletions yarn.lock
Expand Up @@ -3546,11 +3546,6 @@ ip-regex@^2.1.0:
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-2.1.0.tgz#fa78bf5d2e6913c911ce9f819ee5146bb6d844e9"
integrity sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=

ip-regex@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.1.0.tgz#5ad62f685a14edb421abebc2fff8db94df67b455"
integrity sha512-pKnZpbgCTfH/1NLIlOduP/V+WRXzC2MOz3Qo8xmxk8C5GudJLgK5QyLVXOSWy3ParAH7Eemurl3xjv/WXYFvMA==

ipaddr.js@1.9.1:
version "1.9.1"
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3"
Expand Down Expand Up @@ -3775,6 +3770,11 @@ is-typedarray@^1.0.0, is-typedarray@~1.0.0:
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=

is-url-superb@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/is-url-superb/-/is-url-superb-4.0.0.tgz#b54d1d2499bb16792748ac967aa3ecb41a33a8c2"
integrity sha512-GI+WjezhPPcbM+tqE9LnmsY5qqjwHzTvjJ36wxYX5ujNXefSUJ/T17r5bqDV8yLhcgB59KTPNOc9O9cmHTPWsA==

is-windows@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-0.2.0.tgz#de1aa6d63ea29dd248737b69f1ff8b8002d2108c"
Expand Down Expand Up @@ -6289,11 +6289,6 @@ through@^2.3.6:
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=

tlds@^1.203.0:
version "1.207.0"
resolved "https://registry.yarnpkg.com/tlds/-/tlds-1.207.0.tgz#459264e644cf63ddc0965fece3898913286b1afd"
integrity sha512-k7d7Q1LqjtAvhtEOs3yN14EabsNO8ZCoY6RESSJDB9lst3bTx3as/m1UuAeCKzYxiyhR1qq72ZPhpSf+qlqiwg==

tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
Expand Down Expand Up @@ -6609,14 +6604,6 @@ url-parse-lax@^3.0.0:
dependencies:
prepend-http "^2.0.0"

url-regex@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/url-regex/-/url-regex-5.0.0.tgz#8f5456ab83d898d18b2f91753a702649b873273a"
integrity sha512-O08GjTiAFNsSlrUWfqF1jH0H1W3m35ZyadHrGv5krdnmPPoxP27oDTqux/579PtaroiSGm5yma6KT1mHFH6Y/g==
dependencies:
ip-regex "^4.1.0"
tlds "^1.203.0"

use@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
Expand Down

0 comments on commit c04f448

Please sign in to comment.