mirror of
https://github.com/github/codeql-action.git
synced 2025-12-07 00:08:06 +08:00
Compare commits
68 Commits
codeql-bun
...
alexet/win
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8aadff8d91 | ||
|
|
cbbd811c0e | ||
|
|
8373707722 | ||
|
|
09024e50d4 | ||
|
|
daff33213e | ||
|
|
4c3c9b0d41 | ||
|
|
4df078eec5 | ||
|
|
cfec2bbc35 | ||
|
|
18f6367c46 | ||
|
|
2fcc4eb030 | ||
|
|
27ed6ac804 | ||
|
|
c78d81fa3e | ||
|
|
bcca43b391 | ||
|
|
6ddfab14f6 | ||
|
|
039625a3ce | ||
|
|
ce6b93eb0a | ||
|
|
bb51ece0b4 | ||
|
|
fb01860db6 | ||
|
|
2f4f48f767 | ||
|
|
0ff9c449b7 | ||
|
|
bde489c632 | ||
|
|
324d987bc6 | ||
|
|
964ae01287 | ||
|
|
fdf2494cfa | ||
|
|
7f1d7b8bda | ||
|
|
760681b052 | ||
|
|
bcd7b2de1d | ||
|
|
fd0ad84431 | ||
|
|
41b73e168c | ||
|
|
a2653534db | ||
|
|
f84e342ff3 | ||
|
|
2b1c88c014 | ||
|
|
0ab754c698 | ||
|
|
4c94e29f1b | ||
|
|
58defc0652 | ||
|
|
88714e3a60 | ||
|
|
3c63623824 | ||
|
|
1d92248672 | ||
|
|
c6390afb59 | ||
|
|
f2896eb08a | ||
|
|
f8c5dacab5 | ||
|
|
49cb962d82 | ||
|
|
04d2b0018e | ||
|
|
3568e4afcc | ||
|
|
7b72f1c330 | ||
|
|
6452109691 | ||
|
|
c9ca4ec1bd | ||
|
|
0656b2c1ad | ||
|
|
781e3bc540 | ||
|
|
10a2f1b1aa | ||
|
|
c4084e1c1a | ||
|
|
f3f5dfd3df | ||
|
|
169b9f804b | ||
|
|
3d8b1cb7ea | ||
|
|
8fef3928ba | ||
|
|
db540f07f0 | ||
|
|
80a8f97b9c | ||
|
|
1f07e287da | ||
|
|
ed751ece83 | ||
|
|
6408d72268 | ||
|
|
44ed1c6ce1 | ||
|
|
bfa9dfe827 | ||
|
|
19fe854945 | ||
|
|
c2377b2e49 | ||
|
|
74004631ca | ||
|
|
07943dcc5d | ||
|
|
2c62543901 | ||
|
|
18f9eb6b55 |
14
.github/update-release-branch.py
vendored
14
.github/update-release-branch.py
vendored
@@ -35,7 +35,7 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
||||
commits_without_pull_requests = []
|
||||
for commit in all_commits:
|
||||
pr = get_pr_for_commit(repo, commit)
|
||||
|
||||
|
||||
if pr is None:
|
||||
commits_without_pull_requests.append(commit)
|
||||
elif not any(p for p in pull_requests if p.number == pr.number):
|
||||
@@ -47,7 +47,7 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
||||
# Sort PRs and commits by age
|
||||
pull_requests = sorted(pull_requests, key=lambda pr: pr.number)
|
||||
commits_without_pull_requests = sorted(commits_without_pull_requests, key=lambda c: c.commit.author.date)
|
||||
|
||||
|
||||
# Start constructing the body text
|
||||
body = 'Merging ' + short_main_sha + ' into ' + LATEST_RELEASE_BRANCH
|
||||
|
||||
@@ -62,7 +62,7 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
||||
body += '\n- #' + str(pr.number)
|
||||
body += ' - ' + pr.title
|
||||
body += ' (@' + merger + ')'
|
||||
|
||||
|
||||
# List all commits not part of a PR
|
||||
if len(commits_without_pull_requests) > 0:
|
||||
body += '\n\nContains the following commits not from a pull request:'
|
||||
@@ -86,7 +86,7 @@ def get_conductor(repo, pull_requests, other_commits):
|
||||
# If there are any PRs then use whoever merged the last one
|
||||
if len(pull_requests) > 0:
|
||||
return get_merger_of_pr(repo, pull_requests[-1])
|
||||
|
||||
|
||||
# Otherwise take the author of the latest commit
|
||||
return other_commits[-1].author.login
|
||||
|
||||
@@ -95,7 +95,7 @@ def get_conductor(repo, pull_requests, other_commits):
|
||||
# This will not include any commits that exist on the release branch
|
||||
# that aren't on main.
|
||||
def get_commit_difference(repo):
|
||||
commits = run_git('log', '--pretty=format:%H', ORIGIN + '/' + LATEST_RELEASE_BRANCH + '...' + MAIN_BRANCH).strip().split('\n')
|
||||
commits = run_git('log', '--pretty=format:%H', ORIGIN + '/' + LATEST_RELEASE_BRANCH + '..' + MAIN_BRANCH).strip().split('\n')
|
||||
|
||||
# Convert to full-fledged commit objects
|
||||
commits = [repo.get_commit(c) for c in commits]
|
||||
@@ -119,7 +119,7 @@ def get_truncated_commit_message(commit):
|
||||
# Returns the PR object, or None if no PR could be found.
|
||||
def get_pr_for_commit(repo, commit):
|
||||
prs = commit.get_pulls()
|
||||
|
||||
|
||||
if prs.totalCount > 0:
|
||||
# In the case that there are multiple PRs, return the earliest one
|
||||
prs = list(prs)
|
||||
@@ -165,7 +165,7 @@ def main():
|
||||
if branch_exists_on_remote(new_branch_name):
|
||||
print('Branch ' + new_branch_name + ' already exists. Nothing to do.')
|
||||
return
|
||||
|
||||
|
||||
# Create the new branch and push it to the remote
|
||||
print('Creating branch ' + new_branch_name)
|
||||
run_git('checkout', '-b', new_branch_name, MAIN_BRANCH)
|
||||
|
||||
3
.github/workflows/pr-checks.yml
vendored
3
.github/workflows/pr-checks.yml
vendored
@@ -1,5 +1,8 @@
|
||||
name: "PR checks"
|
||||
|
||||
env:
|
||||
GO111MODULE: auto
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, v1]
|
||||
|
||||
1
.github/workflows/update-release-branch.yml
vendored
1
.github/workflows/update-release-branch.yml
vendored
@@ -12,6 +12,7 @@ on:
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository == 'github/codeql-action' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
|
||||
42
lib/actions-util.js
generated
42
lib/actions-util.js
generated
@@ -51,6 +51,13 @@ function getRequiredEnvParam(paramName) {
|
||||
return value;
|
||||
}
|
||||
exports.getRequiredEnvParam = getRequiredEnvParam;
|
||||
function getTemporaryDirectory() {
|
||||
const value = process.env["CODEQL_ACTION_TEMP"];
|
||||
return value !== undefined && value !== ""
|
||||
? value
|
||||
: getRequiredEnvParam("RUNNER_TEMP");
|
||||
}
|
||||
exports.getTemporaryDirectory = getTemporaryDirectory;
|
||||
/**
|
||||
* Ensures all required environment variables are set in the context of a local run.
|
||||
*/
|
||||
@@ -141,12 +148,6 @@ function branchesToArray(branches) {
|
||||
}
|
||||
return "**";
|
||||
}
|
||||
var MissingTriggers;
|
||||
(function (MissingTriggers) {
|
||||
MissingTriggers[MissingTriggers["None"] = 0] = "None";
|
||||
MissingTriggers[MissingTriggers["Push"] = 1] = "Push";
|
||||
MissingTriggers[MissingTriggers["PullRequest"] = 2] = "PullRequest";
|
||||
})(MissingTriggers || (MissingTriggers = {}));
|
||||
function toCodedErrors(errors) {
|
||||
return Object.entries(errors).reduce((acc, [key, value]) => {
|
||||
acc[key] = { message: value, code: key };
|
||||
@@ -157,8 +158,6 @@ function toCodedErrors(errors) {
|
||||
// message to add as a warning annotation to the run
|
||||
exports.WorkflowErrors = toCodedErrors({
|
||||
MismatchedBranches: `Please make sure that every branch in on.pull_request is also in on.push so that Code Scanning can compare pull requests against the state of the base branch.`,
|
||||
MissingHooks: `Please specify on.push and on.pull_request hooks so that Code Scanning can compare pull requests against the state of the base branch.`,
|
||||
MissingPullRequestHook: `Please specify an on.pull_request hook so that Code Scanning is explicitly run against pull requests. This will be required to see results on pull requests from January 31 2021.`,
|
||||
MissingPushHook: `Please specify an on.push hook so that Code Scanning can compare pull requests against the state of the base branch.`,
|
||||
PathsSpecified: `Using on.push.paths can prevent Code Scanning annotating new alerts in your pull requests.`,
|
||||
PathsIgnoreSpecified: `Using on.push.paths-ignore can prevent Code Scanning annotating new alerts in your pull requests.`,
|
||||
@@ -185,27 +184,27 @@ function getWorkflowErrors(doc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
let missing = MissingTriggers.None;
|
||||
let missingPush = false;
|
||||
if (doc.on === undefined) {
|
||||
// this is not a valid config
|
||||
}
|
||||
else if (typeof doc.on === "string") {
|
||||
if (doc.on === "pull_request") {
|
||||
missing = MissingTriggers.Push;
|
||||
missingPush = true;
|
||||
}
|
||||
}
|
||||
else if (Array.isArray(doc.on)) {
|
||||
const hasPush = doc.on.includes("push");
|
||||
const hasPullRequest = doc.on.includes("pull_request");
|
||||
if (hasPullRequest && !hasPush) {
|
||||
missing = missing | MissingTriggers.Push;
|
||||
missingPush = true;
|
||||
}
|
||||
}
|
||||
else if (isObject(doc.on)) {
|
||||
const hasPush = Object.prototype.hasOwnProperty.call(doc.on, "push");
|
||||
const hasPullRequest = Object.prototype.hasOwnProperty.call(doc.on, "pull_request");
|
||||
if (!hasPush && hasPullRequest) {
|
||||
missing = missing | MissingTriggers.Push;
|
||||
missingPush = true;
|
||||
}
|
||||
if (hasPush && hasPullRequest) {
|
||||
const paths = (_e = doc.on.push) === null || _e === void 0 ? void 0 : _e.paths;
|
||||
@@ -243,21 +242,8 @@ function getWorkflowErrors(doc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// on is not a known type
|
||||
// this workflow is likely malformed
|
||||
missing = MissingTriggers.Push | MissingTriggers.PullRequest;
|
||||
}
|
||||
switch (missing) {
|
||||
case MissingTriggers.PullRequest | MissingTriggers.Push:
|
||||
errors.push(exports.WorkflowErrors.MissingHooks);
|
||||
break;
|
||||
case MissingTriggers.PullRequest:
|
||||
errors.push(exports.WorkflowErrors.MissingPullRequestHook);
|
||||
break;
|
||||
case MissingTriggers.Push:
|
||||
errors.push(exports.WorkflowErrors.MissingPushHook);
|
||||
break;
|
||||
if (missingPush) {
|
||||
errors.push(exports.WorkflowErrors.MissingPushHook);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
@@ -287,7 +273,7 @@ async function validateWorkflow() {
|
||||
}
|
||||
core.warning(message);
|
||||
}
|
||||
return `warning: ${formatWorkflowCause(workflowErrors)}`;
|
||||
return formatWorkflowCause(workflowErrors);
|
||||
}
|
||||
exports.validateWorkflow = validateWorkflow;
|
||||
function formatWorkflowErrors(errors) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
22
lib/actions-util.test.js
generated
22
lib/actions-util.test.js
generated
@@ -167,39 +167,39 @@ ava_1.default("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: 1,
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: [1],
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: { 1: 1 },
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: { test: 1 },
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: { test: [1] },
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: { test: { steps: 1 } },
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: { test: { steps: [{ notrun: "git checkout HEAD^2" }] } },
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
jobs: { test: [undefined] },
|
||||
}), [actionsutil.WorkflowErrors.MissingHooks]));
|
||||
}), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(1), []));
|
||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||
on: {
|
||||
@@ -261,6 +261,10 @@ ava_1.default("formatWorkflowErrors() when there are multiple errors", (t) => {
|
||||
]);
|
||||
t.true(message.startsWith("2 issues were detected with this workflow:"));
|
||||
});
|
||||
ava_1.default("formatWorkflowCause() with no errors", (t) => {
|
||||
const message = actionsutil.formatWorkflowCause([]);
|
||||
t.deepEqual(message, undefined);
|
||||
});
|
||||
ava_1.default("formatWorkflowCause()", (t) => {
|
||||
const message = actionsutil.formatWorkflowCause([
|
||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
lib/analysis-paths.test.js
generated
6
lib/analysis-paths.test.js
generated
@@ -27,7 +27,7 @@ ava_1.default("emptyPaths", async (t) => {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" },
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||
@@ -46,7 +46,7 @@ ava_1.default("nonEmptyPaths", async (t) => {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" },
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
||||
@@ -66,7 +66,7 @@ ava_1.default("exclude temp dir", async (t) => {
|
||||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" },
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"analysis-paths.test.js","sourceRoot":"","sources":["../src/analysis-paths.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,gEAAkD;AAClD,mDAA6C;AAC7C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC7B,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;YACT,iBAAiB,EAAE,EAAE;YACrB,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,MAAM;YACpB,SAAS,EAAE,EAAE;YACb,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAwB;SACxD,CAAC;QACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,eAAe,EAAE,KA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AE,YAAY,EAAE,EAAE;QAClD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;YACT,iBAAiB,EAAE,EAAE;YACrB,OAAO;YACP,YAAY;YACZ,SAAS,EAAE,EAAE;YACb,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAwB;SACzE,CAAC;QACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||
5
lib/analyze-action.js
generated
5
lib/analyze-action.js
generated
@@ -14,7 +14,6 @@ const actionsUtil = __importStar(require("./actions-util"));
|
||||
const analyze_1 = require("./analyze");
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
const upload_lib = __importStar(require("./upload-lib"));
|
||||
const util = __importStar(require("./util"));
|
||||
async function sendStatusReport(startedAt, stats, error) {
|
||||
@@ -39,7 +38,7 @@ async function run() {
|
||||
return;
|
||||
}
|
||||
const logger = logging_1.getActionsLogger();
|
||||
config = await config_utils_1.getConfig(actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), logger);
|
||||
config = await config_utils_1.getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||
}
|
||||
@@ -50,7 +49,7 @@ async function run() {
|
||||
const outputDir = actionsUtil.getRequiredInput("output");
|
||||
const queriesStats = await analyze_1.runAnalyze(outputDir, util.getMemoryFlag(actionsUtil.getOptionalInput("ram")), util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger), config, logger);
|
||||
if (actionsUtil.getRequiredInput("upload") === "true") {
|
||||
const uploadStats = await upload_lib.uploadFromActions(outputDir, repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), config.gitHubVersion, apiDetails, logger);
|
||||
const uploadStats = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
||||
stats = { ...queriesStats, ...uploadStats };
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"analyze-action.js","sourceRoot":"","sources":["../src/analyze-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAImB;AACnB,iDAAmD;AACnD,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,6CAA+B;AAU/B,KAAK,UAAU,gBAAgB,CAC7B,SAAe,EACf,KAAuC,EACvC,KAAa;;IAEb,MAAM,MAAM,GACV,OAAA,KAAK,0CAAE,wBAAwB,MAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAClE,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,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CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;yBAC7C;qBACF;gBACH,CAAC,CAAC;gBACF,YAAY,CAAC,aAAa,CAAC,CAAC;aAC7B;SACF;KACF;IAED,MAAM,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
4
lib/analyze.test.js
generated
4
lib/analyze.test.js
generated
@@ -39,7 +39,9 @@ ava_1.default("status report fields", async (t) => {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" },
|
||||
gitHubVersion: {
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
},
|
||||
};
|
||||
fs.mkdirSync(util.getCodeQLDatabasePath(config.tempDir, language), {
|
||||
recursive: true,
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"analyze.test.js","sourceRoot":"","sources":["../src/analyze.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyB;AAEzB,8CAAuB;AAEvB,uCAAuC;AACvC,qCAAqC;AAErC,2CAAuC;AACvC,uCAA4C;AAC5C,mDAA6C;AAC7C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,yEAAyE;AACzE,yCAAyC;AACzC,aAAI,CAAC,sBAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACvC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5C,kBAAS,CAA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CAAC,CAAC,CAAC"}
|
||||
@@ -1 +1 @@
|
||||
{ "maximumVersion": "3.0", "minimumVersion": "2.22" }
|
||||
{ "maximumVersion": "3.1", "minimumVersion": "2.22" }
|
||||
|
||||
2
lib/autobuild-action.js
generated
2
lib/autobuild-action.js
generated
@@ -34,7 +34,7 @@ async function run() {
|
||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("autobuild", "starting", startedAt)))) {
|
||||
return;
|
||||
}
|
||||
const config = await config_utils.getConfig(actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), logger);
|
||||
const config = await config_utils.getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,2CAAuE;AACvE,6DAA+C;AAE/C,uCAA6C;AAS7C,KAAK,UAAU,yBAAyB,CACtC,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;;IAEb,MAAM,MAAM,GACV,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAClD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,WAAW,EACX,MAAM,EACN,SAAS,QACT,KAAK,0CAAE,OAAO,QACd,KAAK,0CAAE,KAAK,CACb,CAAC;IACF,MAAM,YAAY,GAA0B;QAC1C,GAAG,gBAAgB;QACnB,mBAAmB,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,iBAAiB,EAAE,eAAe;KACnC,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAA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;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,2CAAuE;AACvE,6DAA+C;AAE/C,uCAA6C;AAS7C,KAAK,UAAU,yBAAyB,CACtC,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;;IAEb,MAAM,MAAM,GACV,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAClD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,WAAW,EACX,MAAM,EACN,SAAS,QACT,KAAK,0CAAE,OAAO,QACd,KAAK,0CAAE,KAAK,CACb,CAAC;IACF,MAAM,YAAY,GAA0B;QAC1C,GAAG,gBAAgB;QACnB,mBAAmB,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,iBAAiB,EAAE,eAAe;KACnC,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,MAAM,GAAG,0BAAgB,EAAE,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAI,QAAQ,GAAyB,SAAS,CAAC;IAC/C,IAAI;QACF,WAAW,CAAC,0BAA0B,EAAE,CAAC;QACzC,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,WAAW,EACX,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;YACA,OAAO;SACR;QAED,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,SAAS,CACzC,WAAW,CAAC,qBAAqB,EAAE,EACnC,MAAM,CACP,CAAC;QACF,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;SACH;QACD,QAAQ,GAAG,sCAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,MAAM,wBAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;SAC9C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CACZ,mIAAmI,KAAK,CAAC,OAAO,EAAE,CACnJ,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,yBAAyB,CAC7B,SAAS,EACT,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAC1B,QAAQ,EACR,KAAK,CACN,CAAC;QACF,OAAO;KACR;IAED,MAAM,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
42
lib/codeql.js
generated
42
lib/codeql.js
generated
@@ -18,6 +18,7 @@ const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||
const http = __importStar(require("@actions/http-client"));
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
||||
const query_string_1 = __importDefault(require("query-string"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const uuid_1 = require("uuid");
|
||||
const actions_util_1 = require("./actions-util");
|
||||
@@ -53,6 +54,11 @@ function getCodeQLActionRepository(mode, logger) {
|
||||
if (mode !== "actions") {
|
||||
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
||||
}
|
||||
else {
|
||||
return getActionsCodeQLActionRepository(logger);
|
||||
}
|
||||
}
|
||||
function getActionsCodeQLActionRepository(logger) {
|
||||
if (process.env["GITHUB_ACTION_REPOSITORY"] !== undefined) {
|
||||
return process.env["GITHUB_ACTION_REPOSITORY"];
|
||||
}
|
||||
@@ -68,7 +74,7 @@ function getCodeQLActionRepository(mode, logger) {
|
||||
const relativeScriptPathParts = actions_util_1.getRelativeScriptPath().split(path.sep);
|
||||
return `${relativeScriptPathParts[0]}/${relativeScriptPathParts[1]}`;
|
||||
}
|
||||
async function getCodeQLBundleDownloadURL(apiDetails, mode, logger) {
|
||||
async function getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger) {
|
||||
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
||||
const potentialDownloadSources = [
|
||||
// This GitHub instance, and this Action.
|
||||
@@ -84,6 +90,30 @@ async function getCodeQLBundleDownloadURL(apiDetails, mode, logger) {
|
||||
return !self.slice(0, index).some((other) => fast_deep_equal_1.default(source, other));
|
||||
});
|
||||
const codeQLBundleName = getCodeQLBundleName();
|
||||
if (variant === util.GitHubVariant.GHAE) {
|
||||
try {
|
||||
const release = await api
|
||||
.getApiClient(apiDetails)
|
||||
.request("GET /enterprise/code-scanning/codeql-bundle/find/{tag}", {
|
||||
tag: CODEQL_BUNDLE_VERSION,
|
||||
});
|
||||
const assetID = release.data.assets[codeQLBundleName];
|
||||
if (assetID !== undefined) {
|
||||
const download = await api
|
||||
.getApiClient(apiDetails)
|
||||
.request("GET /enterprise/code-scanning/codeql-bundle/download/{asset_id}", { asset_id: assetID });
|
||||
const downloadURL = download.data.url;
|
||||
logger.info(`Found CodeQL bundle at GitHub AE endpoint with URL ${downloadURL}.`);
|
||||
return downloadURL;
|
||||
}
|
||||
else {
|
||||
logger.info(`Attempted to fetch bundle from GitHub AE endpoint but the bundle ${codeQLBundleName} was not found in the assets ${JSON.stringify(release.data.assets)}.`);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
logger.info(`Attempted to fetch bundle from GitHub AE endpoint but got error ${e}.`);
|
||||
}
|
||||
}
|
||||
for (const downloadSource of uniqueDownloadSources) {
|
||||
const [apiURL, repository] = downloadSource;
|
||||
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
|
||||
@@ -126,7 +156,7 @@ async function toolcacheDownloadTool(url, headers, tempDir, logger) {
|
||||
await pipeline(response.message, fs.createWriteStream(dest));
|
||||
return dest;
|
||||
}
|
||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, logger) {
|
||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, variant, logger) {
|
||||
// Setting these two env vars makes the toolcache code safe to use outside,
|
||||
// of actions but this is obviously not a great thing we're doing and it would
|
||||
// be better to write our own implementation to use outside of actions.
|
||||
@@ -161,13 +191,17 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, logge
|
||||
}
|
||||
else {
|
||||
if (!codeqlURL) {
|
||||
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, logger);
|
||||
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger);
|
||||
}
|
||||
const parsedCodeQLURL = new URL(codeqlURL);
|
||||
const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search);
|
||||
const headers = { accept: "application/octet-stream" };
|
||||
// We only want to provide an authorization header if we are downloading
|
||||
// from the same GitHub instance the Action is running on.
|
||||
// This avoids leaking Enterprise tokens to dotcom.
|
||||
if (codeqlURL.startsWith(`${apiDetails.url}/`)) {
|
||||
// We also don't want to send an authorization header if there's already a token provided in the URL.
|
||||
if (codeqlURL.startsWith(`${apiDetails.url}/`) &&
|
||||
parsedQueryString["token"] === undefined) {
|
||||
logger.debug("Downloading CodeQL bundle with token.");
|
||||
headers.authorization = `token ${apiDetails.auth}`;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
49
lib/codeql.test.js
generated
49
lib/codeql.test.js
generated
@@ -24,6 +24,10 @@ const sampleApiDetails = {
|
||||
auth: "token",
|
||||
url: "https://github.com",
|
||||
};
|
||||
const sampleGHAEApiDetails = {
|
||||
auth: "token",
|
||||
url: "https://example.githubenterprise.com",
|
||||
};
|
||||
ava_1.default("download codeql bundle cache", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const versions = ["20200601", "20200610"];
|
||||
@@ -32,7 +36,7 @@ ava_1.default("download codeql bundle cache", async (t) => {
|
||||
nock_1.default("https://example.com")
|
||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||
}
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
@@ -44,12 +48,12 @@ ava_1.default("download codeql bundle cache explicitly requested with pinned dif
|
||||
nock_1.default("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||
nock_1.default("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||
});
|
||||
});
|
||||
@@ -58,9 +62,9 @@ ava_1.default("don't download codeql bundle cache with pinned different version
|
||||
nock_1.default("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
@@ -70,7 +74,7 @@ ava_1.default("download codeql bundle cache with different version cached (not p
|
||||
nock_1.default("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||
const platform = process.platform === "win32"
|
||||
? "win64"
|
||||
@@ -80,7 +84,7 @@ ava_1.default("download codeql bundle cache with different version cached (not p
|
||||
nock_1.default("https://github.com")
|
||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 2);
|
||||
});
|
||||
@@ -90,7 +94,7 @@ ava_1.default('download codeql bundle cache with pinned different version cached
|
||||
nock_1.default("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||
const platform = process.platform === "win32"
|
||||
? "win64"
|
||||
@@ -100,11 +104,38 @@ ava_1.default('download codeql bundle cache with pinned different version cached
|
||||
nock_1.default("https://github.com")
|
||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 2);
|
||||
});
|
||||
});
|
||||
ava_1.default("download codeql bundle from github ae endpoint", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const bundleAssetID = 10;
|
||||
const platform = process.platform === "win32"
|
||||
? "win64"
|
||||
: process.platform === "linux"
|
||||
? "linux64"
|
||||
: "osx64";
|
||||
const codeQLBundleName = `codeql-bundle-${platform}.tar.gz`;
|
||||
nock_1.default("https://example.githubenterprise.com")
|
||||
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/find/${defaults.bundleVersion}`)
|
||||
.reply(200, {
|
||||
assets: { [codeQLBundleName]: bundleAssetID },
|
||||
});
|
||||
nock_1.default("https://example.githubenterprise.com")
|
||||
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/download/${bundleAssetID}`)
|
||||
.reply(200, {
|
||||
url: `https://example.githubenterprise.com/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`,
|
||||
});
|
||||
nock_1.default("https://example.githubenterprise.com")
|
||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.GHAE, logging_1.getRunnerLogger(true));
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
});
|
||||
ava_1.default("parse codeql bundle url version", (t) => {
|
||||
t.deepEqual(codeql.getCodeQLURLVersion("https://github.com/.../codeql-bundle-20200601/..."), "20200601");
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
lib/config-utils.test.js
generated
2
lib/config-utils.test.js
generated
@@ -28,7 +28,7 @@ const sampleApiDetails = {
|
||||
externalRepoAuth: "token",
|
||||
url: "https://github.example.com",
|
||||
};
|
||||
const gitHubVersion = { type: "dotcom" };
|
||||
const gitHubVersion = { type: util.GitHubVariant.DOTCOM };
|
||||
// Returns the filepath of the newly-created file
|
||||
function createConfigFile(inputFileContents, tmpDir) {
|
||||
const configFilePath = path.join(tmpDir, "input");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-20201127"
|
||||
"bundleVersion": "codeql-bundle-20210308"
|
||||
}
|
||||
|
||||
8
lib/init-action.js
generated
8
lib/init-action.js
generated
@@ -60,19 +60,17 @@ async function run() {
|
||||
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
};
|
||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||
if (gitHubVersion !== undefined) {
|
||||
util_1.checkGitHubVersionInRange(gitHubVersion, "actions", logger);
|
||||
}
|
||||
util_1.checkGitHubVersionInRange(gitHubVersion, "actions", logger);
|
||||
try {
|
||||
actionsUtil.prepareLocalRunEnvironment();
|
||||
const workflowErrors = await actionsUtil.validateWorkflow();
|
||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt, workflowErrors)))) {
|
||||
return;
|
||||
}
|
||||
const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), apiDetails, actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), "actions", logger);
|
||||
const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), apiDetails, actionsUtil.getTemporaryDirectory(), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), "actions", gitHubVersion.type, logger);
|
||||
codeql = initCodeQLResult.codeql;
|
||||
toolsVersion = initCodeQLResult.toolsVersion;
|
||||
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
||||
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getTemporaryDirectory(), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
||||
if (config.languages.includes(languages_1.Language.python) &&
|
||||
actionsUtil.getRequiredInput("setup-python-dependencies") === "true") {
|
||||
try {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAG9C,iCAMgB;AAChB,2CAAuC;AACvC,uCAA6C;AAC7C,6CAAkD;AAClD,iCAAqE;AAsBrE,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,MAA0B,EAC1B,YAAoB;;IAEpB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,MAAM,EACN,SAAS,EACT,SAAS,CACV,CAAC;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,iBAAiB,GAAG,WAAW,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CACvE,GAAG,CACJ,CAAC;IACF,MAAM,qBAAqB,GAAG,MAAM,CAAC,iBAAiB,CACpD,yBAAyB,CAC1B;QACC,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,YAAY,SAAG,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,0CAAE,IAAI,EAAE,CAAC;IACnE,IAAI,YAAY,KAA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,EACb,KAAK,CAAC,KAAK,CACZ,CACF,CAAC;QACF,OAAO;KACR;IACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACjE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAC;QAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
8
lib/init.js
generated
8
lib/init.js
generated
@@ -16,9 +16,9 @@ const codeql_1 = require("./codeql");
|
||||
const configUtils = __importStar(require("./config-utils"));
|
||||
const tracer_config_1 = require("./tracer-config");
|
||||
const util = __importStar(require("./util"));
|
||||
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, logger) {
|
||||
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, variant, logger) {
|
||||
logger.startGroup("Setup CodeQL tools");
|
||||
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, logger);
|
||||
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolsDir, mode, variant, logger);
|
||||
await codeql.printVersion();
|
||||
logger.endGroup();
|
||||
return { codeql, toolsVersion };
|
||||
@@ -60,6 +60,7 @@ async function injectWindowsTracer(processName, processLevel, config, codeql, tr
|
||||
|
||||
$id = $PID
|
||||
while ($true) {
|
||||
Write-Host "Looking for process with id : $id"
|
||||
$p = Get-CimInstance -Class Win32_Process -Filter "ProcessId = $id"
|
||||
Write-Host "Found process: $p"
|
||||
if ($p -eq $null) {
|
||||
@@ -72,7 +73,8 @@ async function injectWindowsTracer(processName, processLevel, config, codeql, tr
|
||||
}
|
||||
}
|
||||
Write-Host "Final process: $p"
|
||||
|
||||
Write-Host "Final pid: $id"
|
||||
Write-Host "Running: &$tracer --inject=$id"
|
||||
Invoke-Expression "&$tracer --inject=$id"`;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA+C;AAC/C,4DAA8C;AAG9C,mDAAwE;AACxE,6CAA+B;AAExB,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,QAAgB,EAChB,IAAe,EACf,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,oBAAW,CAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,MAAM,CACP,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AApBD,gCAoBC;AAEM,KAAK,UAAU,UAAU,CAC9B,cAAkC,EAClC,YAAgC,EAChC,UAA8B,EAC9B,UAAyB,EACzB,OAAe,EACf,YAAoB,EACpB,MAAc,EACd,YAAoB,EACpB,aAAiC,EACjC,UAAoC,EACpC,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CACzC,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,OAAO,EACP,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,UAAU,EACV,MAAM,CACP,CAAC;IACF,aAAa,CAAC,uBAAuB,CAAC,MAAM,EAAE,M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CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE;gBAChE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,+IAA+I,CAChJ,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAnDD,8CAmDC"}
|
||||
27
lib/runner.js
generated
27
lib/runner.js
generated
@@ -82,8 +82,8 @@ program
|
||||
.description("Initializes CodeQL")
|
||||
.requiredOption("--repository <repository>", "Repository name. (Required)")
|
||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||
.requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
|
||||
.option("--external-repository-token <token>", "A token for fetching external config files and queries if they reside in a private repository.")
|
||||
.option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
|
||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
||||
.option("--languages <languages>", "Comma-separated list of languages to analyze. Otherwise detects and analyzes all supported languages from the repo.")
|
||||
.option("--queries <queries>", "Comma-separated list of additional queries to run. This overrides the same setting in a configuration file.")
|
||||
.option("--config-file <file>", "Path to config file.")
|
||||
@@ -104,21 +104,20 @@ program
|
||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||
fs.rmdirSync(tempDir, { recursive: true });
|
||||
fs.mkdirSync(tempDir, { recursive: true });
|
||||
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
||||
const apiDetails = {
|
||||
auth: cmd.githubAuth,
|
||||
externalRepoAuth: cmd.externalRepositoryToken,
|
||||
auth,
|
||||
externalRepoAuth: auth,
|
||||
url: util_1.parseGithubUrl(cmd.githubUrl),
|
||||
};
|
||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||
if (gitHubVersion !== undefined) {
|
||||
util_1.checkGitHubVersionInRange(gitHubVersion, "runner", logger);
|
||||
}
|
||||
util_1.checkGitHubVersionInRange(gitHubVersion, "runner", logger);
|
||||
let codeql;
|
||||
if (cmd.codeqlPath !== undefined) {
|
||||
codeql = codeql_1.getCodeQL(cmd.codeqlPath);
|
||||
}
|
||||
else {
|
||||
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, "runner", logger)).codeql;
|
||||
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, "runner", gitHubVersion.type, logger)).codeql;
|
||||
}
|
||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger);
|
||||
const tracerConfig = await init_1.runInit(codeql, config);
|
||||
@@ -209,7 +208,8 @@ program
|
||||
.requiredOption("--commit <commit>", "SHA of commit that was analyzed. (Required)")
|
||||
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||
.requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
|
||||
.option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
|
||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
||||
.option("--checkout-path <path>", "Checkout path. Default is the current working directory.")
|
||||
.option("--no-upload", "Do not upload results after analysis.")
|
||||
.option("--output-dir <dir>", "Directory to output SARIF files to. Default is in the temp directory.")
|
||||
@@ -229,8 +229,9 @@ program
|
||||
throw new Error("Config file could not be found at expected location. " +
|
||||
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
|
||||
}
|
||||
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
||||
const apiDetails = {
|
||||
auth: cmd.githubAuth,
|
||||
auth,
|
||||
url: util_1.parseGithubUrl(cmd.githubUrl),
|
||||
};
|
||||
await analyze_1.runAnalyze(outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger);
|
||||
@@ -254,13 +255,15 @@ program
|
||||
.requiredOption("--commit <commit>", "SHA of commit that was analyzed. (Required)")
|
||||
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||
.requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
|
||||
.option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
|
||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
||||
.option("--checkout-path <path>", "Checkout path. Default is the current working directory.")
|
||||
.option("--debug", "Print more verbose output", false)
|
||||
.action(async (cmd) => {
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
||||
const apiDetails = {
|
||||
auth: cmd.githubAuth,
|
||||
auth,
|
||||
url: util_1.parseGithubUrl(cmd.githubUrl),
|
||||
};
|
||||
try {
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
lib/tracer-config.test.js
generated
2
lib/tracer-config.test.js
generated
@@ -29,7 +29,7 @@ function getTestConfig(tmpDir) {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" },
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
};
|
||||
}
|
||||
// A very minimal setup
|
||||
|
||||
File diff suppressed because one or more lines are too long
8
lib/upload-lib.js
generated
8
lib/upload-lib.js
generated
@@ -17,8 +17,10 @@ const core = __importStar(require("@actions/core"));
|
||||
const file_url_1 = __importDefault(require("file-url"));
|
||||
const jsonschema = __importStar(require("jsonschema"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const fingerprints = __importStar(require("./fingerprints"));
|
||||
const repository_1 = require("./repository");
|
||||
const sharedEnv = __importStar(require("./shared-environment"));
|
||||
const util = __importStar(require("./util"));
|
||||
// Takes a list of paths to sarif files and combines them together,
|
||||
@@ -85,8 +87,8 @@ exports.findSarifFilesInDir = findSarifFilesInDir;
|
||||
// Uploads a single sarif file or a directory of sarif files
|
||||
// depending on what the path happens to refer to.
|
||||
// Returns true iff the upload occurred and succeeded
|
||||
async function uploadFromActions(sarifPath, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, gitHubVersion, apiDetails, logger) {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, gitHubVersion, apiDetails, "actions", logger);
|
||||
async function uploadFromActions(sarifPath, gitHubVersion, apiDetails, logger) {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), gitHubVersion, apiDetails, "actions", logger);
|
||||
}
|
||||
exports.uploadFromActions = uploadFromActions;
|
||||
// Uploads a single sarif file or a directory of sarif files
|
||||
@@ -160,7 +162,7 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
|
||||
base_sha: undefined,
|
||||
};
|
||||
// This behaviour can be made the default when support for GHES 3.0 is discontinued.
|
||||
if (gitHubVersion.type === "dotcom" ||
|
||||
if (gitHubVersion.type !== util.GitHubVariant.GHES ||
|
||||
semver.satisfies(gitHubVersion.version, `>=3.1`)) {
|
||||
if (process.env.GITHUB_EVENT_NAME === "pull_request" &&
|
||||
process.env.GITHUB_EVENT_PATH) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
8
lib/upload-lib.test.js
generated
8
lib/upload-lib.test.js
generated
@@ -28,12 +28,12 @@ ava_1.default("validateSarifFileSchema - invalid", (t) => {
|
||||
});
|
||||
ava_1.default("validate correct payload used per version", async (t) => {
|
||||
const newVersions = [
|
||||
{ type: "dotcom" },
|
||||
{ type: "ghes", version: "3.1.0" },
|
||||
{ type: util_1.GitHubVariant.DOTCOM },
|
||||
{ type: util_1.GitHubVariant.GHES, version: "3.1.0" },
|
||||
];
|
||||
const oldVersions = [
|
||||
{ type: "ghes", version: "2.22.1" },
|
||||
{ type: "ghes", version: "3.0.0" },
|
||||
{ type: util_1.GitHubVariant.GHES, version: "2.22.1" },
|
||||
{ type: util_1.GitHubVariant.GHES, version: "3.0.0" },
|
||||
];
|
||||
const allVersions = newVersions.concat(oldVersions);
|
||||
process.env["GITHUB_EVENT_NAME"] = "push";
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"upload-lib.test.js","sourceRoot":"","sources":["../src/upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,8CAAuB;AAEvB,uCAA4C;AAC5C,mDAA6C;AAC7C,wDAA0C;AAC1C,iCAAmD;AAEnD,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE,EAAE;IAC5C,MAAM,SAAS,GAAG,GAAG,SAAS,o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I,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAChD,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QAEnE,4BAA4B;QAC5B,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACxC,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC;QACrE,EAAE,CAAC,WAAW,CACZ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,EAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAC3C,MAAM,CACP,CAAC;QAEF,MAAM,UAAU,GAAG,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAEzD,CAAC,CAAC,SAAS,CAAC,UAAU,EAAE;YACtB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||
3
lib/upload-sarif-action.js
generated
3
lib/upload-sarif-action.js
generated
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
const upload_lib = __importStar(require("./upload-lib"));
|
||||
const util_1 = require("./util");
|
||||
async function sendSuccessStatusReport(startedAt, uploadStats) {
|
||||
@@ -32,7 +31,7 @@ async function run() {
|
||||
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
};
|
||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), gitHubVersion, apiDetails, logging_1.getActionsLogger());
|
||||
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, logging_1.getActionsLogger());
|
||||
await sendSuccessStatusReport(startedAt, uploadStats);
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAA0C;AAM1C,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SA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,KAAK,CAAC,KAAK,CACZ,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAA6C;AAC7C,yDAA2C;AAC3C,iCAA0C;AAM1C,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;QACA,OAAO;KACR;IAED,IAAI;QACF,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAC3C,GAAG,EAAE,WAAW,CAAC,mBAAmB,CAAC,mBAAmB,CAAC;SAC1D,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,uBAAgB,CAAC,UAAU,CAAC,CAAC;QAEzD,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,iBAAiB,CACpD,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAC1C,aAAa,EACb,UAAU,EACV,0BAAgB,EAAE,CACnB,CAAC;QACF,MAAM,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;KACvD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,SAAS,EACT,SAAS,EACT,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,KAAK,CACZ,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
86
lib/util.js
generated
86
lib/util.js
generated
@@ -72,9 +72,21 @@ async function withTmpDir(body) {
|
||||
return result;
|
||||
}
|
||||
exports.withTmpDir = withTmpDir;
|
||||
/**
|
||||
* Gets an OS-specific amount of memory (in MB) to reserve for OS processes
|
||||
* when the user doesn't explicitly specify a memory setting.
|
||||
* This is a heuristic to avoid OOM errors (exit code 137 / SIGKILL)
|
||||
* from committing too much of the available memory to CodeQL.
|
||||
* @returns number
|
||||
*/
|
||||
function getSystemReservedMemoryMegaBytes() {
|
||||
// Windows needs more memory for OS processes.
|
||||
return 1024 * (process.platform === "win32" ? 1.5 : 1);
|
||||
}
|
||||
/**
|
||||
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
||||
* specified, the total available memory will be used minus 256 MB.
|
||||
* specified, the total available memory will be used minus a threshold
|
||||
* reserved for the OS.
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
@@ -89,8 +101,8 @@ function getMemoryFlag(userInput) {
|
||||
else {
|
||||
const totalMemoryBytes = os.totalmem();
|
||||
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
||||
const systemReservedMemoryMegaBytes = 256;
|
||||
memoryToUseMegaBytes = totalMemoryMegaBytes - systemReservedMemoryMegaBytes;
|
||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
||||
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
||||
}
|
||||
return `--ram=${Math.floor(memoryToUseMegaBytes)}`;
|
||||
}
|
||||
@@ -197,10 +209,16 @@ exports.parseGithubUrl = parseGithubUrl;
|
||||
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
|
||||
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
let hasBeenWarnedAboutVersion = false;
|
||||
var GitHubVariant;
|
||||
(function (GitHubVariant) {
|
||||
GitHubVariant[GitHubVariant["DOTCOM"] = 0] = "DOTCOM";
|
||||
GitHubVariant[GitHubVariant["GHES"] = 1] = "GHES";
|
||||
GitHubVariant[GitHubVariant["GHAE"] = 2] = "GHAE";
|
||||
})(GitHubVariant = exports.GitHubVariant || (exports.GitHubVariant = {}));
|
||||
async function getGitHubVersion(apiDetails) {
|
||||
// We can avoid making an API request in the standard dotcom case
|
||||
if (parseGithubUrl(apiDetails.url) === exports.GITHUB_DOTCOM_URL) {
|
||||
return { type: "dotcom" };
|
||||
return { type: GitHubVariant.DOTCOM };
|
||||
}
|
||||
// Doesn't strictly have to be the meta endpoint as we're only
|
||||
// using the response headers which are available on every request.
|
||||
@@ -209,14 +227,17 @@ async function getGitHubVersion(apiDetails) {
|
||||
// This happens on dotcom, although we expect to have already returned in that
|
||||
// case. This can also serve as a fallback in cases we haven't foreseen.
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === undefined) {
|
||||
return { type: "dotcom" };
|
||||
return { type: GitHubVariant.DOTCOM };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "GitHub AE") {
|
||||
return { type: GitHubVariant.GHAE };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: "ghes", version };
|
||||
return { type: GitHubVariant.GHES, version };
|
||||
}
|
||||
exports.getGitHubVersion = getGitHubVersion;
|
||||
function checkGitHubVersionInRange(version, mode, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "ghes") {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== GitHubVariant.GHES) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(version.version, apiCompatibility.minimumVersion, apiCompatibility.maximumVersion);
|
||||
@@ -248,4 +269,55 @@ function apiVersionInRange(version, minimumVersion, maximumVersion) {
|
||||
return undefined;
|
||||
}
|
||||
exports.apiVersionInRange = apiVersionInRange;
|
||||
/**
|
||||
* Retrieves the github auth token for use with the runner. There are
|
||||
* three possible locations for the token:
|
||||
*
|
||||
* 1. from the cli (considered insecure)
|
||||
* 2. from stdin
|
||||
* 3. from the GITHUB_TOKEN environment variable
|
||||
*
|
||||
* If both 1 & 2 are specified, then an error is thrown.
|
||||
* If 1 & 3 or 2 & 3 are specified, then the environment variable is ignored.
|
||||
*
|
||||
* @param githubAuth a github app token or PAT
|
||||
* @param fromStdIn read the github app token or PAT from stdin up to, but excluding the first whitespace
|
||||
* @param readable the readable stream to use for getting the token (defaults to stdin)
|
||||
*
|
||||
* @return a promise resolving to the auth token.
|
||||
*/
|
||||
async function getGitHubAuth(logger, githubAuth, fromStdIn, readable = process.stdin) {
|
||||
if (githubAuth && fromStdIn) {
|
||||
throw new Error("Cannot specify both `--github-auth` and `--github-auth-stdin`. Please use `--github-auth-stdin`, which is more secure.");
|
||||
}
|
||||
if (githubAuth) {
|
||||
logger.warning("Using `--github-auth` via the CLI is insecure. Use `--github-auth-stdin` instead.");
|
||||
return githubAuth;
|
||||
}
|
||||
if (fromStdIn) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let token = "";
|
||||
readable.on("data", (data) => {
|
||||
token += data.toString("utf8");
|
||||
});
|
||||
readable.on("end", () => {
|
||||
token = token.split(/\s+/)[0].trim();
|
||||
if (token) {
|
||||
resolve(token);
|
||||
}
|
||||
else {
|
||||
reject(new Error("Standard input is empty"));
|
||||
}
|
||||
});
|
||||
readable.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (process.env.GITHUB_TOKEN) {
|
||||
return process.env.GITHUB_TOKEN;
|
||||
}
|
||||
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;
|
||||
//# sourceMappingURL=util.js.map
|
||||
File diff suppressed because one or more lines are too long
48
lib/util.test.js
generated
48
lib/util.test.js
generated
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const stream = __importStar(require("stream"));
|
||||
const github = __importStar(require("@actions/github"));
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const sinon_1 = __importDefault(require("sinon"));
|
||||
@@ -27,9 +28,10 @@ ava_1.default("getToolNames", (t) => {
|
||||
});
|
||||
ava_1.default("getMemoryFlag() should return the correct --ram flag", (t) => {
|
||||
const totalMem = Math.floor(os.totalmem() / (1024 * 1024));
|
||||
const expectedThreshold = process.platform === "win32" ? 1536 : 1024;
|
||||
const tests = [
|
||||
[undefined, `--ram=${totalMem - 256}`],
|
||||
["", `--ram=${totalMem - 256}`],
|
||||
[undefined, `--ram=${totalMem - expectedThreshold}`],
|
||||
["", `--ram=${totalMem - expectedThreshold}`],
|
||||
["512", "--ram=512"],
|
||||
];
|
||||
for (const [input, expectedFlag] of tests) {
|
||||
@@ -152,18 +154,54 @@ ava_1.default("getGitHubVersion", async (t) => {
|
||||
auth: "",
|
||||
url: "https://github.com",
|
||||
});
|
||||
t.deepEqual("dotcom", v.type);
|
||||
t.deepEqual(util.GitHubVariant.DOTCOM, v.type);
|
||||
mockGetMetaVersionHeader("2.0");
|
||||
const v2 = await util.getGitHubVersion({
|
||||
auth: "",
|
||||
url: "https://ghe.example.com",
|
||||
});
|
||||
t.deepEqual({ type: "ghes", version: "2.0" }, v2);
|
||||
t.deepEqual({ type: util.GitHubVariant.GHES, version: "2.0" }, v2);
|
||||
mockGetMetaVersionHeader("GitHub AE");
|
||||
const ghae = await util.getGitHubVersion({
|
||||
auth: "",
|
||||
url: "https://example.githubenterprise.com",
|
||||
});
|
||||
t.deepEqual({ type: util.GitHubVariant.GHAE }, ghae);
|
||||
mockGetMetaVersionHeader(undefined);
|
||||
const v3 = await util.getGitHubVersion({
|
||||
auth: "",
|
||||
url: "https://ghe.example.com",
|
||||
});
|
||||
t.deepEqual({ type: "dotcom" }, v3);
|
||||
t.deepEqual({ type: util.GitHubVariant.DOTCOM }, v3);
|
||||
});
|
||||
ava_1.default("getGitHubAuth", async (t) => {
|
||||
const msgs = [];
|
||||
const mockLogger = {
|
||||
warning: (msg) => msgs.push(msg),
|
||||
};
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
t.throwsAsync(async () => util.getGitHubAuth(mockLogger, "abc", true));
|
||||
process.env.GITHUB_TOKEN = "123";
|
||||
t.is("123", await util.getGitHubAuth(mockLogger, undefined, undefined));
|
||||
t.is(msgs.length, 0);
|
||||
t.is("abc", await util.getGitHubAuth(mockLogger, "abc", undefined));
|
||||
t.is(msgs.length, 1); // warning expected
|
||||
msgs.length = 0;
|
||||
await mockStdInForAuth(t, mockLogger, "def", "def");
|
||||
await mockStdInForAuth(t, mockLogger, "def", "", "def");
|
||||
await mockStdInForAuth(t, mockLogger, "def", "def\n some extra garbage", "ghi");
|
||||
await mockStdInForAuth(t, mockLogger, "defghi", "def", "ghi\n123");
|
||||
await mockStdInForAuthExpectError(t, mockLogger, "");
|
||||
await mockStdInForAuthExpectError(t, mockLogger, "", " ", "abc");
|
||||
await mockStdInForAuthExpectError(t, mockLogger, " def\n some extra garbage", "ghi");
|
||||
t.is(msgs.length, 0);
|
||||
});
|
||||
async function mockStdInForAuth(t, mockLogger, expected, ...text) {
|
||||
const stdin = stream.Readable.from(text);
|
||||
t.is(expected, await util.getGitHubAuth(mockLogger, undefined, true, stdin));
|
||||
}
|
||||
async function mockStdInForAuthExpectError(t, mockLogger, ...text) {
|
||||
const stdin = stream.Readable.from(text);
|
||||
await t.throwsAsync(async () => util.getGitHubAuth(mockLogger, undefined, true, stdin));
|
||||
}
|
||||
//# sourceMappingURL=util.test.js.map
|
||||
File diff suppressed because one or more lines are too long
94
node_modules/decode-uri-component/index.js
generated
vendored
Normal file
94
node_modules/decode-uri-component/index.js
generated
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
'use strict';
|
||||
var token = '%[a-f0-9]{2}';
|
||||
var singleMatcher = new RegExp(token, 'gi');
|
||||
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
|
||||
|
||||
function decodeComponents(components, split) {
|
||||
try {
|
||||
// Try to decode the entire string first
|
||||
return decodeURIComponent(components.join(''));
|
||||
} catch (err) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
if (components.length === 1) {
|
||||
return components;
|
||||
}
|
||||
|
||||
split = split || 1;
|
||||
|
||||
// Split the array in 2 parts
|
||||
var left = components.slice(0, split);
|
||||
var right = components.slice(split);
|
||||
|
||||
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
||||
}
|
||||
|
||||
function decode(input) {
|
||||
try {
|
||||
return decodeURIComponent(input);
|
||||
} catch (err) {
|
||||
var tokens = input.match(singleMatcher);
|
||||
|
||||
for (var i = 1; i < tokens.length; i++) {
|
||||
input = decodeComponents(tokens, i).join('');
|
||||
|
||||
tokens = input.match(singleMatcher);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
function customDecodeURIComponent(input) {
|
||||
// Keep track of all the replacements and prefill the map with the `BOM`
|
||||
var replaceMap = {
|
||||
'%FE%FF': '\uFFFD\uFFFD',
|
||||
'%FF%FE': '\uFFFD\uFFFD'
|
||||
};
|
||||
|
||||
var match = multiMatcher.exec(input);
|
||||
while (match) {
|
||||
try {
|
||||
// Decode as big chunks as possible
|
||||
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
||||
} catch (err) {
|
||||
var result = decode(match[0]);
|
||||
|
||||
if (result !== match[0]) {
|
||||
replaceMap[match[0]] = result;
|
||||
}
|
||||
}
|
||||
|
||||
match = multiMatcher.exec(input);
|
||||
}
|
||||
|
||||
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
|
||||
replaceMap['%C2'] = '\uFFFD';
|
||||
|
||||
var entries = Object.keys(replaceMap);
|
||||
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
// Replace all decoded components
|
||||
var key = entries[i];
|
||||
input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
module.exports = function (encodedURI) {
|
||||
if (typeof encodedURI !== 'string') {
|
||||
throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
|
||||
}
|
||||
|
||||
try {
|
||||
encodedURI = encodedURI.replace(/\+/g, ' ');
|
||||
|
||||
// Try the built in decoder first
|
||||
return decodeURIComponent(encodedURI);
|
||||
} catch (err) {
|
||||
// Fallback to a more advanced decoder
|
||||
return customDecodeURIComponent(encodedURI);
|
||||
}
|
||||
};
|
||||
21
node_modules/decode-uri-component/license
generated
vendored
Normal file
21
node_modules/decode-uri-component/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sam Verschueren <sam.verschueren@gmail.com> (github.com/SamVerschueren)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
37
node_modules/decode-uri-component/package.json
generated
vendored
Normal file
37
node_modules/decode-uri-component/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "decode-uri-component",
|
||||
"version": "0.2.0",
|
||||
"description": "A better decodeURIComponent",
|
||||
"license": "MIT",
|
||||
"repository": "SamVerschueren/decode-uri-component",
|
||||
"author": {
|
||||
"name": "Sam Verschueren",
|
||||
"email": "sam.verschueren@gmail.com",
|
||||
"url": "github.com/SamVerschueren"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava",
|
||||
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"decode",
|
||||
"uri",
|
||||
"component",
|
||||
"decodeuricomponent",
|
||||
"components",
|
||||
"decoder",
|
||||
"url"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^0.17.0",
|
||||
"coveralls": "^2.13.1",
|
||||
"nyc": "^10.3.2",
|
||||
"xo": "^0.16.0"
|
||||
}
|
||||
}
|
||||
70
node_modules/decode-uri-component/readme.md
generated
vendored
Normal file
70
node_modules/decode-uri-component/readme.md
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# decode-uri-component
|
||||
|
||||
[](https://travis-ci.org/SamVerschueren/decode-uri-component) [](https://coveralls.io/github/SamVerschueren/decode-uri-component?branch=master)
|
||||
|
||||
> A better [decodeURIComponent](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent)
|
||||
|
||||
|
||||
## Why?
|
||||
|
||||
- Decodes `+` to a space.
|
||||
- Converts the [BOM](https://en.wikipedia.org/wiki/Byte_order_mark) to a [replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character) `<60>`.
|
||||
- Does not throw with invalid encoded input.
|
||||
- Decodes as much of the string as possible.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save decode-uri-component
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const decodeUriComponent = require('decode-uri-component');
|
||||
|
||||
decodeUriComponent('%25');
|
||||
//=> '%'
|
||||
|
||||
decodeUriComponent('%');
|
||||
//=> '%'
|
||||
|
||||
decodeUriComponent('st%C3%A5le');
|
||||
//=> 'ståle'
|
||||
|
||||
decodeUriComponent('%st%C3%A5le%');
|
||||
//=> '%ståle%'
|
||||
|
||||
decodeUriComponent('%%7Bst%C3%A5le%7D%');
|
||||
//=> '%{ståle}%'
|
||||
|
||||
decodeUriComponent('%7B%ab%%7C%de%%7D');
|
||||
//=> '{%ab%|%de%}'
|
||||
|
||||
decodeUriComponent('%FE%FF');
|
||||
//=> '\uFFFD\uFFFD'
|
||||
|
||||
decodeUriComponent('%C2');
|
||||
//=> '\uFFFD'
|
||||
|
||||
decodeUriComponent('%C2%B5');
|
||||
//=> 'µ'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### decodeUriComponent(encodedURI)
|
||||
|
||||
#### encodedURI
|
||||
|
||||
Type: `string`
|
||||
|
||||
An encoded component of a Uniform Resource Identifier.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sam Verschueren](https://github.com/SamVerschueren)
|
||||
17
node_modules/filter-obj/index.js
generated
vendored
Normal file
17
node_modules/filter-obj/index.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
module.exports = function (obj, predicate) {
|
||||
var ret = {};
|
||||
var keys = Object.keys(obj);
|
||||
var isArr = Array.isArray(predicate);
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var val = obj[key];
|
||||
|
||||
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
|
||||
ret[key] = val;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
21
node_modules/filter-obj/license
generated
vendored
Normal file
21
node_modules/filter-obj/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
37
node_modules/filter-obj/package.json
generated
vendored
Normal file
37
node_modules/filter-obj/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "filter-obj",
|
||||
"version": "1.1.0",
|
||||
"description": "Filter object keys and values into a new object",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/filter-obj",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && node test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"filter",
|
||||
"obj",
|
||||
"object",
|
||||
"key",
|
||||
"keys",
|
||||
"value",
|
||||
"values",
|
||||
"val",
|
||||
"iterate",
|
||||
"iterator"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "0.0.4",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
41
node_modules/filter-obj/readme.md
generated
vendored
Normal file
41
node_modules/filter-obj/readme.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# filter-obj [](https://travis-ci.org/sindresorhus/filter-obj)
|
||||
|
||||
> Filter object keys and values into a new object
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save filter-obj
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var filterObj = require('filter-obj');
|
||||
|
||||
var obj = {
|
||||
foo: true,
|
||||
bar: false
|
||||
};
|
||||
|
||||
var newObject = filterObj(obj, function (key, value, object) {
|
||||
return value === true;
|
||||
});
|
||||
//=> {foo: true}
|
||||
|
||||
var newObject2 = filterObj(obj, ['bar']);
|
||||
//=> {bar: true}
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [map-obj](https://github.com/sindresorhus/map-obj) - Map object keys and values into a new object
|
||||
- [object-assign](https://github.com/sindresorhus/object-assign) - Copy enumerable own properties from one or more source objects to a target object
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
489
node_modules/query-string/index.d.ts
generated
vendored
Normal file
489
node_modules/query-string/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,489 @@
|
||||
export interface ParseOptions {
|
||||
/**
|
||||
Decode the keys and values. URI components are decoded with [`decode-uri-component`](https://github.com/SamVerschueren/decode-uri-component).
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly decode?: boolean;
|
||||
|
||||
/**
|
||||
@default 'none'
|
||||
|
||||
- `bracket`: Parse arrays with bracket representation:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `index`: Parse arrays with index representation:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `comma`: Parse arrays with elements separated by comma:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `separator`: Parse arrays with elements separated by a custom character:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1|2|3', {arrayFormat: 'separator', arrayFormatSeparator: '|'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `none`: Parse arrays with elements using duplicate keys:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1&foo=2&foo=3');
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
*/
|
||||
readonly arrayFormat?: 'bracket' | 'index' | 'comma' | 'separator' | 'none';
|
||||
|
||||
/**
|
||||
The character used to separate array elements when using `{arrayFormat: 'separator'}`.
|
||||
|
||||
@default ,
|
||||
*/
|
||||
readonly arrayFormatSeparator?: string;
|
||||
|
||||
/**
|
||||
Supports both `Function` as a custom sorting function or `false` to disable sorting.
|
||||
|
||||
If omitted, keys are sorted using `Array#sort`, which means, converting them to strings and comparing strings in Unicode code point order.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
const order = ['c', 'a', 'b'];
|
||||
|
||||
queryString.parse('?a=one&b=two&c=three', {
|
||||
sort: (itemLeft, itemRight) => order.indexOf(itemLeft) - order.indexOf(itemRight)
|
||||
});
|
||||
//=> {c: 'three', a: 'one', b: 'two'}
|
||||
```
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('?a=one&c=three&b=two', {sort: false});
|
||||
//=> {a: 'one', c: 'three', b: 'two'}
|
||||
```
|
||||
*/
|
||||
readonly sort?: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
|
||||
/**
|
||||
Parse the value as a number type instead of string type if it's a number.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1', {parseNumbers: true});
|
||||
//=> {foo: 1}
|
||||
```
|
||||
*/
|
||||
readonly parseNumbers?: boolean;
|
||||
|
||||
/**
|
||||
Parse the value as a boolean type instead of string type if it's a boolean.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=true', {parseBooleans: true});
|
||||
//=> {foo: true}
|
||||
```
|
||||
*/
|
||||
readonly parseBooleans?: boolean;
|
||||
|
||||
/**
|
||||
Parse the fragment identifier from the URL and add it to result object.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
|
||||
```
|
||||
*/
|
||||
readonly parseFragmentIdentifier?: boolean;
|
||||
}
|
||||
|
||||
export interface ParsedQuery<T = string> {
|
||||
[key: string]: T | T[] | null;
|
||||
}
|
||||
|
||||
/**
|
||||
Parse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` directly.
|
||||
|
||||
The returned object is created with [`Object.create(null)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create) and thus does not have a `prototype`.
|
||||
|
||||
@param query - The query string to parse.
|
||||
*/
|
||||
export function parse(query: string, options: {parseBooleans: true, parseNumbers: true} & ParseOptions): ParsedQuery<string | boolean | number>;
|
||||
export function parse(query: string, options: {parseBooleans: true} & ParseOptions): ParsedQuery<string | boolean>;
|
||||
export function parse(query: string, options: {parseNumbers: true} & ParseOptions): ParsedQuery<string | number>;
|
||||
export function parse(query: string, options?: ParseOptions): ParsedQuery;
|
||||
|
||||
export interface ParsedUrl {
|
||||
readonly url: string;
|
||||
readonly query: ParsedQuery;
|
||||
|
||||
/**
|
||||
The fragment identifier of the URL.
|
||||
|
||||
Present when the `parseFragmentIdentifier` option is `true`.
|
||||
*/
|
||||
readonly fragmentIdentifier?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
Extract the URL and the query string as an object.
|
||||
|
||||
If the `parseFragmentIdentifier` option is `true`, the object will also contain a `fragmentIdentifier` property.
|
||||
|
||||
@param url - The URL to parse.
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar');
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}}
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
|
||||
```
|
||||
*/
|
||||
export function parseUrl(url: string, options?: ParseOptions): ParsedUrl;
|
||||
|
||||
export interface StringifyOptions {
|
||||
/**
|
||||
Strictly encode URI components with [`strict-uri-encode`](https://github.com/kevva/strict-uri-encode). It uses [`encodeURIComponent`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to `false`. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly strict?: boolean;
|
||||
|
||||
/**
|
||||
[URL encode](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) the keys and values.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly encode?: boolean;
|
||||
|
||||
/**
|
||||
@default 'none'
|
||||
|
||||
- `bracket`: Serialize arrays using bracket representation:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket'});
|
||||
//=> 'foo[]=1&foo[]=2&foo[]=3'
|
||||
```
|
||||
|
||||
- `index`: Serialize arrays using index representation:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
|
||||
//=> 'foo[0]=1&foo[1]=2&foo[2]=3'
|
||||
```
|
||||
|
||||
- `comma`: Serialize arrays by separating elements with comma:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'comma'});
|
||||
//=> 'foo=1,2,3'
|
||||
```
|
||||
|
||||
- `separator`: Serialize arrays by separating elements with character:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'separator', arrayFormatSeparator: '|'});
|
||||
//=> 'foo=1|2|3'
|
||||
```
|
||||
|
||||
- `none`: Serialize arrays by using duplicate keys:
|
||||
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]});
|
||||
//=> 'foo=1&foo=2&foo=3'
|
||||
```
|
||||
*/
|
||||
readonly arrayFormat?: 'bracket' | 'index' | 'comma' | 'separator' | 'none';
|
||||
|
||||
/**
|
||||
The character used to separate array elements when using `{arrayFormat: 'separator'}`.
|
||||
|
||||
@default ,
|
||||
*/
|
||||
readonly arrayFormatSeparator?: string;
|
||||
|
||||
/**
|
||||
Supports both `Function` as a custom sorting function or `false` to disable sorting.
|
||||
|
||||
If omitted, keys are sorted using `Array#sort`, which means, converting them to strings and comparing strings in Unicode code point order.
|
||||
|
||||
@default true
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
const order = ['c', 'a', 'b'];
|
||||
|
||||
queryString.stringify({a: 1, b: 2, c: 3}, {
|
||||
sort: (itemLeft, itemRight) => order.indexOf(itemLeft) - order.indexOf(itemRight)
|
||||
});
|
||||
//=> 'c=3&a=1&b=2'
|
||||
```
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({b: 1, c: 2, a: 3}, {sort: false});
|
||||
//=> 'b=1&c=2&a=3'
|
||||
```
|
||||
*/
|
||||
readonly sort?: ((itemLeft: string, itemRight: string) => number) | false;
|
||||
|
||||
/**
|
||||
Skip keys with `null` as the value.
|
||||
|
||||
Note that keys with `undefined` as the value are always skipped.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: 1, b: undefined, c: null, d: 4}, {
|
||||
skipNull: true
|
||||
});
|
||||
//=> 'a=1&d=4'
|
||||
|
||||
queryString.stringify({a: undefined, b: null}, {
|
||||
skipNull: true
|
||||
});
|
||||
//=> ''
|
||||
```
|
||||
*/
|
||||
readonly skipNull?: boolean;
|
||||
|
||||
/**
|
||||
Skip keys with an empty string as the value.
|
||||
|
||||
@default false
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: 1, b: '', c: '', d: 4}, {
|
||||
skipEmptyString: true
|
||||
});
|
||||
//=> 'a=1&d=4'
|
||||
```
|
||||
|
||||
@example
|
||||
```
|
||||
import queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: '', b: ''}, {
|
||||
skipEmptyString: true
|
||||
});
|
||||
//=> ''
|
||||
```
|
||||
*/
|
||||
readonly skipEmptyString?: boolean;
|
||||
}
|
||||
|
||||
export type Stringifiable = string | boolean | number | null | undefined;
|
||||
|
||||
export type StringifiableRecord = Record<
|
||||
string,
|
||||
Stringifiable | readonly Stringifiable[]
|
||||
>;
|
||||
|
||||
/**
|
||||
Stringify an object into a query string and sort the keys.
|
||||
*/
|
||||
export function stringify(
|
||||
// TODO: Use the below instead when the following TS issues are fixed:
|
||||
// - https://github.com/microsoft/TypeScript/issues/15300
|
||||
// - https://github.com/microsoft/TypeScript/issues/42021
|
||||
// Context: https://github.com/sindresorhus/query-string/issues/298
|
||||
// object: StringifiableRecord,
|
||||
object: Record<string, any>,
|
||||
options?: StringifyOptions
|
||||
): string;
|
||||
|
||||
/**
|
||||
Extract a query string from a URL that can be passed into `.parse()`.
|
||||
|
||||
Note: This behaviour can be changed with the `skipNull` option.
|
||||
*/
|
||||
export function extract(url: string): string;
|
||||
|
||||
export interface UrlObject {
|
||||
readonly url: string;
|
||||
|
||||
/**
|
||||
Overrides queries in the `url` property.
|
||||
*/
|
||||
readonly query: StringifiableRecord;
|
||||
|
||||
/**
|
||||
Overrides the fragment identifier in the `url` property.
|
||||
*/
|
||||
readonly fragmentIdentifier?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
Stringify an object into a URL with a query string and sorting the keys. The inverse of [`.parseUrl()`](https://github.com/sindresorhus/query-string#parseurlstring-options)
|
||||
|
||||
Query items in the `query` property overrides queries in the `url` property.
|
||||
|
||||
The `fragmentIdentifier` property overrides the fragment identifier in the `url` property.
|
||||
|
||||
@example
|
||||
```
|
||||
queryString.stringifyUrl({url: 'https://foo.bar', query: {foo: 'bar'}});
|
||||
//=> 'https://foo.bar?foo=bar'
|
||||
|
||||
queryString.stringifyUrl({url: 'https://foo.bar?foo=baz', query: {foo: 'bar'}});
|
||||
//=> 'https://foo.bar?foo=bar'
|
||||
|
||||
queryString.stringifyUrl({
|
||||
url: 'https://foo.bar',
|
||||
query: {
|
||||
top: 'foo'
|
||||
},
|
||||
fragmentIdentifier: 'bar'
|
||||
});
|
||||
//=> 'https://foo.bar?top=foo#bar'
|
||||
```
|
||||
*/
|
||||
export function stringifyUrl(
|
||||
object: UrlObject,
|
||||
options?: StringifyOptions
|
||||
): string;
|
||||
|
||||
/**
|
||||
Pick query parameters from a URL.
|
||||
|
||||
@param url - The URL containing the query parameters to pick.
|
||||
@param keys - The names of the query parameters to keep. All other query parameters will be removed from the URL.
|
||||
@param filter - A filter predicate that will be provided the name of each query parameter and its value. The `parseNumbers` and `parseBooleans` options also affect `value`.
|
||||
|
||||
@returns The URL with the picked query parameters.
|
||||
|
||||
@example
|
||||
```
|
||||
queryString.pick('https://foo.bar?foo=1&bar=2#hello', ['foo']);
|
||||
//=> 'https://foo.bar?foo=1#hello'
|
||||
|
||||
queryString.pick('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
|
||||
//=> 'https://foo.bar?bar=2#hello'
|
||||
```
|
||||
*/
|
||||
export function pick(
|
||||
url: string,
|
||||
keys: readonly string[],
|
||||
options?: ParseOptions & StringifyOptions
|
||||
): string
|
||||
export function pick(
|
||||
url: string,
|
||||
filter: (key: string, value: string | boolean | number) => boolean,
|
||||
options?: {parseBooleans: true, parseNumbers: true} & ParseOptions & StringifyOptions
|
||||
): string
|
||||
export function pick(
|
||||
url: string,
|
||||
filter: (key: string, value: string | boolean) => boolean,
|
||||
options?: {parseBooleans: true} & ParseOptions & StringifyOptions
|
||||
): string
|
||||
export function pick(
|
||||
url: string,
|
||||
filter: (key: string, value: string | number) => boolean,
|
||||
options?: {parseNumbers: true} & ParseOptions & StringifyOptions
|
||||
): string
|
||||
|
||||
/**
|
||||
Exclude query parameters from a URL. Like `.pick()` but reversed.
|
||||
|
||||
@param url - The URL containing the query parameters to exclude.
|
||||
@param keys - The names of the query parameters to remove. All other query parameters will remain in the URL.
|
||||
@param filter - A filter predicate that will be provided the name of each query parameter and its value. The `parseNumbers` and `parseBooleans` options also affect `value`.
|
||||
|
||||
@returns The URL without the excluded the query parameters.
|
||||
|
||||
@example
|
||||
```
|
||||
queryString.exclude('https://foo.bar?foo=1&bar=2#hello', ['foo']);
|
||||
//=> 'https://foo.bar?bar=2#hello'
|
||||
|
||||
queryString.exclude('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
|
||||
//=> 'https://foo.bar?foo=1#hello'
|
||||
```
|
||||
*/
|
||||
export function exclude(
|
||||
url: string,
|
||||
keys: readonly string[],
|
||||
options?: ParseOptions & StringifyOptions
|
||||
): string
|
||||
export function exclude(
|
||||
url: string,
|
||||
filter: (key: string, value: string | boolean | number) => boolean,
|
||||
options?: {parseBooleans: true, parseNumbers: true} & ParseOptions & StringifyOptions
|
||||
): string
|
||||
export function exclude(
|
||||
url: string,
|
||||
filter: (key: string, value: string | boolean) => boolean,
|
||||
options?: {parseBooleans: true} & ParseOptions & StringifyOptions
|
||||
): string
|
||||
export function exclude(
|
||||
url: string,
|
||||
filter: (key: string, value: string | number) => boolean,
|
||||
options?: {parseNumbers: true} & ParseOptions & StringifyOptions
|
||||
): string
|
||||
404
node_modules/query-string/index.js
generated
vendored
Normal file
404
node_modules/query-string/index.js
generated
vendored
Normal file
@@ -0,0 +1,404 @@
|
||||
'use strict';
|
||||
const strictUriEncode = require('strict-uri-encode');
|
||||
const decodeComponent = require('decode-uri-component');
|
||||
const splitOnFirst = require('split-on-first');
|
||||
const filterObject = require('filter-obj');
|
||||
|
||||
const isNullOrUndefined = value => value === null || value === undefined;
|
||||
|
||||
function encoderForArrayFormat(options) {
|
||||
switch (options.arrayFormat) {
|
||||
case 'index':
|
||||
return key => (result, value) => {
|
||||
const index = result.length;
|
||||
|
||||
if (
|
||||
value === undefined ||
|
||||
(options.skipNull && value === null) ||
|
||||
(options.skipEmptyString && value === '')
|
||||
) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (value === null) {
|
||||
return [...result, [encode(key, options), '[', index, ']'].join('')];
|
||||
}
|
||||
|
||||
return [
|
||||
...result,
|
||||
[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join('')
|
||||
];
|
||||
};
|
||||
|
||||
case 'bracket':
|
||||
return key => (result, value) => {
|
||||
if (
|
||||
value === undefined ||
|
||||
(options.skipNull && value === null) ||
|
||||
(options.skipEmptyString && value === '')
|
||||
) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (value === null) {
|
||||
return [...result, [encode(key, options), '[]'].join('')];
|
||||
}
|
||||
|
||||
return [...result, [encode(key, options), '[]=', encode(value, options)].join('')];
|
||||
};
|
||||
|
||||
case 'comma':
|
||||
case 'separator':
|
||||
return key => (result, value) => {
|
||||
if (value === null || value === undefined || value.length === 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (result.length === 0) {
|
||||
return [[encode(key, options), '=', encode(value, options)].join('')];
|
||||
}
|
||||
|
||||
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
||||
};
|
||||
|
||||
default:
|
||||
return key => (result, value) => {
|
||||
if (
|
||||
value === undefined ||
|
||||
(options.skipNull && value === null) ||
|
||||
(options.skipEmptyString && value === '')
|
||||
) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (value === null) {
|
||||
return [...result, encode(key, options)];
|
||||
}
|
||||
|
||||
return [...result, [encode(key, options), '=', encode(value, options)].join('')];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function parserForArrayFormat(options) {
|
||||
let result;
|
||||
|
||||
switch (options.arrayFormat) {
|
||||
case 'index':
|
||||
return (key, value, accumulator) => {
|
||||
result = /\[(\d*)\]$/.exec(key);
|
||||
|
||||
key = key.replace(/\[\d*\]$/, '');
|
||||
|
||||
if (!result) {
|
||||
accumulator[key] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (accumulator[key] === undefined) {
|
||||
accumulator[key] = {};
|
||||
}
|
||||
|
||||
accumulator[key][result[1]] = value;
|
||||
};
|
||||
|
||||
case 'bracket':
|
||||
return (key, value, accumulator) => {
|
||||
result = /(\[\])$/.exec(key);
|
||||
key = key.replace(/\[\]$/, '');
|
||||
|
||||
if (!result) {
|
||||
accumulator[key] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (accumulator[key] === undefined) {
|
||||
accumulator[key] = [value];
|
||||
return;
|
||||
}
|
||||
|
||||
accumulator[key] = [].concat(accumulator[key], value);
|
||||
};
|
||||
|
||||
case 'comma':
|
||||
case 'separator':
|
||||
return (key, value, accumulator) => {
|
||||
const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);
|
||||
const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));
|
||||
value = isEncodedArray ? decode(value, options) : value;
|
||||
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options);
|
||||
accumulator[key] = newValue;
|
||||
};
|
||||
|
||||
default:
|
||||
return (key, value, accumulator) => {
|
||||
if (accumulator[key] === undefined) {
|
||||
accumulator[key] = value;
|
||||
return;
|
||||
}
|
||||
|
||||
accumulator[key] = [].concat(accumulator[key], value);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function validateArrayFormatSeparator(value) {
|
||||
if (typeof value !== 'string' || value.length !== 1) {
|
||||
throw new TypeError('arrayFormatSeparator must be single character string');
|
||||
}
|
||||
}
|
||||
|
||||
function encode(value, options) {
|
||||
if (options.encode) {
|
||||
return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function decode(value, options) {
|
||||
if (options.decode) {
|
||||
return decodeComponent(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function keysSorter(input) {
|
||||
if (Array.isArray(input)) {
|
||||
return input.sort();
|
||||
}
|
||||
|
||||
if (typeof input === 'object') {
|
||||
return keysSorter(Object.keys(input))
|
||||
.sort((a, b) => Number(a) - Number(b))
|
||||
.map(key => input[key]);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
function removeHash(input) {
|
||||
const hashStart = input.indexOf('#');
|
||||
if (hashStart !== -1) {
|
||||
input = input.slice(0, hashStart);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
function getHash(url) {
|
||||
let hash = '';
|
||||
const hashStart = url.indexOf('#');
|
||||
if (hashStart !== -1) {
|
||||
hash = url.slice(hashStart);
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
function extract(input) {
|
||||
input = removeHash(input);
|
||||
const queryStart = input.indexOf('?');
|
||||
if (queryStart === -1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return input.slice(queryStart + 1);
|
||||
}
|
||||
|
||||
function parseValue(value, options) {
|
||||
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
|
||||
value = Number(value);
|
||||
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
|
||||
value = value.toLowerCase() === 'true';
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function parse(query, options) {
|
||||
options = Object.assign({
|
||||
decode: true,
|
||||
sort: true,
|
||||
arrayFormat: 'none',
|
||||
arrayFormatSeparator: ',',
|
||||
parseNumbers: false,
|
||||
parseBooleans: false
|
||||
}, options);
|
||||
|
||||
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
||||
|
||||
const formatter = parserForArrayFormat(options);
|
||||
|
||||
// Create an object with no prototype
|
||||
const ret = Object.create(null);
|
||||
|
||||
if (typeof query !== 'string') {
|
||||
return ret;
|
||||
}
|
||||
|
||||
query = query.trim().replace(/^[?#&]/, '');
|
||||
|
||||
if (!query) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (const param of query.split('&')) {
|
||||
if (param === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '=');
|
||||
|
||||
// Missing `=` should be `null`:
|
||||
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
||||
value = value === undefined ? null : ['comma', 'separator'].includes(options.arrayFormat) ? value : decode(value, options);
|
||||
formatter(decode(key, options), value, ret);
|
||||
}
|
||||
|
||||
for (const key of Object.keys(ret)) {
|
||||
const value = ret[key];
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
for (const k of Object.keys(value)) {
|
||||
value[k] = parseValue(value[k], options);
|
||||
}
|
||||
} else {
|
||||
ret[key] = parseValue(value, options);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.sort === false) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
|
||||
const value = ret[key];
|
||||
if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {
|
||||
// Sort object keys, not values
|
||||
result[key] = keysSorter(value);
|
||||
} else {
|
||||
result[key] = value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}, Object.create(null));
|
||||
}
|
||||
|
||||
exports.extract = extract;
|
||||
exports.parse = parse;
|
||||
|
||||
exports.stringify = (object, options) => {
|
||||
if (!object) {
|
||||
return '';
|
||||
}
|
||||
|
||||
options = Object.assign({
|
||||
encode: true,
|
||||
strict: true,
|
||||
arrayFormat: 'none',
|
||||
arrayFormatSeparator: ','
|
||||
}, options);
|
||||
|
||||
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
||||
|
||||
const shouldFilter = key => (
|
||||
(options.skipNull && isNullOrUndefined(object[key])) ||
|
||||
(options.skipEmptyString && object[key] === '')
|
||||
);
|
||||
|
||||
const formatter = encoderForArrayFormat(options);
|
||||
|
||||
const objectCopy = {};
|
||||
|
||||
for (const key of Object.keys(object)) {
|
||||
if (!shouldFilter(key)) {
|
||||
objectCopy[key] = object[key];
|
||||
}
|
||||
}
|
||||
|
||||
const keys = Object.keys(objectCopy);
|
||||
|
||||
if (options.sort !== false) {
|
||||
keys.sort(options.sort);
|
||||
}
|
||||
|
||||
return keys.map(key => {
|
||||
const value = object[key];
|
||||
|
||||
if (value === undefined) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (value === null) {
|
||||
return encode(key, options);
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value
|
||||
.reduce(formatter(key), [])
|
||||
.join('&');
|
||||
}
|
||||
|
||||
return encode(key, options) + '=' + encode(value, options);
|
||||
}).filter(x => x.length > 0).join('&');
|
||||
};
|
||||
|
||||
exports.parseUrl = (url, options) => {
|
||||
options = Object.assign({
|
||||
decode: true
|
||||
}, options);
|
||||
|
||||
const [url_, hash] = splitOnFirst(url, '#');
|
||||
|
||||
return Object.assign(
|
||||
{
|
||||
url: url_.split('?')[0] || '',
|
||||
query: parse(extract(url), options)
|
||||
},
|
||||
options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}
|
||||
);
|
||||
};
|
||||
|
||||
exports.stringifyUrl = (object, options) => {
|
||||
options = Object.assign({
|
||||
encode: true,
|
||||
strict: true
|
||||
}, options);
|
||||
|
||||
const url = removeHash(object.url).split('?')[0] || '';
|
||||
const queryFromUrl = exports.extract(object.url);
|
||||
const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false});
|
||||
|
||||
const query = Object.assign(parsedQueryFromUrl, object.query);
|
||||
let queryString = exports.stringify(query, options);
|
||||
if (queryString) {
|
||||
queryString = `?${queryString}`;
|
||||
}
|
||||
|
||||
let hash = getHash(object.url);
|
||||
if (object.fragmentIdentifier) {
|
||||
hash = `#${encode(object.fragmentIdentifier, options)}`;
|
||||
}
|
||||
|
||||
return `${url}${queryString}${hash}`;
|
||||
};
|
||||
|
||||
exports.pick = (input, filter, options) => {
|
||||
options = Object.assign({
|
||||
parseFragmentIdentifier: true
|
||||
}, options);
|
||||
|
||||
const {url, query, fragmentIdentifier} = exports.parseUrl(input, options);
|
||||
return exports.stringifyUrl({
|
||||
url,
|
||||
query: filterObject(query, filter),
|
||||
fragmentIdentifier
|
||||
}, options);
|
||||
};
|
||||
|
||||
exports.exclude = (input, filter, options) => {
|
||||
const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);
|
||||
|
||||
return exports.pick(input, exclusionFilter, options);
|
||||
};
|
||||
9
node_modules/query-string/license
generated
vendored
Normal file
9
node_modules/query-string/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (http://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
54
node_modules/query-string/package.json
generated
vendored
Normal file
54
node_modules/query-string/package.json
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "query-string",
|
||||
"version": "6.14.0",
|
||||
"description": "Parse and stringify URL query strings",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/query-string",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "node benchmark.js",
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"browser",
|
||||
"querystring",
|
||||
"query",
|
||||
"string",
|
||||
"qs",
|
||||
"param",
|
||||
"parameter",
|
||||
"url",
|
||||
"parse",
|
||||
"stringify",
|
||||
"encode",
|
||||
"decode",
|
||||
"searchparams",
|
||||
"filter"
|
||||
],
|
||||
"dependencies": {
|
||||
"decode-uri-component": "^0.2.0",
|
||||
"filter-obj": "^1.1.0",
|
||||
"split-on-first": "^1.0.0",
|
||||
"strict-uri-encode": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"benchmark": "^2.1.4",
|
||||
"deep-equal": "^1.0.1",
|
||||
"fast-check": "^1.5.0",
|
||||
"tsd": "^0.7.3",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
527
node_modules/query-string/readme.md
generated
vendored
Normal file
527
node_modules/query-string/readme.md
generated
vendored
Normal file
@@ -0,0 +1,527 @@
|
||||
# query-string
|
||||
|
||||
> Parse and stringify URL [query strings](https://en.wikipedia.org/wiki/Query_string)
|
||||
|
||||
<br>
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<p>
|
||||
<p>
|
||||
<sup>
|
||||
<a href="https://github.com/sponsors/sindresorhus">My open source work is supported by the community</a>
|
||||
</sup>
|
||||
</p>
|
||||
<sup>Special thanks to:</sup>
|
||||
<br>
|
||||
<br>
|
||||
<a href="https://standardresume.co/tech">
|
||||
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="200"/>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<br>
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install query-string
|
||||
```
|
||||
|
||||
This module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, or, if your project is using create-react-app v1, use version 5: `npm install query-string@5`.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
console.log(location.search);
|
||||
//=> '?foo=bar'
|
||||
|
||||
const parsed = queryString.parse(location.search);
|
||||
console.log(parsed);
|
||||
//=> {foo: 'bar'}
|
||||
|
||||
console.log(location.hash);
|
||||
//=> '#token=bada55cafe'
|
||||
|
||||
const parsedHash = queryString.parse(location.hash);
|
||||
console.log(parsedHash);
|
||||
//=> {token: 'bada55cafe'}
|
||||
|
||||
parsed.foo = 'unicorn';
|
||||
parsed.ilike = 'pizza';
|
||||
|
||||
const stringified = queryString.stringify(parsed);
|
||||
//=> 'foo=unicorn&ilike=pizza'
|
||||
|
||||
location.search = stringified;
|
||||
// note that `location.search` automatically prepends a question mark
|
||||
console.log(location.search);
|
||||
//=> '?foo=unicorn&ilike=pizza'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### .parse(string, options?)
|
||||
|
||||
Parse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` directly.
|
||||
|
||||
The returned object is created with [`Object.create(null)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create) and thus does not have a `prototype`.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### decode
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Decode the keys and values. URL components are decoded with [`decode-uri-component`](https://github.com/SamVerschueren/decode-uri-component).
|
||||
|
||||
##### arrayFormat
|
||||
|
||||
Type: `string`\
|
||||
Default: `'none'`
|
||||
|
||||
- `'bracket'`: Parse arrays with bracket representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'index'`: Parse arrays with index representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'comma'`: Parse arrays with elements separated by comma:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1,2,3', {arrayFormat: 'comma'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'separator'`: Parse arrays with elements separated by a custom character:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1|2|3', {arrayFormat: 'separator', arrayFormatSeparator: '|'});
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
- `'none'`: Parse arrays with elements using duplicate keys:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1&foo=2&foo=3');
|
||||
//=> {foo: ['1', '2', '3']}
|
||||
```
|
||||
|
||||
##### arrayFormatSeparator
|
||||
|
||||
Type: `string`\
|
||||
Default: `','`
|
||||
|
||||
The character used to separate array elements when using `{arrayFormat: 'separator'}`.
|
||||
|
||||
##### sort
|
||||
|
||||
Type: `Function | boolean`\
|
||||
Default: `true`
|
||||
|
||||
Supports both `Function` as a custom sorting function or `false` to disable sorting.
|
||||
|
||||
##### parseNumbers
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=1', {parseNumbers: true});
|
||||
//=> {foo: 1}
|
||||
```
|
||||
|
||||
Parse the value as a number type instead of string type if it's a number.
|
||||
|
||||
##### parseBooleans
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('foo=true', {parseBooleans: true});
|
||||
//=> {foo: true}
|
||||
```
|
||||
|
||||
Parse the value as a boolean type instead of string type if it's a boolean.
|
||||
|
||||
### .stringify(object, options?)
|
||||
|
||||
Stringify an object into a query string and sorting the keys.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### strict
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Strictly encode URI components with [strict-uri-encode](https://github.com/kevva/strict-uri-encode). It uses [encodeURIComponent](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to false. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.
|
||||
|
||||
##### encode
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
[URL encode](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) the keys and values.
|
||||
|
||||
##### arrayFormat
|
||||
|
||||
Type: `string`\
|
||||
Default: `'none'`
|
||||
|
||||
- `'bracket'`: Serialize arrays using bracket representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket'});
|
||||
//=> 'foo[]=1&foo[]=2&foo[]=3'
|
||||
```
|
||||
|
||||
- `'index'`: Serialize arrays using index representation:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});
|
||||
//=> 'foo[0]=1&foo[1]=2&foo[2]=3'
|
||||
```
|
||||
|
||||
- `'comma'`: Serialize arrays by separating elements with comma:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'comma'});
|
||||
//=> 'foo=1,2,3'
|
||||
```
|
||||
|
||||
- `'none'`: Serialize arrays by using duplicate keys:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: [1, 2, 3]});
|
||||
//=> 'foo=1&foo=2&foo=3'
|
||||
```
|
||||
|
||||
##### arrayFormatSeparator
|
||||
|
||||
Type: `string`\
|
||||
Default: `','`
|
||||
|
||||
The character used to separate array elements when using `{arrayFormat: 'separator'}`.
|
||||
|
||||
##### sort
|
||||
|
||||
Type: `Function | boolean`
|
||||
|
||||
Supports both `Function` as a custom sorting function or `false` to disable sorting.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
const order = ['c', 'a', 'b'];
|
||||
|
||||
queryString.stringify({a: 1, b: 2, c: 3}, {
|
||||
sort: (a, b) => order.indexOf(a) - order.indexOf(b)
|
||||
});
|
||||
//=> 'c=3&a=1&b=2'
|
||||
```
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({b: 1, c: 2, a: 3}, {sort: false});
|
||||
//=> 'b=1&c=2&a=3'
|
||||
```
|
||||
|
||||
If omitted, keys are sorted using `Array#sort()`, which means, converting them to strings and comparing strings in Unicode code point order.
|
||||
|
||||
##### skipNull
|
||||
|
||||
Skip keys with `null` as the value.
|
||||
|
||||
Note that keys with `undefined` as the value are always skipped.
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: 1, b: undefined, c: null, d: 4}, {
|
||||
skipNull: true
|
||||
});
|
||||
//=> 'a=1&d=4'
|
||||
```
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: undefined, b: null}, {
|
||||
skipNull: true
|
||||
});
|
||||
//=> ''
|
||||
```
|
||||
|
||||
##### skipEmptyString
|
||||
|
||||
Skip keys with an empty string as the value.
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: 1, b: '', c: '', d: 4}, {
|
||||
skipEmptyString: true
|
||||
});
|
||||
//=> 'a=1&d=4'
|
||||
```
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({a: '', b: ''}, {
|
||||
skipEmptyString: true
|
||||
});
|
||||
//=> ''
|
||||
```
|
||||
|
||||
### .extract(string)
|
||||
|
||||
Extract a query string from a URL that can be passed into `.parse()`.
|
||||
|
||||
Note: This behaviour can be changed with the `skipNull` option.
|
||||
|
||||
### .parseUrl(string, options?)
|
||||
|
||||
Extract the URL and the query string as an object.
|
||||
|
||||
Returns an object with a `url` and `query` property.
|
||||
|
||||
If the `parseFragmentIdentifier` option is `true`, the object will also contain a `fragmentIdentifier` property.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar');
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}}
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
|
||||
```
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
The options are the same as for `.parse()`.
|
||||
|
||||
Extra options are as below.
|
||||
|
||||
##### parseFragmentIdentifier
|
||||
|
||||
Parse the fragment identifier from the URL.
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parseUrl('https://foo.bar?foo=bar#xyz', {parseFragmentIdentifier: true});
|
||||
//=> {url: 'https://foo.bar', query: {foo: 'bar'}, fragmentIdentifier: 'xyz'}
|
||||
```
|
||||
|
||||
### .stringifyUrl(object, options?)
|
||||
|
||||
Stringify an object into a URL with a query string and sorting the keys. The inverse of [`.parseUrl()`](https://github.com/sindresorhus/query-string#parseurlstring-options)
|
||||
|
||||
The `options` are the same as for `.stringify()`.
|
||||
|
||||
Returns a string with the URL and a query string.
|
||||
|
||||
Query items in the `query` property overrides queries in the `url` property.
|
||||
|
||||
The `fragmentIdentifier` property overrides the fragment identifier in the `url` property.
|
||||
|
||||
```js
|
||||
queryString.stringifyUrl({url: 'https://foo.bar', query: {foo: 'bar'}});
|
||||
//=> 'https://foo.bar?foo=bar'
|
||||
|
||||
queryString.stringifyUrl({url: 'https://foo.bar?foo=baz', query: {foo: 'bar'}});
|
||||
//=> 'https://foo.bar?foo=bar'
|
||||
|
||||
queryString.stringifyUrl({
|
||||
url: 'https://foo.bar',
|
||||
query: {
|
||||
top: 'foo'
|
||||
},
|
||||
fragmentIdentifier: 'bar'
|
||||
});
|
||||
//=> 'https://foo.bar?top=foo#bar'
|
||||
```
|
||||
|
||||
#### object
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### url
|
||||
|
||||
Type: `string`
|
||||
|
||||
The URL to stringify.
|
||||
|
||||
##### query
|
||||
|
||||
Type: `object`
|
||||
|
||||
Query items to add to the URL.
|
||||
|
||||
### .pick(url, keys, options?)
|
||||
### .pick(url, filter, options?)
|
||||
|
||||
Pick query parameters from a URL.
|
||||
|
||||
Returns a string with the new URL.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.pick('https://foo.bar?foo=1&bar=2#hello', ['foo']);
|
||||
//=> 'https://foo.bar?foo=1#hello'
|
||||
|
||||
queryString.pick('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
|
||||
//=> 'https://foo.bar?bar=2#hello'
|
||||
```
|
||||
|
||||
### .exclude(url, keys, options?)
|
||||
### .exclude(url, filter, options?)
|
||||
|
||||
Exclude query parameters from a URL.
|
||||
|
||||
Returns a string with the new URL.
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.exclude('https://foo.bar?foo=1&bar=2#hello', ['foo']);
|
||||
//=> 'https://foo.bar?bar=2#hello'
|
||||
|
||||
queryString.exclude('https://foo.bar?foo=1&bar=2#hello', (name, value) => value === 2, {parseNumbers: true});
|
||||
//=> 'https://foo.bar?foo=1#hello'
|
||||
```
|
||||
|
||||
#### url
|
||||
|
||||
Type: `string`
|
||||
|
||||
The URL containing the query parameters to filter.
|
||||
|
||||
#### keys
|
||||
|
||||
Type: `string[]`
|
||||
|
||||
The names of the query parameters to filter based on the function used.
|
||||
|
||||
#### filter
|
||||
|
||||
Type: `(key, value) => boolean`
|
||||
|
||||
A filter predicate that will be provided the name of each query parameter and its value. The `parseNumbers` and `parseBooleans` options also affect `value`.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
[Parse options](#options) and [stringify options](#options-1).
|
||||
|
||||
## Nesting
|
||||
|
||||
This module intentionally doesn't support nesting as it's not spec'd and varies between implementations, which causes a lot of [edge cases](https://github.com/visionmedia/node-querystring/issues).
|
||||
|
||||
You're much better off just converting the object to a JSON string:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({
|
||||
foo: 'bar',
|
||||
nested: JSON.stringify({
|
||||
unicorn: 'cake'
|
||||
})
|
||||
});
|
||||
//=> 'foo=bar&nested=%7B%22unicorn%22%3A%22cake%22%7D'
|
||||
```
|
||||
|
||||
However, there is support for multiple instances of the same key:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.parse('likes=cake&name=bob&likes=icecream');
|
||||
//=> {likes: ['cake', 'icecream'], name: 'bob'}
|
||||
|
||||
queryString.stringify({color: ['taupe', 'chartreuse'], id: '515'});
|
||||
//=> 'color=taupe&color=chartreuse&id=515'
|
||||
```
|
||||
|
||||
## Falsy values
|
||||
|
||||
Sometimes you want to unset a key, or maybe just make it present without assigning a value to it. Here is how falsy values are stringified:
|
||||
|
||||
```js
|
||||
const queryString = require('query-string');
|
||||
|
||||
queryString.stringify({foo: false});
|
||||
//=> 'foo=false'
|
||||
|
||||
queryString.stringify({foo: null});
|
||||
//=> 'foo'
|
||||
|
||||
queryString.stringify({foo: undefined});
|
||||
//=> ''
|
||||
```
|
||||
|
||||
## query-string for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of query-string and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-query-string?utm_source=npm-query-string&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
29
node_modules/split-on-first/index.d.ts
generated
vendored
Normal file
29
node_modules/split-on-first/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
Split a string on the first occurrence of a given separator.
|
||||
|
||||
@param string - The string to split.
|
||||
@param separator - The separator to split on.
|
||||
|
||||
@example
|
||||
```
|
||||
import splitOnFirst = require('split-on-first');
|
||||
|
||||
splitOnFirst('a-b-c', '-');
|
||||
//=> ['a', 'b-c']
|
||||
|
||||
splitOnFirst('key:value:value2', ':');
|
||||
//=> ['key', 'value:value2']
|
||||
|
||||
splitOnFirst('a---b---c', '---');
|
||||
//=> ['a', 'b---c']
|
||||
|
||||
splitOnFirst('a-b-c', '+');
|
||||
//=> ['a-b-c']
|
||||
```
|
||||
*/
|
||||
declare function splitOnFirst(
|
||||
string: string,
|
||||
separator: string
|
||||
): [string, string?];
|
||||
|
||||
export = splitOnFirst;
|
||||
22
node_modules/split-on-first/index.js
generated
vendored
Normal file
22
node_modules/split-on-first/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (string, separator) => {
|
||||
if (!(typeof string === 'string' && typeof separator === 'string')) {
|
||||
throw new TypeError('Expected the arguments to be of type `string`');
|
||||
}
|
||||
|
||||
if (separator === '') {
|
||||
return [string];
|
||||
}
|
||||
|
||||
const separatorIndex = string.indexOf(separator);
|
||||
|
||||
if (separatorIndex === -1) {
|
||||
return [string];
|
||||
}
|
||||
|
||||
return [
|
||||
string.slice(0, separatorIndex),
|
||||
string.slice(separatorIndex + separator.length)
|
||||
];
|
||||
};
|
||||
9
node_modules/split-on-first/license
generated
vendored
Normal file
9
node_modules/split-on-first/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
36
node_modules/split-on-first/package.json
generated
vendored
Normal file
36
node_modules/split-on-first/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "split-on-first",
|
||||
"version": "1.1.0",
|
||||
"description": "Split a string on the first occurance of a given separator",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/split-on-first",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"split",
|
||||
"string",
|
||||
"first",
|
||||
"occurrence",
|
||||
"separator",
|
||||
"delimiter",
|
||||
"text"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
58
node_modules/split-on-first/readme.md
generated
vendored
Normal file
58
node_modules/split-on-first/readme.md
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# split-on-first [](https://travis-ci.com/sindresorhus/split-on-first)
|
||||
|
||||
> Split a string on the first occurrence of a given separator
|
||||
|
||||
This is similar to [`String#split()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split), but that one splits on all the occurrences, not just the first one.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install split-on-first
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const splitOnFirst = require('split-on-first');
|
||||
|
||||
splitOnFirst('a-b-c', '-');
|
||||
//=> ['a', 'b-c']
|
||||
|
||||
splitOnFirst('key:value:value2', ':');
|
||||
//=> ['key', 'value:value2']
|
||||
|
||||
splitOnFirst('a---b---c', '---');
|
||||
//=> ['a', 'b---c']
|
||||
|
||||
splitOnFirst('a-b-c', '+');
|
||||
//=> ['a-b-c']
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### splitOnFirst(string, separator)
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`
|
||||
|
||||
The string to split.
|
||||
|
||||
#### separator
|
||||
|
||||
Type: `string`
|
||||
|
||||
The separator to split on.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [split-at](https://github.com/sindresorhus/split-at) - Split a string at one or more indices
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
2
node_modules/strict-uri-encode/index.js
generated
vendored
Normal file
2
node_modules/strict-uri-encode/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
module.exports = str => encodeURIComponent(str).replace(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
||||
21
node_modules/strict-uri-encode/license
generated
vendored
Normal file
21
node_modules/strict-uri-encode/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Martensson <kevinmartensson@gmail.com> (github.com/kevva)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
31
node_modules/strict-uri-encode/package.json
generated
vendored
Normal file
31
node_modules/strict-uri-encode/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "strict-uri-encode",
|
||||
"version": "2.0.0",
|
||||
"description": "A stricter URI encode adhering to RFC 3986",
|
||||
"license": "MIT",
|
||||
"repository": "kevva/strict-uri-encode",
|
||||
"author": {
|
||||
"name": "Kevin Mårtensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"component",
|
||||
"encode",
|
||||
"RFC3986",
|
||||
"uri"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
39
node_modules/strict-uri-encode/readme.md
generated
vendored
Normal file
39
node_modules/strict-uri-encode/readme.md
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# strict-uri-encode [](https://travis-ci.org/kevva/strict-uri-encode)
|
||||
|
||||
> A stricter URI encode adhering to [RFC 3986](http://tools.ietf.org/html/rfc3986)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save strict-uri-encode
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const strictUriEncode = require('strict-uri-encode');
|
||||
|
||||
strictUriEncode('unicorn!foobar');
|
||||
//=> 'unicorn%21foobar'
|
||||
|
||||
strictUriEncode('unicorn*foobar');
|
||||
//=> 'unicorn%2Afoobar'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### strictUriEncode(string)
|
||||
|
||||
#### string
|
||||
|
||||
Type: `string`, `number`
|
||||
|
||||
String to URI encode.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kevin Mårtensson](http://github.com/kevva)
|
||||
31
package-lock.json
generated
31
package-lock.json
generated
@@ -1348,6 +1348,11 @@
|
||||
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
|
||||
"dev": true
|
||||
},
|
||||
"decode-uri-component": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
|
||||
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
|
||||
},
|
||||
"decompress-response": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
|
||||
@@ -2152,6 +2157,11 @@
|
||||
"to-regex-range": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"filter-obj": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz",
|
||||
"integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs="
|
||||
},
|
||||
"find-up": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
|
||||
@@ -3517,6 +3527,17 @@
|
||||
"escape-goat": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"query-string": {
|
||||
"version": "6.14.0",
|
||||
"resolved": "https://registry.npmjs.org/query-string/-/query-string-6.14.0.tgz",
|
||||
"integrity": "sha512-In3o+lUxlgejoVJgwEdYtdxrmlL0cQWJXj0+kkI7RWVo7hg5AhFtybeKlC9Dpgbr8eOC4ydpEh8017WwyfzqVQ==",
|
||||
"requires": {
|
||||
"decode-uri-component": "^0.2.0",
|
||||
"filter-obj": "^1.1.0",
|
||||
"split-on-first": "^1.0.0",
|
||||
"strict-uri-encode": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"rc": {
|
||||
"version": "1.2.8",
|
||||
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
|
||||
@@ -3956,11 +3977,21 @@
|
||||
"integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==",
|
||||
"dev": true
|
||||
},
|
||||
"split-on-first": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz",
|
||||
"integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw=="
|
||||
},
|
||||
"sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
|
||||
},
|
||||
"strict-uri-encode": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
|
||||
"integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY="
|
||||
},
|
||||
"string-width": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
"long": "^4.0.0",
|
||||
"md5": "^2.2.1",
|
||||
"path": "^0.12.7",
|
||||
"query-string": "^6.14.0",
|
||||
"semver": "^7.3.2",
|
||||
"uuid": "^8.3.0",
|
||||
"zlib": "^1.0.5"
|
||||
|
||||
@@ -31,7 +31,7 @@ python3 -m pip install --user pipenv
|
||||
if command -v python2 &> /dev/null; then
|
||||
# Setup Python 2 dependency installation tools.
|
||||
# The Ubuntu 20.04 GHA environment does not come with a Python 2 pip
|
||||
curl --location --fail https://bootstrap.pypa.io/get-pip.py | python2
|
||||
curl --location --fail https://bootstrap.pypa.io/pip/2.7/get-pip.py | python2
|
||||
|
||||
python2 -m pip install --user --upgrade pip setuptools wheel
|
||||
|
||||
|
||||
24
runner/package-lock.json
generated
24
runner/package-lock.json
generated
@@ -1194,24 +1194,24 @@
|
||||
}
|
||||
},
|
||||
"elliptic": {
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
|
||||
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
|
||||
"version": "6.5.4",
|
||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
|
||||
"integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bn.js": "^4.4.0",
|
||||
"brorand": "^1.0.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"brorand": "^1.1.0",
|
||||
"hash.js": "^1.0.0",
|
||||
"hmac-drbg": "^1.0.0",
|
||||
"inherits": "^2.0.1",
|
||||
"minimalistic-assert": "^1.0.0",
|
||||
"minimalistic-crypto-utils": "^1.0.0"
|
||||
"hmac-drbg": "^1.0.1",
|
||||
"inherits": "^2.0.4",
|
||||
"minimalistic-assert": "^1.0.1",
|
||||
"minimalistic-crypto-utils": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"bn.js": {
|
||||
"version": "4.11.9",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz",
|
||||
"integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==",
|
||||
"version": "4.12.0",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
|
||||
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
actionsutil.getWorkflowErrors({
|
||||
on: 1,
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -242,7 +242,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: 1,
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -252,7 +252,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: [1],
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -262,7 +262,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: { 1: 1 },
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -272,7 +272,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: { test: 1 },
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -282,7 +282,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: { test: [1] },
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -292,7 +292,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: { test: { steps: 1 } },
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -302,7 +302,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: { test: { steps: [{ notrun: "git checkout HEAD^2" }] } },
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -312,7 +312,7 @@ test("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||
on: 1,
|
||||
jobs: { test: [undefined] },
|
||||
} as any),
|
||||
[actionsutil.WorkflowErrors.MissingHooks]
|
||||
[]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -403,6 +403,12 @@ test("formatWorkflowErrors() when there are multiple errors", (t) => {
|
||||
t.true(message.startsWith("2 issues were detected with this workflow:"));
|
||||
});
|
||||
|
||||
test("formatWorkflowCause() with no errors", (t) => {
|
||||
const message = actionsutil.formatWorkflowCause([]);
|
||||
|
||||
t.deepEqual(message, undefined);
|
||||
});
|
||||
|
||||
test("formatWorkflowCause()", (t) => {
|
||||
const message = actionsutil.formatWorkflowCause([
|
||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
||||
|
||||
@@ -45,6 +45,13 @@ export function getRequiredEnvParam(paramName: string): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
export function getTemporaryDirectory(): string {
|
||||
const value = process.env["CODEQL_ACTION_TEMP"];
|
||||
return value !== undefined && value !== ""
|
||||
? value
|
||||
: getRequiredEnvParam("RUNNER_TEMP");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures all required environment variables are set in the context of a local run.
|
||||
*/
|
||||
@@ -177,17 +184,11 @@ function branchesToArray(branches?: string | null | string[]): string[] | "**" {
|
||||
}
|
||||
return "**";
|
||||
}
|
||||
|
||||
enum MissingTriggers {
|
||||
None = 0,
|
||||
Push = 1,
|
||||
PullRequest = 2,
|
||||
}
|
||||
|
||||
export interface CodedError {
|
||||
message: string;
|
||||
code: string;
|
||||
}
|
||||
|
||||
function toCodedErrors<T>(errors: T): Record<keyof T, CodedError> {
|
||||
return Object.entries(errors).reduce((acc, [key, value]) => {
|
||||
acc[key] = { message: value, code: key };
|
||||
@@ -199,8 +200,6 @@ function toCodedErrors<T>(errors: T): Record<keyof T, CodedError> {
|
||||
// message to add as a warning annotation to the run
|
||||
export const WorkflowErrors = toCodedErrors({
|
||||
MismatchedBranches: `Please make sure that every branch in on.pull_request is also in on.push so that Code Scanning can compare pull requests against the state of the base branch.`,
|
||||
MissingHooks: `Please specify on.push and on.pull_request hooks so that Code Scanning can compare pull requests against the state of the base branch.`,
|
||||
MissingPullRequestHook: `Please specify an on.pull_request hook so that Code Scanning is explicitly run against pull requests. This will be required to see results on pull requests from January 31 2021.`,
|
||||
MissingPushHook: `Please specify an on.push hook so that Code Scanning can compare pull requests against the state of the base branch.`,
|
||||
PathsSpecified: `Using on.push.paths can prevent Code Scanning annotating new alerts in your pull requests.`,
|
||||
PathsIgnoreSpecified: `Using on.push.paths-ignore can prevent Code Scanning annotating new alerts in your pull requests.`,
|
||||
@@ -232,19 +231,19 @@ export function getWorkflowErrors(doc: Workflow): CodedError[] {
|
||||
}
|
||||
}
|
||||
|
||||
let missing = MissingTriggers.None;
|
||||
let missingPush = false;
|
||||
|
||||
if (doc.on === undefined) {
|
||||
// this is not a valid config
|
||||
} else if (typeof doc.on === "string") {
|
||||
if (doc.on === "pull_request") {
|
||||
missing = MissingTriggers.Push;
|
||||
missingPush = true;
|
||||
}
|
||||
} else if (Array.isArray(doc.on)) {
|
||||
const hasPush = doc.on.includes("push");
|
||||
const hasPullRequest = doc.on.includes("pull_request");
|
||||
if (hasPullRequest && !hasPush) {
|
||||
missing = missing | MissingTriggers.Push;
|
||||
missingPush = true;
|
||||
}
|
||||
} else if (isObject(doc.on)) {
|
||||
const hasPush = Object.prototype.hasOwnProperty.call(doc.on, "push");
|
||||
@@ -254,7 +253,7 @@ export function getWorkflowErrors(doc: Workflow): CodedError[] {
|
||||
);
|
||||
|
||||
if (!hasPush && hasPullRequest) {
|
||||
missing = missing | MissingTriggers.Push;
|
||||
missingPush = true;
|
||||
}
|
||||
if (hasPush && hasPullRequest) {
|
||||
const paths = doc.on.push?.paths;
|
||||
@@ -295,22 +294,10 @@ export function getWorkflowErrors(doc: Workflow): CodedError[] {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// on is not a known type
|
||||
// this workflow is likely malformed
|
||||
missing = MissingTriggers.Push | MissingTriggers.PullRequest;
|
||||
}
|
||||
|
||||
switch (missing) {
|
||||
case MissingTriggers.PullRequest | MissingTriggers.Push:
|
||||
errors.push(WorkflowErrors.MissingHooks);
|
||||
break;
|
||||
case MissingTriggers.PullRequest:
|
||||
errors.push(WorkflowErrors.MissingPullRequestHook);
|
||||
break;
|
||||
case MissingTriggers.Push:
|
||||
errors.push(WorkflowErrors.MissingPushHook);
|
||||
break;
|
||||
if (missingPush) {
|
||||
errors.push(WorkflowErrors.MissingPushHook);
|
||||
}
|
||||
|
||||
return errors;
|
||||
@@ -340,7 +327,7 @@ export async function validateWorkflow(): Promise<undefined | string> {
|
||||
core.warning(message);
|
||||
}
|
||||
|
||||
return `warning: ${formatWorkflowCause(workflowErrors)}`;
|
||||
return formatWorkflowCause(workflowErrors);
|
||||
}
|
||||
|
||||
export function formatWorkflowErrors(errors: CodedError[]): string {
|
||||
|
||||
@@ -19,7 +19,7 @@ test("emptyPaths", async (t) => {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" } as util.GitHubVersion,
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||
@@ -39,7 +39,7 @@ test("nonEmptyPaths", async (t) => {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" } as util.GitHubVersion,
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
||||
@@ -63,7 +63,7 @@ test("exclude temp dir", async (t) => {
|
||||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" } as util.GitHubVersion,
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
} from "./analyze";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import * as upload_lib from "./upload-lib";
|
||||
import * as util from "./util";
|
||||
|
||||
@@ -64,10 +63,7 @@ async function run() {
|
||||
return;
|
||||
}
|
||||
const logger = getActionsLogger();
|
||||
config = await getConfig(
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
logger
|
||||
);
|
||||
config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error(
|
||||
"Config file could not be found at expected location. Has the 'init' action been called?"
|
||||
@@ -90,16 +86,6 @@ async function run() {
|
||||
if (actionsUtil.getRequiredInput("upload") === "true") {
|
||||
const uploadStats = await upload_lib.uploadFromActions(
|
||||
outputDir,
|
||||
parseRepositoryNwo(
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")
|
||||
),
|
||||
await actionsUtil.getCommitOid(),
|
||||
await actionsUtil.getRef(),
|
||||
await actionsUtil.getAnalysisKey(),
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"),
|
||||
actionsUtil.getWorkflowRunID(),
|
||||
actionsUtil.getRequiredInput("checkout_path"),
|
||||
actionsUtil.getRequiredInput("matrix"),
|
||||
config.gitHubVersion,
|
||||
apiDetails,
|
||||
logger
|
||||
|
||||
@@ -34,7 +34,9 @@ test("status report fields", async (t) => {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" } as util.GitHubVersion,
|
||||
gitHubVersion: {
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
} as util.GitHubVersion,
|
||||
};
|
||||
fs.mkdirSync(util.getCodeQLDatabasePath(config.tempDir, language), {
|
||||
recursive: true,
|
||||
|
||||
@@ -20,7 +20,7 @@ export interface GitHubApiDetails {
|
||||
}
|
||||
|
||||
export interface GitHubApiExternalRepoDetails {
|
||||
externalRepoAuth: string | undefined;
|
||||
externalRepoAuth?: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"maximumVersion": "3.0", "minimumVersion": "2.22"}
|
||||
{"maximumVersion": "3.1", "minimumVersion": "2.22"}
|
||||
|
||||
@@ -57,7 +57,7 @@ async function run() {
|
||||
}
|
||||
|
||||
const config = await config_utils.getConfig(
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
logger
|
||||
);
|
||||
if (config === undefined) {
|
||||
|
||||
@@ -17,6 +17,11 @@ const sampleApiDetails = {
|
||||
url: "https://github.com",
|
||||
};
|
||||
|
||||
const sampleGHAEApiDetails = {
|
||||
auth: "token",
|
||||
url: "https://example.githubenterprise.com",
|
||||
};
|
||||
|
||||
test("download codeql bundle cache", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const versions = ["20200601", "20200610"];
|
||||
@@ -37,6 +42,7 @@ test("download codeql bundle cache", async (t) => {
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -64,6 +70,7 @@ test("download codeql bundle cache explicitly requested with pinned different ve
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -82,6 +89,7 @@ test("download codeql bundle cache explicitly requested with pinned different ve
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -104,6 +112,7 @@ test("don't download codeql bundle cache with pinned different version cached",
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -115,6 +124,7 @@ test("don't download codeql bundle cache with pinned different version cached",
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -139,6 +149,7 @@ test("download codeql bundle cache with different version cached (not pinned)",
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -165,6 +176,7 @@ test("download codeql bundle cache with different version cached (not pinned)",
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -189,6 +201,7 @@ test('download codeql bundle cache with pinned different version cached if "late
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -216,6 +229,7 @@ test('download codeql bundle cache with pinned different version cached if "late
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.DOTCOM,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
@@ -225,6 +239,58 @@ test('download codeql bundle cache with pinned different version cached if "late
|
||||
});
|
||||
});
|
||||
|
||||
test("download codeql bundle from github ae endpoint", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const bundleAssetID = 10;
|
||||
|
||||
const platform =
|
||||
process.platform === "win32"
|
||||
? "win64"
|
||||
: process.platform === "linux"
|
||||
? "linux64"
|
||||
: "osx64";
|
||||
const codeQLBundleName = `codeql-bundle-${platform}.tar.gz`;
|
||||
|
||||
nock("https://example.githubenterprise.com")
|
||||
.get(
|
||||
`/api/v3/enterprise/code-scanning/codeql-bundle/find/${defaults.bundleVersion}`
|
||||
)
|
||||
.reply(200, {
|
||||
assets: { [codeQLBundleName]: bundleAssetID },
|
||||
});
|
||||
|
||||
nock("https://example.githubenterprise.com")
|
||||
.get(
|
||||
`/api/v3/enterprise/code-scanning/codeql-bundle/download/${bundleAssetID}`
|
||||
)
|
||||
.reply(200, {
|
||||
url: `https://example.githubenterprise.com/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`,
|
||||
});
|
||||
|
||||
nock("https://example.githubenterprise.com")
|
||||
.get(
|
||||
`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`
|
||||
)
|
||||
.replyWithFile(
|
||||
200,
|
||||
path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)
|
||||
);
|
||||
|
||||
await codeql.setupCodeQL(
|
||||
undefined,
|
||||
sampleGHAEApiDetails,
|
||||
tmpDir,
|
||||
tmpDir,
|
||||
"runner",
|
||||
util.GitHubVariant.GHAE,
|
||||
getRunnerLogger(true)
|
||||
);
|
||||
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
test("parse codeql bundle url version", (t) => {
|
||||
t.deepEqual(
|
||||
codeql.getCodeQLURLVersion(
|
||||
|
||||
@@ -8,6 +8,7 @@ import * as http from "@actions/http-client";
|
||||
import { IHeaders } from "@actions/http-client/interfaces";
|
||||
import * as toolcache from "@actions/tool-cache";
|
||||
import { default as deepEqual } from "fast-deep-equal";
|
||||
import { default as queryString } from "query-string";
|
||||
import * as semver from "semver";
|
||||
import { v4 as uuidV4 } from "uuid";
|
||||
|
||||
@@ -136,8 +137,12 @@ function getCodeQLBundleName(): string {
|
||||
function getCodeQLActionRepository(mode: util.Mode, logger: Logger): string {
|
||||
if (mode !== "actions") {
|
||||
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
||||
} else {
|
||||
return getActionsCodeQLActionRepository(logger);
|
||||
}
|
||||
}
|
||||
|
||||
function getActionsCodeQLActionRepository(logger: Logger): string {
|
||||
if (process.env["GITHUB_ACTION_REPOSITORY"] !== undefined) {
|
||||
return process.env["GITHUB_ACTION_REPOSITORY"];
|
||||
}
|
||||
@@ -163,6 +168,7 @@ function getCodeQLActionRepository(mode: util.Mode, logger: Logger): string {
|
||||
async function getCodeQLBundleDownloadURL(
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
mode: util.Mode,
|
||||
variant: util.GitHubVariant,
|
||||
logger: Logger
|
||||
): Promise<string> {
|
||||
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
||||
@@ -182,6 +188,39 @@ async function getCodeQLBundleDownloadURL(
|
||||
}
|
||||
);
|
||||
const codeQLBundleName = getCodeQLBundleName();
|
||||
if (variant === util.GitHubVariant.GHAE) {
|
||||
try {
|
||||
const release = await api
|
||||
.getApiClient(apiDetails)
|
||||
.request("GET /enterprise/code-scanning/codeql-bundle/find/{tag}", {
|
||||
tag: CODEQL_BUNDLE_VERSION,
|
||||
});
|
||||
const assetID = release.data.assets[codeQLBundleName];
|
||||
if (assetID !== undefined) {
|
||||
const download = await api
|
||||
.getApiClient(apiDetails)
|
||||
.request(
|
||||
"GET /enterprise/code-scanning/codeql-bundle/download/{asset_id}",
|
||||
{ asset_id: assetID }
|
||||
);
|
||||
const downloadURL = download.data.url;
|
||||
logger.info(
|
||||
`Found CodeQL bundle at GitHub AE endpoint with URL ${downloadURL}.`
|
||||
);
|
||||
return downloadURL;
|
||||
} else {
|
||||
logger.info(
|
||||
`Attempted to fetch bundle from GitHub AE endpoint but the bundle ${codeQLBundleName} was not found in the assets ${JSON.stringify(
|
||||
release.data.assets
|
||||
)}.`
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.info(
|
||||
`Attempted to fetch bundle from GitHub AE endpoint but got error ${e}.`
|
||||
);
|
||||
}
|
||||
}
|
||||
for (const downloadSource of uniqueDownloadSources) {
|
||||
const [apiURL, repository] = downloadSource;
|
||||
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
|
||||
@@ -244,6 +283,7 @@ export async function setupCodeQL(
|
||||
tempDir: string,
|
||||
toolsDir: string,
|
||||
mode: util.Mode,
|
||||
variant: util.GitHubVariant,
|
||||
logger: Logger
|
||||
): Promise<{ codeql: CodeQL; toolsVersion: string }> {
|
||||
// Setting these two env vars makes the toolcache code safe to use outside,
|
||||
@@ -288,14 +328,25 @@ export async function setupCodeQL(
|
||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||
} else {
|
||||
if (!codeqlURL) {
|
||||
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, logger);
|
||||
codeqlURL = await getCodeQLBundleDownloadURL(
|
||||
apiDetails,
|
||||
mode,
|
||||
variant,
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
const parsedCodeQLURL = new URL(codeqlURL);
|
||||
const parsedQueryString = queryString.parse(parsedCodeQLURL.search);
|
||||
const headers: IHeaders = { accept: "application/octet-stream" };
|
||||
// We only want to provide an authorization header if we are downloading
|
||||
// from the same GitHub instance the Action is running on.
|
||||
// This avoids leaking Enterprise tokens to dotcom.
|
||||
if (codeqlURL.startsWith(`${apiDetails.url}/`)) {
|
||||
// We also don't want to send an authorization header if there's already a token provided in the URL.
|
||||
if (
|
||||
codeqlURL.startsWith(`${apiDetails.url}/`) &&
|
||||
parsedQueryString["token"] === undefined
|
||||
) {
|
||||
logger.debug("Downloading CodeQL bundle with token.");
|
||||
headers.authorization = `token ${apiDetails.auth}`;
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,7 @@ const sampleApiDetails = {
|
||||
url: "https://github.example.com",
|
||||
};
|
||||
|
||||
const gitHubVersion = { type: "dotcom" } as util.GitHubVersion;
|
||||
const gitHubVersion = { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion;
|
||||
|
||||
// Returns the filepath of the newly-created file
|
||||
function createConfigFile(inputFileContents: string, tmpDir: string): string {
|
||||
|
||||
@@ -95,7 +95,7 @@ export interface Config {
|
||||
codeQLCmd: string;
|
||||
/**
|
||||
* Version of GHES that we have determined that we are talking to, or undefined
|
||||
* if talking to github.com.
|
||||
* if talking to github.com or GitHub AE.
|
||||
*/
|
||||
gitHubVersion: GitHubVersion;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-20201127"
|
||||
"bundleVersion": "codeql-bundle-20210308"
|
||||
}
|
||||
|
||||
@@ -101,9 +101,7 @@ async function run() {
|
||||
};
|
||||
|
||||
const gitHubVersion = await getGitHubVersion(apiDetails);
|
||||
if (gitHubVersion !== undefined) {
|
||||
checkGitHubVersionInRange(gitHubVersion, "actions", logger);
|
||||
}
|
||||
checkGitHubVersionInRange(gitHubVersion, "actions", logger);
|
||||
|
||||
try {
|
||||
actionsUtil.prepareLocalRunEnvironment();
|
||||
@@ -126,9 +124,10 @@ async function run() {
|
||||
const initCodeQLResult = await initCodeQL(
|
||||
actionsUtil.getOptionalInput("tools"),
|
||||
apiDetails,
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||
"actions",
|
||||
gitHubVersion.type,
|
||||
logger
|
||||
);
|
||||
codeql = initCodeQLResult.codeql;
|
||||
@@ -139,7 +138,7 @@ async function run() {
|
||||
actionsUtil.getOptionalInput("queries"),
|
||||
actionsUtil.getOptionalInput("config-file"),
|
||||
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TEMP"),
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"),
|
||||
codeql,
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"),
|
||||
|
||||
@@ -19,6 +19,7 @@ export async function initCodeQL(
|
||||
tempDir: string,
|
||||
toolsDir: string,
|
||||
mode: util.Mode,
|
||||
variant: util.GitHubVariant,
|
||||
logger: Logger
|
||||
): Promise<{ codeql: CodeQL; toolsVersion: string }> {
|
||||
logger.startGroup("Setup CodeQL tools");
|
||||
@@ -28,6 +29,7 @@ export async function initCodeQL(
|
||||
tempDir,
|
||||
toolsDir,
|
||||
mode,
|
||||
variant,
|
||||
logger
|
||||
);
|
||||
await codeql.printVersion();
|
||||
@@ -111,6 +113,7 @@ export async function injectWindowsTracer(
|
||||
|
||||
$id = $PID
|
||||
while ($true) {
|
||||
Write-Host "Looking for process with id : $id"
|
||||
$p = Get-CimInstance -Class Win32_Process -Filter "ProcessId = $id"
|
||||
Write-Host "Found process: $p"
|
||||
if ($p -eq $null) {
|
||||
@@ -123,7 +126,8 @@ export async function injectWindowsTracer(
|
||||
}
|
||||
}
|
||||
Write-Host "Final process: $p"
|
||||
|
||||
Write-Host "Final pid: $id"
|
||||
Write-Host "Running: &$tracer --inject=$id"
|
||||
Invoke-Expression "&$tracer --inject=$id"`;
|
||||
} else {
|
||||
// If the level is not defined then guess at the 3rd parent process.
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
getMemoryFlag,
|
||||
getThreadsFlag,
|
||||
parseGithubUrl,
|
||||
getGitHubAuth,
|
||||
} from "./util";
|
||||
|
||||
const program = new Command();
|
||||
@@ -96,7 +97,7 @@ interface InitArgs {
|
||||
repository: string;
|
||||
githubUrl: string;
|
||||
githubAuth: string;
|
||||
externalRepositoryToken: string | undefined;
|
||||
githubAuthStdin: boolean;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
@@ -105,13 +106,13 @@ program
|
||||
.description("Initializes CodeQL")
|
||||
.requiredOption("--repository <repository>", "Repository name. (Required)")
|
||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||
.requiredOption(
|
||||
.option(
|
||||
"--github-auth <auth>",
|
||||
"GitHub Apps token or personal access token. (Required)"
|
||||
"GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead."
|
||||
)
|
||||
.option(
|
||||
"--external-repository-token <token>",
|
||||
"A token for fetching external config files and queries if they reside in a private repository."
|
||||
"--github-auth-stdin",
|
||||
"Read GitHub Apps token or personal access token from stdin."
|
||||
)
|
||||
.option(
|
||||
"--languages <languages>",
|
||||
@@ -153,16 +154,20 @@ program
|
||||
fs.rmdirSync(tempDir, { recursive: true });
|
||||
fs.mkdirSync(tempDir, { recursive: true });
|
||||
|
||||
const auth = await getGitHubAuth(
|
||||
logger,
|
||||
cmd.githubAuth,
|
||||
cmd.githubAuthStdin
|
||||
);
|
||||
|
||||
const apiDetails = {
|
||||
auth: cmd.githubAuth,
|
||||
externalRepoAuth: cmd.externalRepositoryToken,
|
||||
auth,
|
||||
externalRepoAuth: auth,
|
||||
url: parseGithubUrl(cmd.githubUrl),
|
||||
};
|
||||
|
||||
const gitHubVersion = await getGitHubVersion(apiDetails);
|
||||
if (gitHubVersion !== undefined) {
|
||||
checkGitHubVersionInRange(gitHubVersion, "runner", logger);
|
||||
}
|
||||
checkGitHubVersionInRange(gitHubVersion, "runner", logger);
|
||||
|
||||
let codeql: CodeQL;
|
||||
if (cmd.codeqlPath !== undefined) {
|
||||
@@ -175,6 +180,7 @@ program
|
||||
tempDir,
|
||||
toolsDir,
|
||||
"runner",
|
||||
gitHubVersion.type,
|
||||
logger
|
||||
)
|
||||
).codeql;
|
||||
@@ -315,6 +321,7 @@ interface AnalyzeArgs {
|
||||
ref: string;
|
||||
githubUrl: string;
|
||||
githubAuth: string;
|
||||
githubAuthStdin: boolean;
|
||||
checkoutPath: string | undefined;
|
||||
upload: boolean;
|
||||
outputDir: string | undefined;
|
||||
@@ -335,9 +342,13 @@ program
|
||||
)
|
||||
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||
.requiredOption(
|
||||
.option(
|
||||
"--github-auth <auth>",
|
||||
"GitHub Apps token or personal access token. (Required)"
|
||||
"GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead."
|
||||
)
|
||||
.option(
|
||||
"--github-auth-stdin",
|
||||
"Read GitHub Apps token or personal access token from stdin."
|
||||
)
|
||||
.option(
|
||||
"--checkout-path <path>",
|
||||
@@ -379,8 +390,14 @@ program
|
||||
);
|
||||
}
|
||||
|
||||
const auth = await getGitHubAuth(
|
||||
logger,
|
||||
cmd.githubAuth,
|
||||
cmd.githubAuthStdin
|
||||
);
|
||||
|
||||
const apiDetails = {
|
||||
auth: cmd.githubAuth,
|
||||
auth,
|
||||
url: parseGithubUrl(cmd.githubUrl),
|
||||
};
|
||||
|
||||
@@ -421,6 +438,7 @@ interface UploadArgs {
|
||||
commit: string;
|
||||
ref: string;
|
||||
githubUrl: string;
|
||||
githubAuthStdin: boolean;
|
||||
githubAuth: string;
|
||||
checkoutPath: string | undefined;
|
||||
debug: boolean;
|
||||
@@ -442,9 +460,13 @@ program
|
||||
)
|
||||
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||
.requiredOption(
|
||||
.option(
|
||||
"--github-auth <auth>",
|
||||
"GitHub Apps token or personal access token. (Required)"
|
||||
"GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead."
|
||||
)
|
||||
.option(
|
||||
"--github-auth-stdin",
|
||||
"Read GitHub Apps token or personal access token from stdin."
|
||||
)
|
||||
.option(
|
||||
"--checkout-path <path>",
|
||||
@@ -453,8 +475,13 @@ program
|
||||
.option("--debug", "Print more verbose output", false)
|
||||
.action(async (cmd: UploadArgs) => {
|
||||
const logger = getRunnerLogger(cmd.debug);
|
||||
const auth = await getGitHubAuth(
|
||||
logger,
|
||||
cmd.githubAuth,
|
||||
cmd.githubAuthStdin
|
||||
);
|
||||
const apiDetails = {
|
||||
auth: cmd.githubAuth,
|
||||
auth,
|
||||
url: parseGithubUrl(cmd.githubUrl),
|
||||
};
|
||||
try {
|
||||
|
||||
@@ -26,7 +26,7 @@ function getTestConfig(tmpDir: string): configUtils.Config {
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: "dotcom" } as util.GitHubVersion,
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import test from "ava";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { setupTests } from "./testing-utils";
|
||||
import * as uploadLib from "./upload-lib";
|
||||
import { GitHubVersion, withTmpDir } from "./util";
|
||||
import { GitHubVersion, GitHubVariant, withTmpDir } from "./util";
|
||||
|
||||
setupTests(test);
|
||||
|
||||
@@ -26,12 +26,12 @@ test("validateSarifFileSchema - invalid", (t) => {
|
||||
|
||||
test("validate correct payload used per version", async (t) => {
|
||||
const newVersions: GitHubVersion[] = [
|
||||
{ type: "dotcom" },
|
||||
{ type: "ghes", version: "3.1.0" },
|
||||
{ type: GitHubVariant.DOTCOM },
|
||||
{ type: GitHubVariant.GHES, version: "3.1.0" },
|
||||
];
|
||||
const oldVersions: GitHubVersion[] = [
|
||||
{ type: "ghes", version: "2.22.1" },
|
||||
{ type: "ghes", version: "3.0.0" },
|
||||
{ type: GitHubVariant.GHES, version: "2.22.1" },
|
||||
{ type: GitHubVariant.GHES, version: "3.0.0" },
|
||||
];
|
||||
const allVersions = newVersions.concat(oldVersions);
|
||||
|
||||
|
||||
@@ -7,10 +7,11 @@ import fileUrl from "file-url";
|
||||
import * as jsonschema from "jsonschema";
|
||||
import * as semver from "semver";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import * as api from "./api-client";
|
||||
import * as fingerprints from "./fingerprints";
|
||||
import { Logger } from "./logging";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
import { parseRepositoryNwo, RepositoryNwo } from "./repository";
|
||||
import * as sharedEnv from "./shared-environment";
|
||||
import * as util from "./util";
|
||||
|
||||
@@ -104,28 +105,20 @@ export function findSarifFilesInDir(sarifPath: string): string[] {
|
||||
// Returns true iff the upload occurred and succeeded
|
||||
export async function uploadFromActions(
|
||||
sarifPath: string,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
commitOid: string,
|
||||
ref: string,
|
||||
analysisKey: string,
|
||||
analysisName: string,
|
||||
workflowRunID: number,
|
||||
checkoutPath: string,
|
||||
environment: string,
|
||||
gitHubVersion: util.GitHubVersion,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
logger: Logger
|
||||
): Promise<UploadStatusReport> {
|
||||
return await uploadFiles(
|
||||
getSarifFilePaths(sarifPath),
|
||||
repositoryNwo,
|
||||
commitOid,
|
||||
ref,
|
||||
analysisKey,
|
||||
analysisName,
|
||||
workflowRunID,
|
||||
checkoutPath,
|
||||
environment,
|
||||
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||
await actionsUtil.getCommitOid(),
|
||||
await actionsUtil.getRef(),
|
||||
await actionsUtil.getAnalysisKey(),
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"),
|
||||
actionsUtil.getWorkflowRunID(),
|
||||
actionsUtil.getRequiredInput("checkout_path"),
|
||||
actionsUtil.getRequiredInput("matrix"),
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
"actions",
|
||||
@@ -248,7 +241,7 @@ export function buildPayload(
|
||||
|
||||
// This behaviour can be made the default when support for GHES 3.0 is discontinued.
|
||||
if (
|
||||
gitHubVersion.type === "dotcom" ||
|
||||
gitHubVersion.type !== util.GitHubVariant.GHES ||
|
||||
semver.satisfies(gitHubVersion.version, `>=3.1`)
|
||||
) {
|
||||
if (
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import * as upload_lib from "./upload-lib";
|
||||
import { getGitHubVersion } from "./util";
|
||||
|
||||
@@ -50,14 +49,6 @@ async function run() {
|
||||
|
||||
const uploadStats = await upload_lib.uploadFromActions(
|
||||
actionsUtil.getRequiredInput("sarif_file"),
|
||||
parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||
await actionsUtil.getCommitOid(),
|
||||
await actionsUtil.getRef(),
|
||||
await actionsUtil.getAnalysisKey(),
|
||||
actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"),
|
||||
actionsUtil.getWorkflowRunID(),
|
||||
actionsUtil.getRequiredInput("checkout_path"),
|
||||
actionsUtil.getRequiredInput("matrix"),
|
||||
gitHubVersion,
|
||||
apiDetails,
|
||||
getActionsLogger()
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as stream from "stream";
|
||||
|
||||
import * as github from "@actions/github";
|
||||
import test from "ava";
|
||||
import test, { ExecutionContext } from "ava";
|
||||
import sinon from "sinon";
|
||||
|
||||
import * as api from "./api-client";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { getRunnerLogger, Logger } from "./logging";
|
||||
import { setupTests } from "./testing-utils";
|
||||
import * as util from "./util";
|
||||
|
||||
@@ -23,10 +24,11 @@ test("getToolNames", (t) => {
|
||||
|
||||
test("getMemoryFlag() should return the correct --ram flag", (t) => {
|
||||
const totalMem = Math.floor(os.totalmem() / (1024 * 1024));
|
||||
const expectedThreshold = process.platform === "win32" ? 1536 : 1024;
|
||||
|
||||
const tests = [
|
||||
[undefined, `--ram=${totalMem - 256}`],
|
||||
["", `--ram=${totalMem - 256}`],
|
||||
[undefined, `--ram=${totalMem - expectedThreshold}`],
|
||||
["", `--ram=${totalMem - expectedThreshold}`],
|
||||
["512", "--ram=512"],
|
||||
];
|
||||
|
||||
@@ -221,19 +223,85 @@ test("getGitHubVersion", async (t) => {
|
||||
auth: "",
|
||||
url: "https://github.com",
|
||||
});
|
||||
t.deepEqual("dotcom", v.type);
|
||||
t.deepEqual(util.GitHubVariant.DOTCOM, v.type);
|
||||
|
||||
mockGetMetaVersionHeader("2.0");
|
||||
const v2 = await util.getGitHubVersion({
|
||||
auth: "",
|
||||
url: "https://ghe.example.com",
|
||||
});
|
||||
t.deepEqual({ type: "ghes", version: "2.0" }, v2);
|
||||
t.deepEqual({ type: util.GitHubVariant.GHES, version: "2.0" }, v2);
|
||||
|
||||
mockGetMetaVersionHeader("GitHub AE");
|
||||
const ghae = await util.getGitHubVersion({
|
||||
auth: "",
|
||||
url: "https://example.githubenterprise.com",
|
||||
});
|
||||
t.deepEqual({ type: util.GitHubVariant.GHAE }, ghae);
|
||||
|
||||
mockGetMetaVersionHeader(undefined);
|
||||
const v3 = await util.getGitHubVersion({
|
||||
auth: "",
|
||||
url: "https://ghe.example.com",
|
||||
});
|
||||
t.deepEqual({ type: "dotcom" }, v3);
|
||||
t.deepEqual({ type: util.GitHubVariant.DOTCOM }, v3);
|
||||
});
|
||||
|
||||
test("getGitHubAuth", async (t) => {
|
||||
const msgs: string[] = [];
|
||||
const mockLogger = ({
|
||||
warning: (msg: string) => msgs.push(msg),
|
||||
} as unknown) as Logger;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
t.throwsAsync(async () => util.getGitHubAuth(mockLogger, "abc", true));
|
||||
|
||||
process.env.GITHUB_TOKEN = "123";
|
||||
t.is("123", await util.getGitHubAuth(mockLogger, undefined, undefined));
|
||||
t.is(msgs.length, 0);
|
||||
t.is("abc", await util.getGitHubAuth(mockLogger, "abc", undefined));
|
||||
t.is(msgs.length, 1); // warning expected
|
||||
|
||||
msgs.length = 0;
|
||||
await mockStdInForAuth(t, mockLogger, "def", "def");
|
||||
await mockStdInForAuth(t, mockLogger, "def", "", "def");
|
||||
await mockStdInForAuth(
|
||||
t,
|
||||
mockLogger,
|
||||
"def",
|
||||
"def\n some extra garbage",
|
||||
"ghi"
|
||||
);
|
||||
await mockStdInForAuth(t, mockLogger, "defghi", "def", "ghi\n123");
|
||||
|
||||
await mockStdInForAuthExpectError(t, mockLogger, "");
|
||||
await mockStdInForAuthExpectError(t, mockLogger, "", " ", "abc");
|
||||
await mockStdInForAuthExpectError(
|
||||
t,
|
||||
mockLogger,
|
||||
" def\n some extra garbage",
|
||||
"ghi"
|
||||
);
|
||||
t.is(msgs.length, 0);
|
||||
});
|
||||
|
||||
async function mockStdInForAuth(
|
||||
t: ExecutionContext<any>,
|
||||
mockLogger: Logger,
|
||||
expected: string,
|
||||
...text: string[]
|
||||
) {
|
||||
const stdin = stream.Readable.from(text) as any;
|
||||
t.is(expected, await util.getGitHubAuth(mockLogger, undefined, true, stdin));
|
||||
}
|
||||
|
||||
async function mockStdInForAuthExpectError(
|
||||
t: ExecutionContext<unknown>,
|
||||
mockLogger: Logger,
|
||||
...text: string[]
|
||||
) {
|
||||
const stdin = stream.Readable.from(text) as any;
|
||||
await t.throwsAsync(async () =>
|
||||
util.getGitHubAuth(mockLogger, undefined, true, stdin)
|
||||
);
|
||||
}
|
||||
|
||||
107
src/util.ts
107
src/util.ts
@@ -1,6 +1,7 @@
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import { Readable } from "stream";
|
||||
|
||||
import * as core from "@actions/core";
|
||||
import * as semver from "semver";
|
||||
@@ -81,9 +82,22 @@ export async function withTmpDir<T>(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an OS-specific amount of memory (in MB) to reserve for OS processes
|
||||
* when the user doesn't explicitly specify a memory setting.
|
||||
* This is a heuristic to avoid OOM errors (exit code 137 / SIGKILL)
|
||||
* from committing too much of the available memory to CodeQL.
|
||||
* @returns number
|
||||
*/
|
||||
function getSystemReservedMemoryMegaBytes(): number {
|
||||
// Windows needs more memory for OS processes.
|
||||
return 1024 * (process.platform === "win32" ? 1.5 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
||||
* specified, the total available memory will be used minus 256 MB.
|
||||
* specified, the total available memory will be used minus a threshold
|
||||
* reserved for the OS.
|
||||
*
|
||||
* @returns string
|
||||
*/
|
||||
@@ -97,8 +111,8 @@ export function getMemoryFlag(userInput: string | undefined): string {
|
||||
} else {
|
||||
const totalMemoryBytes = os.totalmem();
|
||||
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
||||
const systemReservedMemoryMegaBytes = 256;
|
||||
memoryToUseMegaBytes = totalMemoryMegaBytes - systemReservedMemoryMegaBytes;
|
||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
||||
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
||||
}
|
||||
return `--ram=${Math.floor(memoryToUseMegaBytes)}`;
|
||||
}
|
||||
@@ -219,16 +233,22 @@ const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR =
|
||||
"CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
let hasBeenWarnedAboutVersion = false;
|
||||
|
||||
export enum GitHubVariant {
|
||||
DOTCOM,
|
||||
GHES,
|
||||
GHAE,
|
||||
}
|
||||
export type GitHubVersion =
|
||||
| { type: "dotcom" }
|
||||
| { type: "ghes"; version: string };
|
||||
| { type: GitHubVariant.DOTCOM }
|
||||
| { type: GitHubVariant.GHAE }
|
||||
| { type: GitHubVariant.GHES; version: string };
|
||||
|
||||
export async function getGitHubVersion(
|
||||
apiDetails: GitHubApiDetails
|
||||
): Promise<GitHubVersion> {
|
||||
// We can avoid making an API request in the standard dotcom case
|
||||
if (parseGithubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: "dotcom" };
|
||||
return { type: GitHubVariant.DOTCOM };
|
||||
}
|
||||
|
||||
// Doesn't strictly have to be the meta endpoint as we're only
|
||||
@@ -239,11 +259,15 @@ export async function getGitHubVersion(
|
||||
// This happens on dotcom, although we expect to have already returned in that
|
||||
// case. This can also serve as a fallback in cases we haven't foreseen.
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === undefined) {
|
||||
return { type: "dotcom" };
|
||||
return { type: GitHubVariant.DOTCOM };
|
||||
}
|
||||
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "GitHub AE") {
|
||||
return { type: GitHubVariant.GHAE };
|
||||
}
|
||||
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] as string;
|
||||
return { type: "ghes", version };
|
||||
return { type: GitHubVariant.GHES, version };
|
||||
}
|
||||
|
||||
export function checkGitHubVersionInRange(
|
||||
@@ -251,7 +275,7 @@ export function checkGitHubVersionInRange(
|
||||
mode: Mode,
|
||||
logger: Logger
|
||||
) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "ghes") {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== GitHubVariant.GHES) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -301,3 +325,68 @@ export function apiVersionInRange(
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the github auth token for use with the runner. There are
|
||||
* three possible locations for the token:
|
||||
*
|
||||
* 1. from the cli (considered insecure)
|
||||
* 2. from stdin
|
||||
* 3. from the GITHUB_TOKEN environment variable
|
||||
*
|
||||
* If both 1 & 2 are specified, then an error is thrown.
|
||||
* If 1 & 3 or 2 & 3 are specified, then the environment variable is ignored.
|
||||
*
|
||||
* @param githubAuth a github app token or PAT
|
||||
* @param fromStdIn read the github app token or PAT from stdin up to, but excluding the first whitespace
|
||||
* @param readable the readable stream to use for getting the token (defaults to stdin)
|
||||
*
|
||||
* @return a promise resolving to the auth token.
|
||||
*/
|
||||
export async function getGitHubAuth(
|
||||
logger: Logger,
|
||||
githubAuth: string | undefined,
|
||||
fromStdIn: boolean | undefined,
|
||||
readable = process.stdin as Readable
|
||||
): Promise<string> {
|
||||
if (githubAuth && fromStdIn) {
|
||||
throw new Error(
|
||||
"Cannot specify both `--github-auth` and `--github-auth-stdin`. Please use `--github-auth-stdin`, which is more secure."
|
||||
);
|
||||
}
|
||||
|
||||
if (githubAuth) {
|
||||
logger.warning(
|
||||
"Using `--github-auth` via the CLI is insecure. Use `--github-auth-stdin` instead."
|
||||
);
|
||||
return githubAuth;
|
||||
}
|
||||
|
||||
if (fromStdIn) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let token = "";
|
||||
readable.on("data", (data) => {
|
||||
token += data.toString("utf8");
|
||||
});
|
||||
readable.on("end", () => {
|
||||
token = token.split(/\s+/)[0].trim();
|
||||
if (token) {
|
||||
resolve(token);
|
||||
} else {
|
||||
reject(new Error("Standard input is empty"));
|
||||
}
|
||||
});
|
||||
readable.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (process.env.GITHUB_TOKEN) {
|
||||
return process.env.GITHUB_TOKEN;
|
||||
}
|
||||
|
||||
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."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
source "https://rubygems.org" do
|
||||
end
|
||||
end
|
||||
|
||||
gem "bundler"
|
||||
|
||||
12
tests/multi-language-repo/Gemfile.lock
Normal file
12
tests/multi-language-repo/Gemfile.lock
Normal file
@@ -0,0 +1,12 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
|
||||
PLATFORMS
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
bundler (= 2.2.9)
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.9
|
||||
Reference in New Issue
Block a user