Skip to content

Commit

Permalink
Showing 27 changed files with 2,159 additions and 3 deletions.
26 changes: 25 additions & 1 deletion lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions node_modules/decode-uri-component/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/decode-uri-component/license

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions node_modules/decode-uri-component/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions node_modules/decode-uri-component/readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/filter-obj/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/filter-obj/license

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions node_modules/filter-obj/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions node_modules/filter-obj/readme.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

489 changes: 489 additions & 0 deletions node_modules/query-string/index.d.ts

Large diffs are not rendered by default.

404 changes: 404 additions & 0 deletions node_modules/query-string/index.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions node_modules/query-string/license
54 changes: 54 additions & 0 deletions node_modules/query-string/package.json
527 changes: 527 additions & 0 deletions node_modules/query-string/readme.md

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions node_modules/split-on-first/index.d.ts
22 changes: 22 additions & 0 deletions node_modules/split-on-first/index.js
9 changes: 9 additions & 0 deletions node_modules/split-on-first/license
36 changes: 36 additions & 0 deletions node_modules/split-on-first/package.json
58 changes: 58 additions & 0 deletions node_modules/split-on-first/readme.md
2 changes: 2 additions & 0 deletions node_modules/strict-uri-encode/index.js
21 changes: 21 additions & 0 deletions node_modules/strict-uri-encode/license
31 changes: 31 additions & 0 deletions node_modules/strict-uri-encode/package.json
39 changes: 39 additions & 0 deletions node_modules/strict-uri-encode/readme.md
31 changes: 31 additions & 0 deletions package-lock.json
1 change: 1 addition & 0 deletions package.json
@@ -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"
34 changes: 33 additions & 1 deletion src/codeql.ts
@@ -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";

@@ -212,6 +213,31 @@ async function getCodeQLBundleDownloadURL(
);
}
}
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;
}
} catch (e) {
logger.info(
`Attempted to fetch bundle from GitHub AE endpoint but got error ${e}.`
);
}
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
}

@@ -291,11 +317,17 @@ export async function setupCodeQL(
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, 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 {

0 comments on commit f8c5dac

Please sign in to comment.