Setup python extractor for installed deps
This commit is contained in:
parent
8cea21575c
commit
52274f1815
3 changed files with 66 additions and 2 deletions
26
lib/analyze.js
generated
26
lib/analyze.js
generated
|
|
@ -7,6 +7,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||
|
|
@ -15,6 +16,28 @@ const languages_1 = require("./languages");
|
|||
const sharedEnv = __importStar(require("./shared-environment"));
|
||||
const upload_lib = __importStar(require("./upload-lib"));
|
||||
const util = __importStar(require("./util"));
|
||||
async function setupPythonExtractor(logger) {
|
||||
const codeqlPython = process.env["CODEQL_PYTHON"];
|
||||
if (codeqlPython === undefined || codeqlPython.length === 0) {
|
||||
// If CODEQL_PYTHON is not set, no dependencies were installed, so we don't need to do anything
|
||||
return;
|
||||
}
|
||||
let output = '';
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
output += data.toString();
|
||||
}
|
||||
}
|
||||
};
|
||||
await new toolrunnner.ToolRunner(codeqlPython, ['-c', 'import os; import pip; print(os.path.dirname(os.path.dirname(pip.__file__)))'], options).exec();
|
||||
logger.info('Setting LGTM_INDEX_IMPORT_PATH=' + output);
|
||||
process.env['LGTM_INDEX_IMPORT_PATH'] = output;
|
||||
output = '';
|
||||
await new toolrunnner.ToolRunner(codeqlPython, ['-c', 'import sys; print(sys.version_info[0])'], options).exec();
|
||||
logger.info('Setting LGTM_PYTHON_SETUP_VERSION=' + output);
|
||||
process.env['LGTM_PYTHON_SETUP_VERSION'] = output;
|
||||
}
|
||||
async function createdDBForScannedLanguages(config, logger) {
|
||||
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
||||
// we extract any scanned languages.
|
||||
|
|
@ -23,6 +46,9 @@ async function createdDBForScannedLanguages(config, logger) {
|
|||
for (const language of config.languages) {
|
||||
if (languages_1.isScannedLanguage(language)) {
|
||||
logger.startGroup('Extracting ' + language);
|
||||
if (language === languages_1.Language.python) {
|
||||
await setupPythonExtractor(logger);
|
||||
}
|
||||
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config.tempDir, language), language);
|
||||
logger.endGroup();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue