From cc9c92bdf2cdbcaa4faa9be1ee406ca6b5d632d1 Mon Sep 17 00:00:00 2001 From: Ilona Shishov Date: Sun, 22 Oct 2023 17:07:42 +0300 Subject: [PATCH] feat: added MATCH_MANIFEST_VERSIONS to config and Exhort JS API request Signed-off-by: Ilona Shishov --- src/config.ts | 2 ++ src/server.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index a8efc30a..074f4379 100644 --- a/src/config.ts +++ b/src/config.ts @@ -8,6 +8,7 @@ class Config { exhort_snyk_token: string; + match_manifest_versions: boolean; provide_fullstack_action: boolean; forbidden_licenses: Array; no_crypto: boolean; @@ -26,6 +27,7 @@ class Config constructor() { // TODO: this needs to be configurable this.exhort_snyk_token = process.env.SNYK_TOKEN || ''; + this.match_manifest_versions = (process.env.MATCH_MANIFEST_VERSIONS || '') === 'true'; this.provide_fullstack_action = (process.env.PROVIDE_FULLSTACK_ACTION || '') === 'true'; this.forbidden_licenses = []; this.no_crypto = false; diff --git a/src/server.ts b/src/server.ts index d8031007..5b5f39fd 100644 --- a/src/server.ts +++ b/src/server.ts @@ -62,6 +62,7 @@ connection.onInitialize((params): InitializeResult => { // Defining settings for Red Hat Dependency Analytics interface RedhatDependencyAnalyticsSettings { exhortSnykToken: string; + matchManifestVersions: boolean; mvnExecutable: string; npmExecutable: string; goExecutable: string; @@ -74,6 +75,7 @@ interface RedhatDependencyAnalyticsSettings { // Initializing default settings for Red Hat Dependency Analytics const defaultSettings: RedhatDependencyAnalyticsSettings = { exhortSnykToken: config.exhort_snyk_token, + matchManifestVersions: config.match_manifest_versions, mvnExecutable: config.mvn_executable, npmExecutable: config.npm_executable, goExecutable: config.go_executable, @@ -211,7 +213,8 @@ const fetchVulnerabilities = async (fileType: string, reqData: any) => { 'EXHORT_PIP_PATH': globalSettings.pipExecutable, 'EXHORT_DEV_MODE': config.exhort_dev_mode, 'RHDA_TOKEN': config.telemetry_id, - 'RHDA_SOURCE': config.utm_source + 'RHDA_SOURCE': config.utm_source, + 'MATCH_MANIFEST_VERSIONS': globalSettings.matchManifestVersions }; if (globalSettings.exhortSnykToken !== '') { options['EXHORT_SNYK_TOKEN'] = globalSettings.exhortSnykToken; @@ -368,6 +371,7 @@ connection.onDidChangeConfiguration(() => { // Updating global settings based on the fetched configuration data. globalSettings = ({ exhortSnykToken: data.redHatDependencyAnalytics.exhortSnykToken, + matchManifestVersions: data.redHatDependencyAnalytics.matchManifestVersions, mvnExecutable: data.mvn.executable.path || 'mvn', npmExecutable: data.npm.executable.path || 'npm', goExecutable: data.go.executable.path || 'go',