Skip to content

Commit

Permalink
Run the pack download command
Browse files Browse the repository at this point in the history
  • Loading branch information
aeisenberg committed Jun 6, 2021
1 parent 06687e9 commit d87945e
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 7 deletions.
8 changes: 8 additions & 0 deletions lib/analyze.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/analyze.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions 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.

20 changes: 20 additions & 0 deletions lib/init-action.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/init-action.js.map

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

11 changes: 11 additions & 0 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ export async function runQueries(
}

try {
if (hasPackWithCustomQueries) {
const codeql = getCodeQL(config.codeQLCmd);
const results = await codeql.packDownload(packsWithVersion);
logger.info(
`Downloaded packs: ${results.packs
.map((r) => `${r.name}@${r.version || "latest"}`)
.join(", ")}`
);
}

let analysisSummaryBuiltIn = "";
const customAnalysisSummaries: string[] = [];
if (queries["builtin"].length > 0) {
Expand Down Expand Up @@ -256,6 +266,7 @@ export async function runQueries(
logger.endGroup();
} catch (e) {
logger.info(e);
logger.info(e.stack);
statusReport.analyze_failure_language = language;
throw new CodeQLAnalysisError(
statusReport,
Expand Down
4 changes: 2 additions & 2 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
await new toolrunner.ToolRunner(cmd, args, {
listeners: {
stdout: (data: Buffer) => {
output += data.toString("utf8");
output += data.toString();
},
},
}).exec();
Expand All @@ -781,7 +781,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
const args = [
"pack",
"download",
"-v",
"--format=json",
...getExtraOptionsFromEnv(["pack", "download"]),
...packs.map(packWithVersionToString),
];
Expand Down
27 changes: 27 additions & 0 deletions src/init-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import * as fs from "fs";
import * as os from "os";
import * as path from "path";

import * as core from "@actions/core";
import * as yaml from "js-yaml";

import {
createStatusReportBase,
Expand Down Expand Up @@ -177,6 +182,28 @@ async function run() {
);
}
}

////////////////////////////////
// TODO This should not happen in the action, we should be able to
// generate the default qlconfig from the CLI
// DO NOT COMMIT THIS
const defaultQlConfig = {
registryKind: "docker",
registries: [
{
url: "https://ghcr.io/v2/",
packages: "*",
},
],
};

fs.mkdirSync(path.join(os.homedir(), ".codeql"));
fs.writeFileSync(
path.join(os.homedir(), ".codeql", "qlconfig.yml"),
yaml.safeDump(defaultQlConfig),
"utf8"
);
////////////////////////////////
} catch (e) {
core.setFailed(e.message);
console.log(e);
Expand Down

0 comments on commit d87945e

Please sign in to comment.