mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 01:08:46 +00:00
Move credentialToStr and add tests
This commit is contained in:
Generated
+3
-3
@@ -119143,6 +119143,9 @@ async function getDownloadUrl(logger) {
|
||||
version: UPDATEJOB_PROXY_VERSION
|
||||
};
|
||||
}
|
||||
function credentialToStr(c) {
|
||||
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== void 0}; Token: ${c.token !== void 0}`;
|
||||
}
|
||||
|
||||
// src/status-report.ts
|
||||
var os = __toESM(require("os"));
|
||||
@@ -119935,9 +119938,6 @@ async function getProxyBinaryPath(logger) {
|
||||
proxyBin = path.join(proxyBin, proxyFileName);
|
||||
return proxyBin;
|
||||
}
|
||||
function credentialToStr(c) {
|
||||
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${c.username}; Password: ${c.password !== void 0}; Token: ${c.token !== void 0}`;
|
||||
}
|
||||
void runWrapper();
|
||||
/*! Bundled license information:
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { KnownLanguage } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import {
|
||||
Credential,
|
||||
credentialToStr,
|
||||
getCredentials,
|
||||
getDownloadUrl,
|
||||
parseLanguage,
|
||||
@@ -309,10 +310,4 @@ async function getProxyBinaryPath(logger: Logger): Promise<string> {
|
||||
return proxyBin;
|
||||
}
|
||||
|
||||
function credentialToStr(c: Credential): string {
|
||||
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${
|
||||
c.username
|
||||
}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`;
|
||||
}
|
||||
|
||||
void runWrapper();
|
||||
|
||||
@@ -301,3 +301,20 @@ test("getDownloadUrl returns matching release asset", async (t) => {
|
||||
t.is(info.version, defaults.cliVersion);
|
||||
t.is(info.url, "url-we-want");
|
||||
});
|
||||
|
||||
test("credentialToStr - hides passwords/tokens", (t) => {
|
||||
const secret = "password123";
|
||||
const credential = {
|
||||
type: "maven_credential",
|
||||
};
|
||||
t.false(
|
||||
startProxyExports
|
||||
.credentialToStr({ password: secret, ...credential })
|
||||
.includes(secret),
|
||||
);
|
||||
t.false(
|
||||
startProxyExports
|
||||
.credentialToStr({ token: secret, ...credential })
|
||||
.includes(secret),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -277,3 +277,14 @@ export async function getDownloadUrl(
|
||||
version: UPDATEJOB_PROXY_VERSION,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Pretty-prints a `Credential` value to a string, but hides the actual password or token values.
|
||||
*
|
||||
* @param c The credential to convert to a string.
|
||||
*/
|
||||
export function credentialToStr(c: Credential): string {
|
||||
return `Type: ${c.type}; Host: ${c.host}; Url: ${c.url} Username: ${
|
||||
c.username
|
||||
}; Password: ${c.password !== undefined}; Token: ${c.token !== undefined}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user