mirror of
https://github.com/github/codeql-action
synced 2026-05-25 15:00:36 +03:00
Type result of parsing JSON as unknown until narrowed
This commit is contained in:
Generated
+51
-19
@@ -47749,12 +47749,12 @@ var require_concat_map = __commonJS({
|
||||
var res = [];
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
var x = fn(xs[i], i);
|
||||
if (isArray(x)) res.push.apply(res, x);
|
||||
if (isArray2(x)) res.push.apply(res, x);
|
||||
else res.push(x);
|
||||
}
|
||||
return res;
|
||||
};
|
||||
var isArray = Array.isArray || function(xs) {
|
||||
var isArray2 = Array.isArray || function(xs) {
|
||||
return Object.prototype.toString.call(xs) === "[object Array]";
|
||||
};
|
||||
}
|
||||
@@ -52097,8 +52097,8 @@ var require_object = __commonJS({
|
||||
"node_modules/@typespec/ts-http-runtime/dist/commonjs/util/object.js"(exports2) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports2, "__esModule", { value: true });
|
||||
exports2.isObject = isObject2;
|
||||
function isObject2(input) {
|
||||
exports2.isObject = isObject3;
|
||||
function isObject3(input) {
|
||||
return typeof input === "object" && input !== null && !Array.isArray(input) && !(input instanceof RegExp) && !(input instanceof Date);
|
||||
}
|
||||
}
|
||||
@@ -56584,7 +56584,7 @@ var require_commonjs4 = __commonJS({
|
||||
exports2.computeSha256Hmac = computeSha256Hmac;
|
||||
exports2.getRandomIntegerInclusive = getRandomIntegerInclusive;
|
||||
exports2.isError = isError;
|
||||
exports2.isObject = isObject2;
|
||||
exports2.isObject = isObject3;
|
||||
exports2.randomUUID = randomUUID;
|
||||
exports2.uint8ArrayToString = uint8ArrayToString;
|
||||
exports2.stringToUint8Array = stringToUint8Array;
|
||||
@@ -56631,7 +56631,7 @@ var require_commonjs4 = __commonJS({
|
||||
function isError(e) {
|
||||
return tspRuntime.isError(e);
|
||||
}
|
||||
function isObject2(input) {
|
||||
function isObject3(input) {
|
||||
return tspRuntime.isObject(input);
|
||||
}
|
||||
function randomUUID() {
|
||||
@@ -121350,6 +121350,23 @@ function isAuthToken(value, patterns = GITHUB_TOKEN_PATTERNS) {
|
||||
return void 0;
|
||||
}
|
||||
|
||||
// src/json/index.ts
|
||||
function parseString(data) {
|
||||
return JSON.parse(data);
|
||||
}
|
||||
function isObject2(value) {
|
||||
return typeof value === "object";
|
||||
}
|
||||
function isArray(value) {
|
||||
return Array.isArray(value);
|
||||
}
|
||||
function isString(value) {
|
||||
return typeof value === "string";
|
||||
}
|
||||
function isStringOrUndefined(value) {
|
||||
return value === void 0 || isString(value);
|
||||
}
|
||||
|
||||
// src/languages.ts
|
||||
var KnownLanguage = /* @__PURE__ */ ((KnownLanguage2) => {
|
||||
KnownLanguage2["actions"] = "actions";
|
||||
@@ -121373,10 +121390,10 @@ function isUsernamePassword(config) {
|
||||
return hasUsername(config) && "password" in config;
|
||||
}
|
||||
function isToken(config) {
|
||||
return "token" in config;
|
||||
return "token" in config && isStringOrUndefined(config.token);
|
||||
}
|
||||
function isAzureConfig(config) {
|
||||
return "tenant_id" in config && "client_id" in config && isDefined2(config.tenant_id) && isDefined2(config.client_id);
|
||||
return "tenant_id" in config && "client_id" in config && isDefined2(config.tenant_id) && isDefined2(config.client_id) && isString(config.tenant_id) && isString(config.client_id);
|
||||
}
|
||||
function isAWSConfig(config) {
|
||||
const requiredProperties = [
|
||||
@@ -121387,14 +121404,23 @@ function isAWSConfig(config) {
|
||||
"domain_owner"
|
||||
];
|
||||
for (const property of requiredProperties) {
|
||||
if (!(property in config) || !isDefined2(config[property])) {
|
||||
if (!(property in config) || !isDefined2(config[property]) || !isString(config[property])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ("audience" in config && !isStringOrUndefined(config.audience)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function isJFrogConfig(config) {
|
||||
return "jfrog_oidc_provider_name" in config && isDefined2(config.jfrog_oidc_provider_name);
|
||||
if ("audience" in config && !isStringOrUndefined(config.audience)) {
|
||||
return false;
|
||||
}
|
||||
if ("identity_mapping_name" in config && !isStringOrUndefined(config.identity_mapping_name)) {
|
||||
return false;
|
||||
}
|
||||
return "jfrog_oidc_provider_name" in config && isDefined2(config.jfrog_oidc_provider_name) && isString(config.jfrog_oidc_provider_name);
|
||||
}
|
||||
function credentialToStr(credential) {
|
||||
let result = `Type: ${credential.type};`;
|
||||
@@ -121829,12 +121855,12 @@ var NEW_LANGUAGE_TO_REGISTRY_TYPE = {
|
||||
go: ["goproxy_server", "git_source"]
|
||||
};
|
||||
function getRegistryAddress(registry) {
|
||||
if (isDefined2(registry.url)) {
|
||||
if (isDefined2(registry.url) && isString(registry.url) && isStringOrUndefined(registry.host)) {
|
||||
return {
|
||||
url: registry.url,
|
||||
host: registry.host
|
||||
};
|
||||
} else if (isDefined2(registry.host)) {
|
||||
} else if (isDefined2(registry.host) && isString(registry.host)) {
|
||||
return {
|
||||
url: void 0,
|
||||
host: registry.host
|
||||
@@ -121872,12 +121898,18 @@ function getAuthConfig(config) {
|
||||
}
|
||||
return { username: config.username, token: config.token };
|
||||
} else {
|
||||
if ("password" in config && isDefined2(config.password)) {
|
||||
let username = void 0;
|
||||
let password = void 0;
|
||||
if ("password" in config && isString(config.password)) {
|
||||
core10.setSecret(config.password);
|
||||
password = config.password;
|
||||
}
|
||||
if ("username" in config && isString(config.username)) {
|
||||
username = config.username;
|
||||
}
|
||||
return {
|
||||
username: "username" in config ? config.username : void 0,
|
||||
password: "password" in config ? config.password : void 0
|
||||
username,
|
||||
password
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -121897,22 +121929,22 @@ function getCredentials(logger, registrySecrets, registriesCredentials, language
|
||||
}
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(credentialsStr);
|
||||
parsed = parseString(credentialsStr);
|
||||
} catch {
|
||||
logger.error("Failed to parse the credentials data.");
|
||||
throw new ConfigurationError("Invalid credentials format.");
|
||||
}
|
||||
if (!Array.isArray(parsed)) {
|
||||
if (!isArray(parsed)) {
|
||||
throw new ConfigurationError(
|
||||
"Expected credentials data to be an array of configurations, but it is not."
|
||||
);
|
||||
}
|
||||
const out = [];
|
||||
for (const e of parsed) {
|
||||
if (e === null || typeof e !== "object") {
|
||||
if (e === null || !isObject2(e)) {
|
||||
throw new ConfigurationError("Invalid credentials - must be an object");
|
||||
}
|
||||
if (!isDefined2(e.type)) {
|
||||
if (!isDefined2(e.type) || !isString(e.type)) {
|
||||
throw new ConfigurationError("Invalid credentials - must have a type");
|
||||
}
|
||||
const authConfig = getAuthConfig(e);
|
||||
|
||||
Reference in New Issue
Block a user