Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into v1 #568

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
86a804f
Allow the codeql-action to run packages
aeisenberg Jun 3, 2021
6cee818
Add better comments and error messages for pack-related changes
aeisenberg Jun 4, 2021
9b5753a
Fix logic for calculating if there are queries to run
aeisenberg Jun 4, 2021
06687e9
Avoid using `SemVer` instances
aeisenberg Jun 4, 2021
d87945e
Run the pack download command
aeisenberg Jun 4, 2021
02e8dcf
Fix out of memory in hash computation
edoardopirovano Jun 7, 2021
9e6b46a
Update changelog and version after v1.0.1
invalid-email-address Jun 7, 2021
fbb9046
1.0.2
invalid-email-address Jun 7, 2021
a69f472
Merge branch 'main' into mergeback/v1.0.1-to-main-ece2addc
aeisenberg Jun 7, 2021
9c13fef
Merge pull request #554 from github/mergeback/v1.0.1-to-main-ece2addc
aeisenberg Jun 7, 2021
c095005
Some refactoring in fingerprint computation
edoardopirovano Jun 7, 2021
2cc885d
Replace analyze with run-queries and interpret-results
edoardopirovano Jun 4, 2021
1cc5f1d
Packaging: Address review comments
aeisenberg Jun 7, 2021
d42f654
Add an integration test for packaging
aeisenberg Jun 8, 2021
0ea20c5
Add intepret-results timings to status reports
edoardopirovano Jun 9, 2021
06df98a
Add new log grouping for DB cleanup
edoardopirovano Jun 9, 2021
babcc1b
Add `--finalize-dataset` to `database finalize` call
edoardopirovano Jun 9, 2021
82388fd
Merge remote-tracking branch 'upstream/main' into aeisenberg/pack-run
aeisenberg Jun 9, 2021
db01c78
Remove unneeded action input in PR check
aeisenberg Jun 9, 2021
49b2220
Refactor codeql.ts
aeisenberg Jun 9, 2021
96e7de3
Use nullish conversion for packs
aeisenberg Jun 9, 2021
a2e96a4
Add pack download to its own log group
aeisenberg Jun 9, 2021
23cdd6b
Remove two log entries
aeisenberg Jun 9, 2021
6a1c070
Avoid running mergeback workflow on PR
aeisenberg Jun 9, 2021
20aafcd
Remove unnecessary type assertions
aeisenberg Jun 10, 2021
e284efb
Merge pull request #545 from github/aeisenberg/pack-run
aeisenberg Jun 10, 2021
bbc9e44
1.0.2
invalid-email-address Jun 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Packaging: Address review comments
1. Better malformed data guard for PackDownloadOutput
2. Fix Packs type
3. Remove TODO in init-action
aeisenberg committed Jun 8, 2021
commit 1cc5f1d5dd07a0ba41613a8c038c643507d6d677
2 changes: 1 addition & 1 deletion lib/analysis-paths.test.js.map

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

1 change: 1 addition & 0 deletions lib/analyze.test.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.test.js.map

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

11 changes: 9 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.

2 changes: 1 addition & 1 deletion lib/config-utils.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/config-utils.js.map

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions lib/init-action.js
2 changes: 1 addition & 1 deletion lib/init-action.js.map
7 changes: 3 additions & 4 deletions src/analysis-paths.test.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@ import * as path from "path";
import test from "ava";

import * as analysisPaths from "./analysis-paths";
import { Packs } from "./config-utils";
import { setupTests } from "./testing-utils";
import * as util from "./util";

@@ -22,7 +21,7 @@ test("emptyPaths", async (t) => {
codeQLCmd: "",
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
dbLocation: path.resolve(tmpDir, "codeql_databases"),
packs: {} as Packs,
packs: {},
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
@@ -44,7 +43,7 @@ test("nonEmptyPaths", async (t) => {
codeQLCmd: "",
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
dbLocation: path.resolve(tmpDir, "codeql_databases"),
packs: {} as Packs,
packs: {},
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
@@ -70,7 +69,7 @@ test("exclude temp dir", async (t) => {
codeQLCmd: "",
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
dbLocation: path.resolve(tempDir, "codeql_databases"),
packs: {} as Packs,
packs: {},
};
analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
9 changes: 5 additions & 4 deletions src/analyze.test.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import sinon from "sinon";

import { runQueries } from "./analyze";
import { setCodeQL } from "./codeql";
import { Config, Packs } from "./config-utils";
import { Config } from "./config-utils";
import { getIdPrefix } from "./count-loc";
import * as count from "./count-loc";
import { Language } from "./languages";
@@ -39,19 +39,20 @@ test("status report fields and search path setting", async (t) => {
[Language.cpp]: [
{
packName: "a/b",
version: clean("1.0.0"),
version: clean("1.0.0")!,
},
],
[Language.java]: [
{
packName: "c/d",
version: clean("2.0.0"),
version: clean("2.0.0")!,
},
],
} as Packs;
};

for (const language of Object.values(Language)) {
setCodeQL({
packDownload: async () => ({ packs: [] }),
databaseAnalyze: async (
_,
sarifFile: string,
12 changes: 10 additions & 2 deletions src/codeql.ts
Original file line number Diff line number Diff line change
@@ -796,10 +796,18 @@ function getCodeQLForCmd(cmd: string): CodeQL {
}).exec();

try {
return JSON.parse(output) as PackDownloadOutput;
const parsedOutput: PackDownloadOutput = JSON.parse(output);
if (
Array.isArray(parsedOutput.packs) &&
parsedOutput.packs.every((p) => p.name && p.version)
) {
return parsedOutput;
} else {
throw new Error("Unexpected output from pack download");
}
} catch (e) {
throw new Error(
`Attempted to download specified packs but got an error:${"\n"}${output}.`
`Attempted to download specified packs but got an error:\n${output}\n${e}`
);
}
},
9 changes: 5 additions & 4 deletions src/config-utils.ts
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ export interface Config {
packs: Packs;
}

export type Packs = Record<Partial<Language>, PackWithVersion[]>;
export type Packs = Partial<Record<Language, PackWithVersion[]>>;

export interface PackWithVersion {
/** qualified name of a package reference */
@@ -1032,8 +1032,8 @@ export function parsePacks(
packsByLanguage: string[] | Record<string, string[]> | undefined,
languages: Language[],
configFile: string
) {
const packs = {} as Packs;
): Packs {
const packs = {};

if (!packsByLanguage) {
return packs;
@@ -1071,6 +1071,7 @@ function toPackWithVersion(packStr, configFile: string): PackWithVersion {
if (typeof packStr !== "string") {
throw new Error(getPacksStrInvalid(packStr, configFile));
}

const nameWithVersion = packStr.split("@");
let version: string | undefined;
if (
@@ -1158,7 +1159,7 @@ export async function initConfig(
for (const language of config.languages) {
const hasBuiltinQueries = config.queries[language]?.builtin.length > 0;
const hasCustomQueries = config.queries[language]?.custom.length > 0;
const hasPacks = config.packs[language]?.length > 0;
const hasPacks = (config.packs[language]?.length || 0) > 0;
if (!hasPacks && !hasBuiltinQueries && !hasCustomQueries) {
throw new Error(
`Did not detect any queries to run for ${language}. ` +
27 changes: 0 additions & 27 deletions src/init-action.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
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,
@@ -182,28 +177,6 @@ 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);