Add support for downloading packs from GHES

This change adds:

- new `registries` block allowed in code scanning config file
- new `registries-auth-tokens` input in init action
- Change the downloadPacks function so that it accepts new parameters:
    - registries block
    - api auth
- Generate a qlconfig.yml file with the registries block if one is
  supplied. Use this file when downloading packs.
- temporarily set the `GITHUB_TOKEN` and `CODEQL_REGISTRIES_AUTH` based
  on api auth

TODO:

1. integration test
2. handle pack downloads when the config is generated by the CLI
This commit is contained in:
Andrew Eisenberg 2022-08-29 12:57:46 -07:00
parent c7bb8946b2
commit 0e98efa2bb
37 changed files with 428 additions and 103 deletions

View file

@ -4,7 +4,7 @@ import * as githubUtils from "@actions/github/lib/utils";
import * as retry from "@octokit/plugin-retry";
import consoleLogLevel from "console-log-level";
import { getRequiredInput } from "./actions-util";
import { getOptionalInput, getRequiredInput } from "./actions-util";
import * as util from "./util";
import { getMode, getRequiredEnvParam, GitHubVersion } from "./util";
@ -23,6 +23,7 @@ export interface GitHubApiDetails {
auth: string;
url: string;
apiURL: string | undefined;
registriesAuthTokens: string | undefined;
}
export interface GitHubApiExternalRepoDetails {
@ -68,6 +69,9 @@ function getApiDetails() {
auth: getRequiredInput("token"),
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
apiURL: getRequiredEnvParam("GITHUB_API_URL"),
// only available in the init action
registriesAuthTokens: getOptionalInput("registries-auth-tokens"),
};
}