Skip to content

Commit

Permalink
Merge pull request #61 from github/disable_queries
Browse files Browse the repository at this point in the history
Add a quick way to disable builtin queries
  • Loading branch information
Robert authored and GitHub committed Jun 15, 2020
2 parents 476c8a4 + 19faafb commit 042ab54
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
21 changes: 20 additions & 1 deletion lib/finalize-db.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/finalize-db.js.map

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

25 changes: 23 additions & 2 deletions src/finalize-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ import * as sharedEnv from './shared-environment';
import * as upload_lib from './upload-lib';
import * as util from './util';

/**
* A list of queries from https://github.com/github/codeql that
* we don't want to run. Disabling them here is a quicker alternative to
* disabling them in the code scanning query suites. Queries should also
* be disabled in the suites, and removed from this list here once the
* bundle is updated to make those suite changes live.
*
* Format is a map from language to an array of path suffixes of .ql files.
*/
const DISABLED_BUILTIN_QUERIES: {[language: string]: string[]} = {
'csharp': [
'ql/src/Security Features/CWE-937/VulnerablePackage.ql',
'ql/src/Security Features/CWE-451/MissingXFrameOptions.ql',
]
};

function queryIsDisabled(language, query): boolean {
return (DISABLED_BUILTIN_QUERIES[language] || [])
.some(disabledQuery => query.endsWith(disabledQuery));
}

function getMemoryFlag(): string {
let memoryToUseMegaBytes: number;
const memoryToUseString = core.getInput("ram");
Expand Down Expand Up @@ -125,7 +146,7 @@ async function resolveQueryLanguages(codeqlCmd: string, config: configUtils.Conf
if (res[language] === undefined) {
res[language] = [];
}
res[language].push(...Object.keys(<any>queries));
res[language].push(...Object.keys(queries).filter(q => !queryIsDisabled(language, q)));
}
}

Expand All @@ -136,7 +157,7 @@ async function resolveQueryLanguages(codeqlCmd: string, config: configUtils.Conf
if (res[language] === undefined) {
res[language] = [];
}
res[language].push(...Object.keys(<any>queries));
res[language].push(...Object.keys(queries));
}

const noDeclaredLanguage = resolveQueriesOutputObject.noDeclaredLanguage;
Expand Down

0 comments on commit 042ab54

Please sign in to comment.