Skip to content

Commit b8f39fe

Browse files
committed
Use features properly in setupPythonExtractor
1 parent eb8a706 commit b8f39fe

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

src/analyze-action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ async function run() {
237237
threads,
238238
memory,
239239
config,
240-
logger
240+
logger,
241+
features
241242
);
242243

243244
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {

src/analyze.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { DatabaseCreationTimings } from "./actions-util";
1010
import * as analysisPaths from "./analysis-paths";
1111
import { CodeQL, getCodeQL } from "./codeql";
1212
import * as configUtils from "./config-utils";
13-
import { FeatureEnablement } from "./feature-flags";
13+
import { FeatureEnablement, Feature } from "./feature-flags";
1414
import { isScannedLanguage, Language } from "./languages";
1515
import { Logger } from "./logging";
1616
import { endTracingForCluster } from "./tracer-config";
@@ -80,23 +80,20 @@ export interface QueriesStatusReport {
8080
analyze_failure_language?: string;
8181
}
8282

83-
async function setupPythonExtractor(logger: Logger) {
83+
async function setupPythonExtractor(logger: Logger, features: FeatureEnablement, codeql: CodeQL) {
8484
const codeqlPython = process.env["CODEQL_PYTHON"];
8585
if (codeqlPython === undefined || codeqlPython.length === 0) {
8686
// If CODEQL_PYTHON is not set, no dependencies were installed, so we don't need to do anything
8787
return;
8888
}
8989

90-
// CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION is the internal environment
91-
// variable used by the python extractor. This is set in init-action.ts only if the
92-
// feature-flag is enabled.
93-
if (
94-
(process.env["CODEQL_EXTRACTOR_PYTHON_DISABLE_LIBRARY_EXTRACTION"] || "")
95-
.length > 0
96-
) {
90+
if (await features.getValue(
91+
Feature.DisablePythonDependencyInstallation,
92+
codeql
93+
)) {
9794
logger.warning(
9895
"Library extraction is disabled now. Please remove your logic that sets the CODEQL_PYTHON environment variable." +
99-
"\nIf you used CODEQL_PYTHON to force the version of Python to analyze as, please use CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION instead, such as CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION=2.7 or CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION=3.11."
96+
"\nIf you used CODEQL_PYTHON to force the version of Python to analyze as, please use CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION instead, such as CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION=2.7 or CODEQL_EXTRACTOR_PYTHON_ANALYSIS_VERSION=3.11."
10097
);
10198
return;
10299
}
@@ -133,7 +130,8 @@ async function setupPythonExtractor(logger: Logger) {
133130
export async function createdDBForScannedLanguages(
134131
codeql: CodeQL,
135132
config: configUtils.Config,
136-
logger: Logger
133+
logger: Logger,
134+
features: FeatureEnablement
137135
) {
138136
// Insert the LGTM_INDEX_X env vars at this point so they are set when
139137
// we extract any scanned languages.
@@ -147,7 +145,7 @@ export async function createdDBForScannedLanguages(
147145
logger.startGroup(`Extracting ${language}`);
148146

149147
if (language === Language.python) {
150-
await setupPythonExtractor(logger);
148+
await setupPythonExtractor(logger, features, codeql);
151149
}
152150

153151
await codeql.extractScannedLanguage(config, language);
@@ -179,12 +177,13 @@ async function finalizeDatabaseCreation(
179177
config: configUtils.Config,
180178
threadsFlag: string,
181179
memoryFlag: string,
182-
logger: Logger
180+
logger: Logger,
181+
features: FeatureEnablement
183182
): Promise<DatabaseCreationTimings> {
184183
const codeql = await getCodeQL(config.codeQLCmd);
185184

186185
const extractionStart = performance.now();
187-
await createdDBForScannedLanguages(codeql, config, logger);
186+
await createdDBForScannedLanguages(codeql, config, logger, features);
188187
const extractionTime = performance.now() - extractionStart;
189188

190189
const trapImportStart = performance.now();
@@ -488,7 +487,8 @@ export async function runFinalize(
488487
threadsFlag: string,
489488
memoryFlag: string,
490489
config: configUtils.Config,
491-
logger: Logger
490+
logger: Logger,
491+
features: FeatureEnablement
492492
): Promise<DatabaseCreationTimings> {
493493
try {
494494
await del(outputDir, { force: true });
@@ -503,7 +503,8 @@ export async function runFinalize(
503503
config,
504504
threadsFlag,
505505
memoryFlag,
506-
logger
506+
logger,
507+
features
507508
);
508509

509510
// WARNING: This does not _really_ end tracing, as the tracer will restore its

0 commit comments

Comments
 (0)