Language: TypeScript
Label: vulnerable
CWE: CWE-20 \u2014 Improper Input Validation
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.

Code:
    origin(origin, callback) {
      if (!origin || origin === "null") {
        callback(null, true);

        return;
      }

      const { hostname } = new URL(origin);
      const appHostname = new URL(fastify.config.PUBLIC_APP_URL).hostname;

      if (
        hostname === "localhost" ||
        hostname.endsWith(appHostname) ||
        (fastify.config.VRITE_CLOUD && hostname.endsWith("swagger.io"))
      ) {
        callback(null, true);

        return;
      }

      callback(new Error("Not allowed"), false);
    }