add debug mode to limit output
This commit is contained in:
parent
f80d660e33
commit
6f422a4303
18 changed files with 86 additions and 69 deletions
4
lib/codeql.test.js
generated
4
lib/codeql.test.js
generated
|
|
@ -27,7 +27,7 @@ ava_1.default('download codeql bundle cache', async (t) => {
|
|||
nock_1.default('https://example.com')
|
||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, 'token', 'https://github.example.com', tmpDir, tmpDir, 'runner', logging_1.getRunnerLogger());
|
||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, 'token', 'https://github.example.com', tmpDir, tmpDir, 'runner', logging_1.getRunnerLogger(true));
|
||||
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
|
||||
}
|
||||
const cachedVersions = toolcache.findAllVersions('CodeQL');
|
||||
|
|
@ -46,7 +46,7 @@ ava_1.default('parse codeql bundle url version', t => {
|
|||
for (const [version, expectedVersion] of Object.entries(tests)) {
|
||||
const url = `https://github.com/.../codeql-bundle-${version}/...`;
|
||||
try {
|
||||
const parsedVersion = codeql.getCodeQLURLVersion(url, logging_1.getRunnerLogger());
|
||||
const parsedVersion = codeql.getCodeQLURLVersion(url, logging_1.getRunnerLogger(true));
|
||||
t.deepEqual(parsedVersion, expectedVersion);
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"codeql.test.js","sourceRoot":"","sources":["../src/codeql.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAiD;AACjD,8CAAuB;AACvB,gDAAwB;AACxB,2CAA6B;AAE7B,iDAAmC;AACnC,uCAA4C;AAC5C,mDAA2C;AAC3C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,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AI,CAAC,CAAC,CAAC;IAEpE,IAAI,EAAE,GAAG,EAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAC,EAAC,CAAC;IACnD,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,wCAAwC,EAAE,CAAC,CAAC,EAAE;IACjD,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,EAAC,GAAG,EAAE,EAAE,EAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAE/D,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,EAAC,GAAG,EAAE,EAAE,EAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAE/D,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,EAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAC,EAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC"}
|
||||
42
lib/config-utils.test.js
generated
42
lib/config-utils.test.js
generated
|
|
@ -47,7 +47,7 @@ function mockListLanguages(languages) {
|
|||
}
|
||||
ava_1.default("load empty config", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
const logger = logging_1.getRunnerLogger();
|
||||
const logger = logging_1.getRunnerLogger(true);
|
||||
const languages = 'javascript,python';
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
resolveQueries: async function () {
|
||||
|
|
@ -64,7 +64,7 @@ ava_1.default("load empty config", async (t) => {
|
|||
});
|
||||
ava_1.default("loading config saves config", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
const logger = logging_1.getRunnerLogger();
|
||||
const logger = logging_1.getRunnerLogger(true);
|
||||
const codeQL = codeql_1.setCodeQL({
|
||||
resolveQueries: async function () {
|
||||
return {
|
||||
|
|
@ -89,7 +89,7 @@ ava_1.default("loading config saves config", async (t) => {
|
|||
ava_1.default("load input outside of workspace", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
try {
|
||||
await configUtils.initConfig(undefined, undefined, '../input', { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(undefined, undefined, '../input', { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -102,7 +102,7 @@ ava_1.default("load non-local input with invalid repo syntax", async (t) => {
|
|||
// no filename given, just a repo
|
||||
const configFile = 'octo-org/codeql-config@main';
|
||||
try {
|
||||
await configUtils.initConfig(undefined, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(undefined, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -116,7 +116,7 @@ ava_1.default("load non-existent input", async (t) => {
|
|||
const configFile = 'input';
|
||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
||||
try {
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -172,7 +172,7 @@ ava_1.default("load non-empty input", async (t) => {
|
|||
const languages = 'javascript';
|
||||
const configFile = 'input';
|
||||
fs.writeFileSync(path.join(tmpDir, configFile), inputFileContents, 'utf8');
|
||||
const actualConfig = await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
const actualConfig = await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
// Should exactly equal the object we constructed earlier
|
||||
t.deepEqual(actualConfig, expectedConfig);
|
||||
});
|
||||
|
|
@ -209,7 +209,7 @@ ava_1.default("default queries are used", async (t) => {
|
|||
const languages = 'javascript';
|
||||
const configFile = 'input';
|
||||
fs.writeFileSync(path.join(tmpDir, configFile), inputFileContents, 'utf8');
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
// Check resolve queries was called correctly
|
||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||
t.deepEqual(resolveQueriesArgs[0].queries, ['javascript-code-scanning.qls']);
|
||||
|
|
@ -244,7 +244,7 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
|||
},
|
||||
});
|
||||
const languages = 'javascript';
|
||||
const config = await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
const config = await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
// Check resolveQueries was called correctly
|
||||
// It'll be called once for the default queries
|
||||
// and once for `./foo` from the config file.
|
||||
|
|
@ -288,7 +288,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
|||
},
|
||||
});
|
||||
const languages = 'javascript';
|
||||
const config = await configUtils.initConfig(languages, queries, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
const config = await configUtils.initConfig(languages, queries, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
// Check resolveQueries was called correctly
|
||||
// It'll be called once for the default queries and once for `./override`,
|
||||
// but won't be called for './foo' from the config file.
|
||||
|
|
@ -325,7 +325,7 @@ ava_1.default("Multiple queries can be specified in workflow file, no config fil
|
|||
},
|
||||
});
|
||||
const languages = 'javascript';
|
||||
const config = await configUtils.initConfig(languages, queries, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
const config = await configUtils.initConfig(languages, queries, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
// Check resolveQueries was called correctly:
|
||||
// It'll be called once for the default queries,
|
||||
// and then once for each of the two queries from the workflow
|
||||
|
|
@ -359,7 +359,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
|||
},
|
||||
});
|
||||
try {
|
||||
await configUtils.initConfig(languages, queries, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(languages, queries, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
t.fail('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -402,7 +402,7 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
|||
fs.mkdirSync(path.join(tmpDir, 'foo/bar/dev'), { recursive: true });
|
||||
const configFile = 'octo-org/codeql-config/config.yaml@main';
|
||||
const languages = 'javascript';
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
t.assert(spyGetContents.called);
|
||||
});
|
||||
});
|
||||
|
|
@ -412,7 +412,7 @@ ava_1.default("Remote config handles the case where a directory is provided", as
|
|||
mockGetContents(dummyResponse);
|
||||
const repoReference = 'octo-org/codeql-config/config.yaml@main';
|
||||
try {
|
||||
await configUtils.initConfig(undefined, undefined, repoReference, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(undefined, undefined, repoReference, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -428,7 +428,7 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
|||
mockGetContents(dummyResponse);
|
||||
const repoReference = 'octo-org/codeql-config/config.yaml@main';
|
||||
try {
|
||||
await configUtils.initConfig(undefined, undefined, repoReference, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(undefined, undefined, repoReference, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -440,7 +440,7 @@ ava_1.default("No detected languages", async (t) => {
|
|||
return await util.withTmpDir(async (tmpDir) => {
|
||||
mockListLanguages([]);
|
||||
try {
|
||||
await configUtils.initConfig(undefined, undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(undefined, undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -452,7 +452,7 @@ ava_1.default("Unknown languages", async (t) => {
|
|||
return await util.withTmpDir(async (tmpDir) => {
|
||||
const languages = 'ruby,english';
|
||||
try {
|
||||
await configUtils.initConfig(languages, undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(languages, undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -477,7 +477,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
|||
const inputFile = path.join(tmpDir, configFile);
|
||||
fs.writeFileSync(inputFile, inputFileContents, 'utf8');
|
||||
try {
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
}
|
||||
catch (err) {
|
||||
|
|
@ -537,10 +537,10 @@ ava_1.default('path validations', t => {
|
|||
const propertyName = 'paths';
|
||||
const configFile = './.github/codeql/config.yml';
|
||||
for (const path of validPaths) {
|
||||
t.truthy(configUtils.validateAndSanitisePath(path, propertyName, configFile, logging_1.getRunnerLogger()));
|
||||
t.truthy(configUtils.validateAndSanitisePath(path, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
||||
}
|
||||
for (const path of invalidPaths) {
|
||||
t.throws(() => configUtils.validateAndSanitisePath(path, propertyName, configFile, logging_1.getRunnerLogger()));
|
||||
t.throws(() => configUtils.validateAndSanitisePath(path, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
||||
}
|
||||
});
|
||||
ava_1.default('path sanitisation', t => {
|
||||
|
|
@ -548,8 +548,8 @@ ava_1.default('path sanitisation', t => {
|
|||
const propertyName = 'paths';
|
||||
const configFile = './.github/codeql/config.yml';
|
||||
// Valid paths are not modified
|
||||
t.deepEqual(configUtils.validateAndSanitisePath('foo/bar', propertyName, configFile, logging_1.getRunnerLogger()), 'foo/bar');
|
||||
t.deepEqual(configUtils.validateAndSanitisePath('foo/bar', propertyName, configFile, logging_1.getRunnerLogger(true)), 'foo/bar');
|
||||
// Trailing stars are stripped
|
||||
t.deepEqual(configUtils.validateAndSanitisePath('foo/**', propertyName, configFile, logging_1.getRunnerLogger()), 'foo/');
|
||||
t.deepEqual(configUtils.validateAndSanitisePath('foo/**', propertyName, configFile, logging_1.getRunnerLogger(true)), 'foo/');
|
||||
});
|
||||
//# sourceMappingURL=config-utils.test.js.map
|
||||
File diff suppressed because one or more lines are too long
6
lib/fingerprints.test.js
generated
6
lib/fingerprints.test.js
generated
|
|
@ -99,7 +99,7 @@ ava_1.default('hash', (t) => {
|
|||
function testResolveUriToFile(uri, index, artifactsURIs) {
|
||||
const location = { "uri": uri, "index": index };
|
||||
const artifacts = artifactsURIs.map(uri => ({ "location": { "uri": uri } }));
|
||||
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), logging_1.getRunnerLogger());
|
||||
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), logging_1.getRunnerLogger(true));
|
||||
}
|
||||
ava_1.default('resolveUriToFile', t => {
|
||||
// The resolveUriToFile method checks that the file exists and is in the right directory
|
||||
|
|
@ -143,7 +143,7 @@ ava_1.default('addFingerprints', t => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(__dirname + '/../src/testdata');
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger(true)), expected);
|
||||
});
|
||||
ava_1.default('missingRegions', t => {
|
||||
// Run an end-to-end test on a test file
|
||||
|
|
@ -154,6 +154,6 @@ ava_1.default('missingRegions', t => {
|
|||
expected = JSON.stringify(JSON.parse(expected));
|
||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(__dirname + '/../src/testdata');
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger(true)), expected);
|
||||
});
|
||||
//# sourceMappingURL=fingerprints.test.js.map
|
||||
File diff suppressed because one or more lines are too long
4
lib/logging.js
generated
4
lib/logging.js
generated
|
|
@ -12,9 +12,9 @@ function getActionsLogger() {
|
|||
return core;
|
||||
}
|
||||
exports.getActionsLogger = getActionsLogger;
|
||||
function getRunnerLogger() {
|
||||
function getRunnerLogger(debugMode) {
|
||||
return {
|
||||
debug: console.debug,
|
||||
debug: debugMode ? console.debug : () => undefined,
|
||||
info: console.info,
|
||||
warning: console.warn,
|
||||
error: console.error,
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAYtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe;IAC7B,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AATD,0CASC"}
|
||||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAYtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AATD,0CASC"}
|
||||
9
lib/runner.js
generated
9
lib/runner.js
generated
|
|
@ -67,7 +67,6 @@ function checkEnvironmentSetup(config) {
|
|||
"See end out output from 'init' command for instructions.");
|
||||
}
|
||||
}
|
||||
const logger = logging_1.getRunnerLogger();
|
||||
program
|
||||
.command('init')
|
||||
.description('Initializes CodeQL')
|
||||
|
|
@ -81,7 +80,9 @@ program
|
|||
.option('--temp-dir <dir>', 'Directory to use for temporary files. By default will use current working directory.')
|
||||
.option('--tools-dir <dir>', 'Directory to use for CodeQL tools and other files to store between runs. By default will use home directory.')
|
||||
.option('--checkout-path <path>', 'Checkout path (default: current working directory)')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd) => {
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const tempDir = getTempDir(cmd.tempDir);
|
||||
const toolsDir = getToolsDir(cmd.toolsDir);
|
||||
|
|
@ -139,7 +140,9 @@ program
|
|||
.description('Attempts to automatically build code')
|
||||
.option('--language <language>', 'The language to build. By default will try to detect the dominant language.')
|
||||
.option('--temp-dir <dir>', 'Directory to use for temporary files. By default will use current working directory.')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd) => {
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
|
||||
checkEnvironmentSetup(config);
|
||||
|
|
@ -176,7 +179,9 @@ program
|
|||
.option('--no-upload', 'Do not upload results after analysis', false)
|
||||
.option('--output-dir <dir>', 'Directory to output SARIF files to. By default will use temp directory.')
|
||||
.option('--temp-dir <dir>', 'Directory to use for temporary files. By default will use current working directory.')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd) => {
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const tempDir = getTempDir(cmd.tempDir);
|
||||
const outputDir = cmd.outputDir || path.join(tempDir, 'codeql-sarif');
|
||||
|
|
@ -200,7 +205,9 @@ program
|
|||
.requiredOption('--github-url <url>', 'URL of GitHub instance')
|
||||
.requiredOption('--github-auth <auth>', 'GitHub Apps token, or of the form "username:token" if using a personal access token')
|
||||
.option('--checkout-path <path>', 'Checkout path (default: current working directory)')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd) => {
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, cmd.ref, undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), 'runner', logger);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
4
lib/upload-lib.test.js
generated
4
lib/upload-lib.test.js
generated
|
|
@ -17,10 +17,10 @@ const uploadLib = __importStar(require("./upload-lib"));
|
|||
testing_utils_1.setupTests(ava_1.default);
|
||||
ava_1.default('validateSarifFileSchema - valid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/valid-sarif.sarif';
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger()));
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger(true)));
|
||||
});
|
||||
ava_1.default('validateSarifFileSchema - invalid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/invalid-sarif.sarif';
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger()));
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger(true)));
|
||||
});
|
||||
//# sourceMappingURL=upload-lib.test.js.map
|
||||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"upload-lib.test.js","sourceRoot":"","sources":["../src/upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AAEvB,uCAA4C;AAC5C,mDAA2C;AAC3C,wDAA0C;AAE1C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE;IAC1C,MAAM,SAAS,GAAG,SAAS,GAAG,oCAAoC,CAAC;IACnE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,EAAE,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,mCAAmC,EAAE,CAAC,CAAC,EAAE;IAC5C,MAAM,SAAS,GAAG,SAAS,GAAG,sCAAsC,CAAC;IACrE,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,EAAE,CAAC,CAAC,CAAC;AAClF,CAAC,CAAC,CAAC"}
|
||||
{"version":3,"file":"upload-lib.test.js","sourceRoot":"","sources":["../src/upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AAEvB,uCAA4C;AAC5C,mDAA2C;AAC3C,wDAA0C;AAE1C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE;IAC1C,MAAM,SAAS,GAAG,SAAS,GAAG,oCAAoC,CAAC;IACnE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,mCAAmC,EAAE,CAAC,CAAC,EAAE;IAC5C,MAAM,SAAS,GAAG,SAAS,GAAG,sCAAsC,CAAC;IACrE,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC,CAAC,CAAC"}
|
||||
|
|
@ -29,7 +29,7 @@ test('download codeql bundle cache', async t => {
|
|||
tmpDir,
|
||||
tmpDir,
|
||||
'runner',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
|
||||
t.assert(toolcache.find('CodeQL', `0.0.0-${version}`));
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ test('parse codeql bundle url version', t => {
|
|||
const url = `https://github.com/.../codeql-bundle-${version}/...`;
|
||||
|
||||
try {
|
||||
const parsedVersion = codeql.getCodeQLURLVersion(url, getRunnerLogger());
|
||||
const parsedVersion = codeql.getCodeQLURLVersion(url, getRunnerLogger(true));
|
||||
t.deepEqual(parsedVersion, expectedVersion);
|
||||
} catch (e) {
|
||||
t.fail(e.message);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ function mockListLanguages(languages: string[]) {
|
|||
|
||||
test("load empty config", async t => {
|
||||
return await util.withTmpDir(async tmpDir => {
|
||||
const logger = getRunnerLogger();
|
||||
const logger = getRunnerLogger(true);
|
||||
const languages = 'javascript,python';
|
||||
|
||||
const codeQL = setCodeQL({
|
||||
|
|
@ -84,7 +84,7 @@ test("load empty config", async t => {
|
|||
|
||||
test("loading config saves config", async t => {
|
||||
return await util.withTmpDir(async tmpDir => {
|
||||
const logger = getRunnerLogger();
|
||||
const logger = getRunnerLogger(true);
|
||||
|
||||
const codeQL = setCodeQL({
|
||||
resolveQueries: async function() {
|
||||
|
|
@ -139,7 +139,7 @@ test("load input outside of workspace", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getConfigFileOutsideWorkspaceErrorMessage(path.join(tmpDir, '../input'))));
|
||||
|
|
@ -164,7 +164,7 @@ test("load non-local input with invalid repo syntax", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getConfigFileRepoFormatInvalidMessage('octo-org/codeql-config@main')));
|
||||
|
|
@ -190,7 +190,7 @@ test("load non-existent input", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getConfigFileDoesNotExistErrorMessage(path.join(tmpDir, 'input'))));
|
||||
|
|
@ -262,7 +262,7 @@ test("load non-empty input", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
|
||||
// Should exactly equal the object we constructed earlier
|
||||
t.deepEqual(actualConfig, expectedConfig);
|
||||
|
|
@ -317,7 +317,7 @@ test("default queries are used", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
|
||||
// Check resolve queries was called correctly
|
||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||
|
|
@ -370,7 +370,7 @@ test("Queries can be specified in config file", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
|
||||
// Check resolveQueries was called correctly
|
||||
// It'll be called once for the default queries
|
||||
|
|
@ -434,7 +434,7 @@ test("Queries from config file can be overridden in workflow file", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
|
||||
// Check resolveQueries was called correctly
|
||||
// It'll be called once for the default queries and once for `./override`,
|
||||
|
|
@ -489,7 +489,7 @@ test("Multiple queries can be specified in workflow file, no config file require
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
|
||||
// Check resolveQueries was called correctly:
|
||||
// It'll be called once for the default queries,
|
||||
|
|
@ -539,7 +539,7 @@ test("Invalid queries in workflow file handled correctly", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
t.fail('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getQueryUsesInvalid(undefined, "foo/bar@v1@v3")));
|
||||
|
|
@ -597,7 +597,7 @@ test("API client used when reading remote config", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
t.assert(spyGetContents.called);
|
||||
});
|
||||
});
|
||||
|
|
@ -620,7 +620,7 @@ test("Remote config handles the case where a directory is provided", async t =>
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getConfigFileDirectoryGivenMessage(repoReference)));
|
||||
|
|
@ -648,7 +648,7 @@ test("Invalid format of remote config handled correctly", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getConfigFileFormatInvalidMessage(repoReference)));
|
||||
|
|
@ -672,7 +672,7 @@ test("No detected languages", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getNoLanguagesError()));
|
||||
|
|
@ -696,7 +696,7 @@ test("Unknown languages", async t => {
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(configUtils.getUnknownLanguagesError(['ruby', 'english'])));
|
||||
|
|
@ -738,7 +738,7 @@ function doInvalidInputTest(
|
|||
tmpDir,
|
||||
'token',
|
||||
'https://github.example.com',
|
||||
getRunnerLogger());
|
||||
getRunnerLogger(true));
|
||||
throw new Error('initConfig did not throw error');
|
||||
} catch (err) {
|
||||
t.deepEqual(err, new Error(expectedErrorMessageGenerator(inputFile)));
|
||||
|
|
@ -846,10 +846,10 @@ test('path validations', t => {
|
|||
const configFile = './.github/codeql/config.yml';
|
||||
|
||||
for (const path of validPaths) {
|
||||
t.truthy(configUtils.validateAndSanitisePath(path, propertyName, configFile, getRunnerLogger()));
|
||||
t.truthy(configUtils.validateAndSanitisePath(path, propertyName, configFile, getRunnerLogger(true)));
|
||||
}
|
||||
for (const path of invalidPaths) {
|
||||
t.throws(() => configUtils.validateAndSanitisePath(path, propertyName, configFile, getRunnerLogger()));
|
||||
t.throws(() => configUtils.validateAndSanitisePath(path, propertyName, configFile, getRunnerLogger(true)));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -860,11 +860,11 @@ test('path sanitisation', t => {
|
|||
|
||||
// Valid paths are not modified
|
||||
t.deepEqual(
|
||||
configUtils.validateAndSanitisePath('foo/bar', propertyName, configFile, getRunnerLogger()),
|
||||
configUtils.validateAndSanitisePath('foo/bar', propertyName, configFile, getRunnerLogger(true)),
|
||||
'foo/bar');
|
||||
|
||||
// Trailing stars are stripped
|
||||
t.deepEqual(
|
||||
configUtils.validateAndSanitisePath('foo/**', propertyName, configFile, getRunnerLogger()),
|
||||
configUtils.validateAndSanitisePath('foo/**', propertyName, configFile, getRunnerLogger(true)),
|
||||
'foo/');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ test('hash', (t: ava.Assertions) => {
|
|||
function testResolveUriToFile(uri: any, index: any, artifactsURIs: any[]) {
|
||||
const location = { "uri": uri, "index": index };
|
||||
const artifacts = artifactsURIs.map(uri => ({ "location": { "uri": uri } }));
|
||||
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), getRunnerLogger());
|
||||
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), getRunnerLogger(true));
|
||||
}
|
||||
|
||||
test('resolveUriToFile', t => {
|
||||
|
|
@ -173,7 +173,7 @@ test('addFingerprints', t => {
|
|||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(__dirname + '/../src/testdata');
|
||||
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, getRunnerLogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, getRunnerLogger(true)), expected);
|
||||
});
|
||||
|
||||
test('missingRegions', t => {
|
||||
|
|
@ -188,5 +188,5 @@ test('missingRegions', t => {
|
|||
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||
const checkoutPath = path.normalize(__dirname + '/../src/testdata');
|
||||
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, getRunnerLogger()), expected);
|
||||
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, getRunnerLogger(true)), expected);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ export function getActionsLogger(): Logger {
|
|||
return core;
|
||||
}
|
||||
|
||||
export function getRunnerLogger(): Logger {
|
||||
export function getRunnerLogger(debugMode: boolean): Logger {
|
||||
return {
|
||||
debug: console.debug,
|
||||
debug: debugMode ? console.debug : () => undefined,
|
||||
info: console.info,
|
||||
warning: console.warn,
|
||||
error: console.error,
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ function checkEnvironmentSetup(config: Config) {
|
|||
}
|
||||
}
|
||||
|
||||
const logger = getRunnerLogger();
|
||||
|
||||
interface InitArgs {
|
||||
languages: string | undefined;
|
||||
queries: string | undefined;
|
||||
|
|
@ -78,6 +76,7 @@ interface InitArgs {
|
|||
repository: string;
|
||||
githubUrl: string;
|
||||
githubAuth: string;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
program
|
||||
|
|
@ -93,7 +92,9 @@ program
|
|||
.option('--temp-dir <dir>', 'Directory to use for temporary files. By default will use current working directory.')
|
||||
.option('--tools-dir <dir>', 'Directory to use for CodeQL tools and other files to store between runs. By default will use home directory.')
|
||||
.option('--checkout-path <path>', 'Checkout path (default: current working directory)')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd: InitArgs) => {
|
||||
const logger = getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const tempDir = getTempDir(cmd.tempDir);
|
||||
const toolsDir = getToolsDir(cmd.toolsDir);
|
||||
|
|
@ -174,6 +175,7 @@ program
|
|||
interface AutobuildArgs {
|
||||
language: string;
|
||||
tempDir: string | undefined;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
program
|
||||
|
|
@ -181,7 +183,9 @@ program
|
|||
.description('Attempts to automatically build code')
|
||||
.option('--language <language>', 'The language to build. By default will try to detect the dominant language.')
|
||||
.option('--temp-dir <dir>', 'Directory to use for temporary files. By default will use current working directory.')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd: AutobuildArgs) => {
|
||||
const logger = getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const config = await getConfig(getTempDir(cmd.tempDir), logger);
|
||||
checkEnvironmentSetup(config);
|
||||
|
|
@ -215,6 +219,7 @@ interface AnalyzeArgs {
|
|||
upload: boolean;
|
||||
outputDir: string | undefined;
|
||||
tempDir: string | undefined;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
program
|
||||
|
|
@ -229,7 +234,9 @@ program
|
|||
.option('--no-upload', 'Do not upload results after analysis', false)
|
||||
.option('--output-dir <dir>', 'Directory to output SARIF files to. By default will use temp directory.')
|
||||
.option('--temp-dir <dir>', 'Directory to use for temporary files. By default will use current working directory.')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd: AnalyzeArgs) => {
|
||||
const logger = getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const tempDir = getTempDir(cmd.tempDir);
|
||||
const outputDir = cmd.outputDir || path.join(tempDir, 'codeql-sarif');
|
||||
|
|
@ -266,6 +273,7 @@ interface UploadArgs {
|
|||
githubUrl: string;
|
||||
githubAuth: string;
|
||||
checkoutPath: string | undefined;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
program
|
||||
|
|
@ -278,7 +286,9 @@ program
|
|||
.requiredOption('--github-url <url>', 'URL of GitHub instance')
|
||||
.requiredOption('--github-auth <auth>', 'GitHub Apps token, or of the form "username:token" if using a personal access token')
|
||||
.option('--checkout-path <path>', 'Checkout path (default: current working directory)')
|
||||
.option('--debug', 'Print more verbose output', false)
|
||||
.action(async (cmd: UploadArgs) => {
|
||||
const logger = getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
await upload_lib.upload(
|
||||
cmd.sarifFile,
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ setupTests(test);
|
|||
|
||||
test('validateSarifFileSchema - valid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/valid-sarif.sarif';
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger()));
|
||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger(true)));
|
||||
});
|
||||
|
||||
test('validateSarifFileSchema - invalid', t => {
|
||||
const inputFile = __dirname + '/../src/testdata/invalid-sarif.sarif';
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger()));
|
||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, getRunnerLogger(true)));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue