CVE-2022-0722 (JavaScript, published 2022-06-27T11:15Z)
Description: value: Exposure of Sensitive Information to an Unauthorized Actor in GitHub repository ionicabizau/parse-url prior to 7.0.0.
Severity: MEDIUM (CVSS v3 base score: 7.5)
Weakness: CWE-200 \u2014 Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
Repository: https://github.com/ionicabizau/parse-url
Files changed:
lib/index.js
package.json
test/index.js
Commit message: Refactor codebase, upgrade dependencies


Vulnerable code:
 * @param {Boolean|Object} normalize Wheter to normalize the url or not.
 *  - `protocols` (Array): An array with the url protocols (usually it has one element).
 *  - `protocol` (String): The first protocol, `"ssh"` (if the url is a ssh url) or `"file"`.
 *  - `port` (null|Number): The domain port.
 *  - `resource` (String): The url domain (including subdomains).
 *  - `user` (String): The authentication user (usually for ssh urls).
 *  - `pathname` (String): The url pathname.
 *  - `hash` (String): The url hash.
 *  - `search` (String): The url querystring value.
 *  - `href` (String): The input url.
 *  - `query` (Object): The url querystring, parsed as object.
function parseUrl(url, normalize = false) {
    "is-ssh": "^1.3.0",
    "parse-path": "^4.0.4",
    "protocols": "^1.4.0"
}
    , qs = require("querystring")
          , port: null
          , port: null
          , port: null
          , port: null
            protocols: []
          , port: null
          , port: null
            c[1].query = qs.parse(c[1].search)
            c[1].href = url

Fixed code:
// Dependencies

 * @param {Boolean|Object} normalize Whether to normalize the url or not.
 *    - `protocols` (Array): An array with the url protocols (usually it has one element).
 *    - `protocol` (String): The first protocol, `"ssh"` (if the url is a ssh url) or `"file"`.
 *    - `port` (null|Number): The domain port.
 *    - `resource` (String): The url domain (including subdomains).
 *    - `user` (String): The authentication user (usually for ssh urls).
 *    - `pathname` (String): The url pathname.
 *    - `hash` (String): The url hash.
 *    - `search` (String): The url querystring value.
 *    - `href` (String): The input url.
 *    - `query` (Object): The url querystring, parsed as object.
const parseUrl = (url, normalize = false) => {

    // Constants
    const GIT_RE = /((git@|http(s)?:\/\/)([\w\.@]+)(\/|:))(([\~,\w,\-,\_,\/]+)(.git){0,1}((\/){0,1}))/




    // Potential git-ssh urls
    if (parsed.protocol === "file") {
        const matched  = parsed.href.match(GIT_RE)
        if (matched) {
            parsed.protocols = ["ssh"]
            parsed.protocol = "ssh"
            parsed.resource = matched[4]
            parsed.user = "git"
            parsed.pathname = `/${matched[6]}`
        }
    }

    "is-ssh": "^1.4.0",
    "parse-path": "^5.0.0",
    "protocols": "^2.0.1"
}
          , port: ""
          , query: {}
          , port: ""
          , query: {}
          , port: ""
          , query: {}
          , port: ""
          , query: {}
            protocols: ["ssh"]
          , port: ""
          , query: {}
          , port: ""
          , query: {}


            c[1].href = c[1].href || url
            c[1].password = c[1].password || ""