Skip to content

Commit d87945e

Browse files
committed
Run the pack download command
1 parent 06687e9 commit d87945e

9 files changed

Lines changed: 73 additions & 7 deletions

File tree

lib/analyze.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/codeql.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,16 @@ export async function runQueries(
178178
}
179179

180180
try {
181+
if (hasPackWithCustomQueries) {
182+
const codeql = getCodeQL(config.codeQLCmd);
183+
const results = await codeql.packDownload(packsWithVersion);
184+
logger.info(
185+
`Downloaded packs: ${results.packs
186+
.map((r) => `${r.name}@${r.version || "latest"}`)
187+
.join(", ")}`
188+
);
189+
}
190+
181191
let analysisSummaryBuiltIn = "";
182192
const customAnalysisSummaries: string[] = [];
183193
if (queries["builtin"].length > 0) {
@@ -256,6 +266,7 @@ export async function runQueries(
256266
logger.endGroup();
257267
} catch (e) {
258268
logger.info(e);
269+
logger.info(e.stack);
259270
statusReport.analyze_failure_language = language;
260271
throw new CodeQLAnalysisError(
261272
statusReport,

src/codeql.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
760760
await new toolrunner.ToolRunner(cmd, args, {
761761
listeners: {
762762
stdout: (data: Buffer) => {
763-
output += data.toString("utf8");
763+
output += data.toString();
764764
},
765765
},
766766
}).exec();
@@ -781,7 +781,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
781781
const args = [
782782
"pack",
783783
"download",
784-
"-v",
784+
"--format=json",
785785
...getExtraOptionsFromEnv(["pack", "download"]),
786786
...packs.map(packWithVersionToString),
787787
];

src/init-action.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
import * as fs from "fs";
2+
import * as os from "os";
3+
import * as path from "path";
4+
15
import * as core from "@actions/core";
6+
import * as yaml from "js-yaml";
27

38
import {
49
createStatusReportBase,
@@ -177,6 +182,28 @@ async function run() {
177182
);
178183
}
179184
}
185+
186+
////////////////////////////////
187+
// TODO This should not happen in the action, we should be able to
188+
// generate the default qlconfig from the CLI
189+
// DO NOT COMMIT THIS
190+
const defaultQlConfig = {
191+
registryKind: "docker",
192+
registries: [
193+
{
194+
url: "https://ghcr.io/v2/",
195+
packages: "*",
196+
},
197+
],
198+
};
199+
200+
fs.mkdirSync(path.join(os.homedir(), ".codeql"));
201+
fs.writeFileSync(
202+
path.join(os.homedir(), ".codeql", "qlconfig.yml"),
203+
yaml.safeDump(defaultQlConfig),
204+
"utf8"
205+
);
206+
////////////////////////////////
180207
} catch (e) {
181208
core.setFailed(e.message);
182209
console.log(e);

0 commit comments

Comments
 (0)