All files / src dependency-check.ts

0% Statements 0/52
0% Branches 0/1
0% Functions 0/1
0% Lines 0/52

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                                                                                         
#!/usr/bin/env node
import { ensureError } from "./util/misc.js";
import { installDependencyCheck } from "./installer.js";
import { executeDependencyCheck } from "./executor.js";
import { parseCli } from "./cli.js";
import { Maybe } from "purify-ts";
import { createLogger } from "./util/log.js";
import { name } from "./info.js";
import { setExitCode } from "./util/proc.js";

const log = createLogger(name);

let ignoreErrors = false;

export async function run() {
  const cli = parseCli();
  ignoreErrors = cli.ignoreErrors;

  let executable = cli.owaspBinary;
  if (executable.isNothing()) {
    executable = Maybe.of(
      await installDependencyCheck(
        cli.binDir,
        cli.odcVersion,
        cli.proxyUrl,
        cli.githubToken,
        cli.forceInstall,
        cli.keepOldVersions,
      ),
    );
  } else {
    log.info("Locally preinstalled (OWASP_BIN) Dependency-Check Core found.");
  }

  if (executable.isJust()) {
    const result = executeDependencyCheck(
      executable.unsafeCoerce(),
      cli.cmdArguments,
      cli.outDir,
      cli.proxyUrl,
      cli.hideOwaspOutput,
      cli.javaBinary,
    );
    setExitCode(result, ignoreErrors, log);
  }
}

void run().catch((e: unknown) => {
  const error = ensureError(e);
  log.error(error.message);
  setExitCode(1, ignoreErrors, log);
});