mirror of
https://github.com/github/codeql-action.git
synced 2025-12-06 07:48:17 +08:00
Compare commits
1 Commits
f5c63fadd5
...
aeisenberg
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea8a6c7048 |
2
lib/api-client.js
generated
2
lib/api-client.js
generated
@@ -27,7 +27,7 @@ exports.getApiClient = function (apiDetails, { allowLocalRun = false, allowExter
|
||||
const auth = (allowExternal && apiDetails.externalRepoAuth) || apiDetails.auth;
|
||||
return new githubUtils.GitHub(githubUtils.getOctokitOptions(auth, {
|
||||
baseUrl: getApiUrl(apiDetails.url),
|
||||
userAgent: "CodeQL Action",
|
||||
userAgent: util_1.isAction() ? "CodeQL Action" : "CodeQL Runner",
|
||||
log: console_log_level_1.default({ level: "debug" }),
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAE7B,uEAAyD;AACzD,0EAAgD;AAEhD,iDAAuE;AACvE,iCAAoC;AAEpC,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,+FAAc,CAAA;IACd,+FAAc,CAAA;AAChB,CAAC,EAHW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAGrC;AAeY,QAAA,YAAY,GAAG,UAC1B,UAAoC,EACpC,EAAE,aAAa,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,EAAE;IAErD,IAAI,iBAAU,EAAE,IAAI,CAAC,aAAa,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IAED,MAAM,IAAI,GACR,CAAC,aAAa,IAAI,UAAU,CAAC,gBAAgB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC;IACpE,OAAO,IAAI,WAAW,CAAC,MAAM,CAC3B,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAClC,OAAO,EAAE,SAAS,CAAC,UA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C,CAAC;IAEF,OAAO,oBAAY,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;AACrD,CAAC;AAPD,kDAOC"}
|
||||
2
lib/codeql.js
generated
2
lib/codeql.js
generated
@@ -216,6 +216,8 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, v
|
||||
else if (process.platform !== "linux" && process.platform !== "darwin") {
|
||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
// set a environment variable to let CodeQL know where we are running
|
||||
process.env.CODEQL_WRAPPER = util.isAction() ? "action" : "runner";
|
||||
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
|
||||
return { codeql: cachedCodeQL, toolsVersion: codeqlURLVersion };
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
8
lib/util.js
generated
8
lib/util.js
generated
@@ -320,4 +320,12 @@ async function getGitHubAuth(logger, githubAuth, fromStdIn, readable = process.s
|
||||
throw new Error("No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input.");
|
||||
}
|
||||
exports.getGitHubAuth = getGitHubAuth;
|
||||
/**
|
||||
* Returns true if this process is running as part of github actions.
|
||||
* False otherwise.
|
||||
*/
|
||||
function isAction() {
|
||||
return "GITHUB_ACTIONS" in process.env;
|
||||
}
|
||||
exports.isAction = isAction;
|
||||
//# sourceMappingURL=util.js.map
|
||||
File diff suppressed because one or more lines are too long
6
lib/util.test.js
generated
6
lib/util.test.js
generated
@@ -204,4 +204,10 @@ async function mockStdInForAuthExpectError(t, mockLogger, ...text) {
|
||||
const stdin = stream.Readable.from(text);
|
||||
await t.throwsAsync(async () => util.getGitHubAuth(mockLogger, undefined, true, stdin));
|
||||
}
|
||||
ava_1.default("isAction", async (t) => {
|
||||
process.env.GITHUB_ACTIONS = "true";
|
||||
t.assert(util.isAction(), "Should be running in actions");
|
||||
delete process.env.GITHUB_ACTIONS;
|
||||
t.assert(!util.isAction(), "Should be running in runner");
|
||||
});
|
||||
//# sourceMappingURL=util.test.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@ import * as githubUtils from "@actions/github/lib/utils";
|
||||
import consoleLogLevel from "console-log-level";
|
||||
|
||||
import { getRequiredEnvParam, getRequiredInput } from "./actions-util";
|
||||
import { isLocalRun } from "./util";
|
||||
import { isLocalRun, isAction } from "./util";
|
||||
|
||||
export enum DisallowedAPIVersionReason {
|
||||
ACTION_TOO_OLD,
|
||||
@@ -37,7 +37,7 @@ export const getApiClient = function (
|
||||
return new githubUtils.GitHub(
|
||||
githubUtils.getOctokitOptions(auth, {
|
||||
baseUrl: getApiUrl(apiDetails.url),
|
||||
userAgent: "CodeQL Action",
|
||||
userAgent: isAction() ? "CodeQL Action" : "CodeQL Runner",
|
||||
log: consoleLogLevel({ level: "debug" }),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -399,6 +399,9 @@ export async function setupCodeQL(
|
||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||
}
|
||||
|
||||
// set a environment variable to let CodeQL know where we are running
|
||||
process.env.CODEQL_WRAPPER = util.isAction() ? "action" : "runner";
|
||||
|
||||
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
|
||||
return { codeql: cachedCodeQL, toolsVersion: codeqlURLVersion };
|
||||
} catch (e) {
|
||||
|
||||
@@ -305,3 +305,10 @@ async function mockStdInForAuthExpectError(
|
||||
util.getGitHubAuth(mockLogger, undefined, true, stdin)
|
||||
);
|
||||
}
|
||||
|
||||
test("isAction", async (t) => {
|
||||
process.env.GITHUB_ACTIONS = "true";
|
||||
t.assert(util.isAction(), "Should be running in actions");
|
||||
delete process.env.GITHUB_ACTIONS;
|
||||
t.assert(!util.isAction(), "Should be running in runner");
|
||||
});
|
||||
|
||||
@@ -390,3 +390,11 @@ export async function getGitHubAuth(
|
||||
"No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this process is running as part of github actions.
|
||||
* False otherwise.
|
||||
*/
|
||||
export function isAction() {
|
||||
return "GITHUB_ACTIONS" in process.env;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user