Skip to content

Commit

Permalink
fix: replace path-parse by parse-url (#426)
Browse files Browse the repository at this point in the history
This fixes a vulnerabilty in parse-path (CVE-2022-0624)

Closes #423
  • Loading branch information
fgreinacher authored Jul 11, 2022
1 parent 129dff5 commit 1b3987e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 125 deletions.
6 changes: 3 additions & 3 deletions lib/get-repo-id.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const parsePath = require('parse-path');
const parseUrl = require('parse-url');
const escapeStringRegexp = require('escape-string-regexp');

module.exports = ({envCi: {service} = {}, env: {CI_PROJECT_PATH}}, gitlabUrl, repositoryUrl) =>
service === 'gitlab' && CI_PROJECT_PATH
? CI_PROJECT_PATH
: parsePath(repositoryUrl)
.pathname.replace(new RegExp(`^${escapeStringRegexp(parsePath(gitlabUrl).pathname)}`), '')
: parseUrl(repositoryUrl)
.pathname.replace(new RegExp(`^${escapeStringRegexp(parseUrl(gitlabUrl).pathname)}`), '')
.replace(/^\//, '')
.replace(/\/$/, '')
.replace(/\.git$/, '');
Loading

0 comments on commit 1b3987e

Please sign in to comment.