async function runQueries(codeqlCmd, databaseFolder, sarifFolder, config) {
    const queriesPerLanguage = await resolveQueryLanguages(codeqlCmd, config);
    for (let database of fs.readdirSync(databaseFolder)) {
        core.startGroup('Analyzing ' + database);
        const queries = queriesPerLanguage[database] || [];
        if (queries.length === 0) {
            throw new Error('Unable to analyse ' + database + ' as no queries were selected for this language');
        }
        // Pass the queries to codeql using a file instead of using the command
        // line to avoid command line length restrictions, particularly on windows.
        const querySuite = path.join(databaseFolder, database + '-queries.qls');
        const querySuiteContents = queries.map(q => '- query: ' + q).join('\n');
        fs.writeFileSync(querySuite, querySuiteContents);
        core.debug('Query suite file for ' + database + '...\n' + querySuiteContents);
        const sarifFile = path.join(sarifFolder, database + '.sarif');
        await exec.exec(codeqlCmd, [
            'database',
            'analyze',
            util.getMemoryFlag(),
            util.getThreadsFlag(),
            path.join(databaseFolder, database),
            '--format=sarif-latest',
            '--output=' + sarifFile,
            '--no-sarif-add-snippets',
            querySuite
        ]);
        core.debug('SARIF results for database ' + database + ' created at "' + sarifFile + '"');
        core.endGroup();
    }
}
// Runs queries and creates sarif files in the given folder
Runs queries and creates sarif files in the given folder
Runs queries and creates sarif files in the given folder
async function runQueries(codeqlCmd, databaseFolder, sarifFolder, config) {
    const queriesPerLanguage = await resolveQueryLanguages(codeqlCmd, config);
    for (let database of fs.readdirSync(databaseFolder)) {
        core.startGroup('Analyzing ' + database);
        const queries = queriesPerLanguage[database] || [];
        if (queries.length === 0) {
            throw new Error('Unable to analyse ' + database + ' as no queries were selected for this language');
        }
        const querySuite = path.join(databaseFolder, database + '-queries.qls');
        const querySuiteContents = queries.map(q => '- query: ' + q).join('\n');
        fs.writeFileSync(querySuite, querySuiteContents);
        core.debug('Query suite file for ' + database + '...\n' + querySuiteContents);
        const sarifFile = path.join(sarifFolder, database + '.sarif');
        await exec.exec(codeqlCmd, [
            'database',
            'analyze',
            util.getMemoryFlag(),
            util.getThreadsFlag(),
            path.join(databaseFolder, database),
            '--format=sarif-latest',
            '--output=' + sarifFile,
            '--no-sarif-add-snippets',
            querySuite
        ]);
        core.debug('SARIF results for database ' + database + ' created at "' + sarifFile + '"');
        core.endGroup();
    }
}
async function runQueries ( codeqlCmd , databaseFolder , sarifFolder , config ) { const queriesPerLanguage = await resolveQueryLanguages ( codeqlCmd , config ) ; for ( let database of fs . readdirSync ( databaseFolder ) ) { core . startGroup ( 'Analyzing ' + database ) ; const queries = queriesPerLanguage [ database ] || [ ] ; if ( queries . length === 0 ) { throw new Error ( 'Unable to analyse ' + database + ' as no queries were selected for this language' ) ; } const querySuite = path . join ( databaseFolder , database + '-queries.qls' ) ; const querySuiteContents = queries . map ( q => '- query: ' + q ) . join ( '\n' ) ; fs . writeFileSync ( querySuite , querySuiteContents ) ; core . debug ( 'Query suite file for ' + database + '...\n' + querySuiteContents ) ; const sarifFile = path . join ( sarifFolder , database + '.sarif' ) ; await exec . exec ( codeqlCmd , [ 'database' , 'analyze' , util . getMemoryFlag ( ) , util . getThreadsFlag ( ) , path . join ( databaseFolder , database ) , '--format=sarif-latest' , '--output=' + sarifFile , '--no-sarif-add-snippets' , querySuite ] ) ; core . debug ( 'SARIF results for database ' + database + ' created at "' + sarifFile + '"' ) ; core . endGroup ( ) ; } }
Runs queries and creates sarif files in the given folder
Runs queries and creates sarif files in the given folder
// Pass the queries to codeql using a file instead of using the command // line to avoid command line length restrictions, particularly on windows.