summaryrefslogtreecommitdiff
path: root/lib/license
diff options
context:
space:
mode:
authorCan Eldem <celdem@gitlab.com>2020-05-06 11:42:04 +0000
committerCan Eldem <celdem@gitlab.com>2020-05-06 11:42:04 +0000
commit6b40d051f8325ea957e60fc37abe26e97c5de2b6 (patch)
treef64e2d51b783c339609958de8af3564ecc92e632 /lib/license
parent8e427c7987e90a028e6d9f344a9f70bb13b6eee4 (diff)
parentb963d8d572fdf93d9c76e45d400465d8c5c2fae0 (diff)
Merge branch '212921-offline-npm' into 'master'v3.8.0
Specify a custom CA for npm See merge request gitlab-org/security-products/license-management!145
Diffstat (limited to 'lib/license')
-rw-r--r--lib/license/finder/ext/npm.rb8
-rw-r--r--lib/license/management/shell.rb9
-rw-r--r--lib/license/management/version.rb2
3 files changed, 15 insertions, 4 deletions
diff --git a/lib/license/finder/ext/npm.rb b/lib/license/finder/ext/npm.rb
index 75c0855..48741f9 100644
--- a/lib/license/finder/ext/npm.rb
+++ b/lib/license/finder/ext/npm.rb
@@ -16,7 +16,7 @@ module LicenseFinder
def prepare
Dir.chdir(project_path) do
- shell.execute("#{prepare_command} --production")
+ shell.execute("#{prepare_command} --production", env: default_env)
end
end
@@ -32,5 +32,11 @@ module LicenseFinder
end
status.success? ? JSON.parse(stdout) : {}
end
+
+ def default_env
+ return {} unless shell.custom_certificate_installed?
+
+ { 'NPM_CONFIG_CAFILE' => ENV.fetch('NPM_CONFIG_CAFILE', shell.custom_certificate_path.to_s) }
+ end
end
end
diff --git a/lib/license/management/shell.rb b/lib/license/management/shell.rb
index 9ff59c4..9053a3f 100644
--- a/lib/license/management/shell.rb
+++ b/lib/license/management/shell.rb
@@ -48,6 +48,7 @@ module License
Dir.glob('custom.*.crt').each do |path|
full_path = File.expand_path(path)
execute([:openssl, :x509, '-in', full_path, '-text', '-noout'])
+ keystore_path = "#{ENV['JAVA_HOME']}/jre/lib/security/cacerts"
execute([
:keytool,
'-importcert',
@@ -56,9 +57,13 @@ module License
'-trustcacerts',
'-noprompt',
'-storepass', 'changeit',
- '-keystore', "#{ENV['JAVA_HOME']}/jre/lib/security/cacerts"
+ '-keystore', keystore_path
+ ])
+ execute([
+ :keytool, '-list', '-v',
+ '-storepass changeit',
+ '-keystore', keystore_path
])
- execute(["keytool -list -v -storepass changeit"])
end
end
end
diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb
index cfb570e..881fa37 100644
--- a/lib/license/management/version.rb
+++ b/lib/license/management/version.rb
@@ -2,6 +2,6 @@
module License
module Management
- VERSION = '3.7.6'
+ VERSION = '3.8.0'
end
end