mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Make owner optional in parseRemoteFileAddress
This commit is contained in:
33
lib/entry-points.js
generated
33
lib/entry-points.js
generated
@@ -148660,6 +148660,12 @@ function initializeEnvironment(version) {
|
||||
core2.exportVariable("CODEQL_ACTION_FEATURE_WILL_UPLOAD" /* FEATURE_WILL_UPLOAD */, "true");
|
||||
core2.exportVariable("CODEQL_ACTION_VERSION" /* VERSION */, version);
|
||||
}
|
||||
function getEnv(env = process.env) {
|
||||
return {
|
||||
getRequired: (name) => getRequiredEnvVar(env, name),
|
||||
getOptional: (name) => getOptionalEnvVar(name)
|
||||
};
|
||||
}
|
||||
function getRequiredEnvVar(env, paramName) {
|
||||
const value = env[paramName];
|
||||
if (value === void 0 || value.length === 0) {
|
||||
@@ -151431,19 +151437,34 @@ function parseUserConfig(logger, pathInput, contents, validateConfig) {
|
||||
// src/config/remote-file.ts
|
||||
var DEFAULT_CONFIG_FILE_NAME = ".github/codeql-action.yaml";
|
||||
var DEFAULT_CONFIG_FILE_REF = "main";
|
||||
function parseRemoteFileAddress(configFile) {
|
||||
function getDefaultOwner(env) {
|
||||
const currentRepoNwo = env.getRequired("GITHUB_REPOSITORY" /* GITHUB_REPOSITORY */);
|
||||
const nwoParts = currentRepoNwo.split("/");
|
||||
if (nwoParts.length !== 2 || nwoParts[0].trim().length === 0) {
|
||||
throw new Error(
|
||||
`Expected ${"GITHUB_REPOSITORY" /* GITHUB_REPOSITORY */} to contain a name with owner, but got '${currentRepoNwo}'.`
|
||||
);
|
||||
}
|
||||
return nwoParts[0].trim();
|
||||
}
|
||||
function parseRemoteFileAddress(env, configFile) {
|
||||
const format = new RegExp(
|
||||
"(?<owner>[^/]+)/(?<repo>[^/@]+)(/(?<path>[^@]+))?(@(?<ref>.*))?"
|
||||
"((?<owner>[^/]+)/)?(?<repo>[^/@]+)(/(?<path>[^@]+))?(@(?<ref>.*))?"
|
||||
);
|
||||
const pieces = format.exec(configFile);
|
||||
if (!pieces?.groups?.owner || !pieces?.groups?.repo) {
|
||||
if (!pieces?.groups?.repo || pieces.groups.repo.trim().length === 0) {
|
||||
throw new ConfigurationError(
|
||||
getConfigFileRepoFormatInvalidMessage(configFile)
|
||||
);
|
||||
}
|
||||
if (pieces.groups.path?.startsWith("/")) {
|
||||
throw new ConfigurationError(
|
||||
`The path component of '${configFile}' cannot be an absolute path.`
|
||||
);
|
||||
}
|
||||
return {
|
||||
owner: pieces.groups.owner,
|
||||
repo: pieces.groups.repo,
|
||||
owner: pieces.groups.owner || getDefaultOwner(env),
|
||||
repo: pieces.groups.repo.trim(),
|
||||
path: pieces.groups.path || DEFAULT_CONFIG_FILE_NAME,
|
||||
ref: pieces.groups.ref || DEFAULT_CONFIG_FILE_REF
|
||||
};
|
||||
@@ -151466,7 +151487,7 @@ function getConfigFileInput(logger, actions, repositoryProperties) {
|
||||
return void 0;
|
||||
}
|
||||
async function getRemoteConfig(logger, configFile, apiDetails, validateConfig) {
|
||||
const address = parseRemoteFileAddress(configFile);
|
||||
const address = parseRemoteFileAddress(getEnv(), configFile);
|
||||
const response = await getApiClientWithExternalAuth(apiDetails).rest.repos.getContent({
|
||||
owner: address.owner,
|
||||
repo: address.repo,
|
||||
|
||||
Reference in New Issue
Block a user