summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-05-22 15:48:21 +0000
committerCan Eldem <celdem@gitlab.com>2020-05-22 15:48:21 +0000
commitef80bee8d1f97830449132afd1a4514c1d9d145b (patch)
tree93a45ec7990788dcff4c1c18a29920698889e593
parent7e044195b5148b1b9ecbb92d88eb2e4c57a3d81b (diff)
Add functional tests to the pipeline
* Move jobs to gitlab-ci.yml files that match the stage they belong to. * Move linter job to build stage * Add functional test jobs * Reduce max size to 2 GB * Pass the current pipeline image to the downstream jobs * Replace `edge` tag with `latest` * Use $CI_DEFAULT_BRANCH instead of master * Move `.env*` files to config dir and update RELEASE instructions * Combine `tag` and `release` stages into `deploy` stage as recommended in GitLab docs * Make the `build-docker-image` job interruptible * Fix issues found in code quality report
-rw-r--r--.dockerignore1
-rw-r--r--.gitlab-ci.yml77
-rw-r--r--.gitlab/build.yml29
-rw-r--r--.gitlab/deploy.yml172
-rw-r--r--.gitlab/release.yml139
-rw-r--r--.gitlab/test.yml68
-rw-r--r--README.md16
-rw-r--r--config/.env.12-10-stable (renamed from .env.12-10-stable)0
-rw-r--r--config/.env.12-2-stable (renamed from .env.12-2-stable)0
-rw-r--r--config/.env.12-3-stable (renamed from .env.12-3-stable)0
-rw-r--r--config/.env.12-4-stable (renamed from .env.12-4-stable)0
-rw-r--r--config/.env.12-5-stable (renamed from .env.12-5-stable)0
-rw-r--r--config/.env.12-6-stable (renamed from .env.12-6-stable)0
-rw-r--r--config/.env.12-7-stable (renamed from .env.12-7-stable)0
-rw-r--r--config/.env.12-8-stable (renamed from .env.12-8-stable)0
-rw-r--r--config/.env.12-9-stable (renamed from .env.12-9-stable)0
-rw-r--r--config/.env.13-0-stable (renamed from .env.13-0-stable)0
-rw-r--r--config/.env.legacy (renamed from .env.legacy)0
-rw-r--r--lib/license/finder/ext/go_modules.rb24
-rw-r--r--lib/license/management/shell.rb51
-rw-r--r--spec/fixtures/expected/js/bower/v1.0.json159
-rw-r--r--spec/fixtures/expected/js/bower/v1.1.json232
-rw-r--r--spec/fixtures/expected/js/bower/v2.0.json150
-rw-r--r--spec/integration/js/bower_spec.rb2
24 files changed, 852 insertions, 268 deletions
diff --git a/.dockerignore b/.dockerignore
index 3038e1a..22b59c0 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -5,3 +5,4 @@ Dockerfile
spec
tags
tmp
+config/.env*
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 63c89d8..b5bdcc9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,21 +3,21 @@
variables:
DOCKER_DRIVER: overlay2
MAJOR: 3
- TMP_IMAGE: $CI_REGISTRY_IMAGE/tmp:$CI_COMMIT_SHA
+ TMP_IMAGE: $CI_REGISTRY_IMAGE/license-finder:$CI_COMMIT_SHA
include:
- template: Container-Scanning.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: Jobs/Code-Quality.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
+ - local: .gitlab/build.yml
- local: .gitlab/test.yml
- - local: .gitlab/release.yml
+ - local: .gitlab/deploy.yml
stages:
- build
- test
- - tag
- - release
+ - deploy
default:
image:
@@ -25,76 +25,9 @@ default:
entrypoint: [""]
tags: [gitlab-org]
-build commit:
- image: docker:stable
- stage: build
- tags: [gitlab-org-docker]
- services:
- - docker:stable-dind
- script:
- - docker info
- - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- - docker pull $CI_REGISTRY_IMAGE:latest || true
- - docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $TMP_IMAGE .
- - docker image inspect $TMP_IMAGE --format='{{.Size}}'
- - docker push $TMP_IMAGE
-
-build mvn:
- image: maven:3.3.9-jdk-8
- stage: build
- script:
- - cd spec/fixtures/java/example/ && mvn deploy -s settings.xml
- allow_failure: true
-
container_scanning:
variables:
- CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE/tmp # only predefined variables are parameter-expanded (no $TMP_IMAGE)
-
-.docker_tag:
- image: docker:stable
- stage: tag
- tags: [gitlab-org-docker]
- services:
- - docker:stable-dind
- script:
- - docker info
- - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- - export SOURCE_IMAGE=$TMP_IMAGE
- - export TARGET_IMAGE=$CI_REGISTRY_IMAGE:${IMAGE_TAG:-$CI_JOB_NAME}
- - |
- if [ -z "$DOTENV" ]; then
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- else
- ./bin/docker-dotenv
- fi
- - docker push $TARGET_IMAGE
-
-branch:
- extends: .docker_tag
- variables:
- IMAGE_TAG: $CI_COMMIT_REF_SLUG
- only:
- - branches
- except:
- - master
-
-edge:
- extends: .docker_tag
- variables:
- IMAGE_TAG: edge
- only:
- - master
-
-version:
- extends: .docker_tag
- before_script:
- - export IMAGE_TAG=${CI_COMMIT_TAG/v/}
- - echo "Checking that $CI_COMMIT_TAG is last in the changelog"
- - test "$(grep '^## v' CHANGELOG.md |head -n 1)" = "## $CI_COMMIT_TAG"
- only:
- - tags
- allow_failure: false
+ CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE/license-finder # only predefined variables are parameter-expanded (no $TMP_IMAGE)
code_quality:
before_script:
diff --git a/.gitlab/build.yml b/.gitlab/build.yml
new file mode 100644
index 0000000..772bde3
--- /dev/null
+++ b/.gitlab/build.yml
@@ -0,0 +1,29 @@
+build-docker-image:
+ image: docker:stable
+ interruptible: true
+ stage: build
+ tags: [gitlab-org-docker]
+ services:
+ - docker:stable-dind
+ script:
+ - docker info
+ - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+ - docker pull $CI_REGISTRY_IMAGE:latest || true
+ - docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $TMP_IMAGE .
+ - docker image inspect $TMP_IMAGE --format='{{.Size}}'
+ - docker push $TMP_IMAGE
+
+build-mvn-pkg:
+ image: maven:3.3.9-jdk-8
+ stage: build
+ script:
+ - cd spec/fixtures/java/example/ && mvn deploy -s settings.xml
+ allow_failure: true
+
+lint:
+ stage: build
+ image: ruby:alpine
+ script:
+ - apk add build-base shellcheck
+ - bin/setup
+ - bin/lint
diff --git a/.gitlab/deploy.yml b/.gitlab/deploy.yml
new file mode 100644
index 0000000..22c8633
--- /dev/null
+++ b/.gitlab/deploy.yml
@@ -0,0 +1,172 @@
+.docker_tag:
+ image: docker:stable
+ stage: deploy
+ tags: [gitlab-org-docker]
+ services:
+ - docker:stable-dind
+ script:
+ - docker info
+ - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
+ - export SOURCE_IMAGE=$TMP_IMAGE
+ - export TARGET_IMAGE=$CI_REGISTRY_IMAGE:${IMAGE_TAG:-$CI_JOB_NAME}
+ - |
+ if [ -z "$DOTENV" ]; then
+ docker pull $SOURCE_IMAGE
+ docker tag $SOURCE_IMAGE $TARGET_IMAGE
+ else
+ ./bin/docker-dotenv
+ fi
+ - docker push $TARGET_IMAGE
+
+latest:
+ extends: .docker_tag
+ variables:
+ IMAGE_TAG: latest
+ only:
+ - $CI_DEFAULT_BRANCH
+
+version:
+ extends: .docker_tag
+ before_script:
+ - export IMAGE_TAG=${CI_COMMIT_TAG/v/}
+ - echo "Checking that $CI_COMMIT_TAG is last in the changelog"
+ - test "$(grep '^## v' CHANGELOG.md |head -n 1)" = "## $CI_COMMIT_TAG"
+ only:
+ - tags
+ allow_failure: false
+
+.release:
+ extends: .docker_tag
+ when: manual
+ only:
+ - tags
+ after_script:
+ # Also push to registry.gitlab.com/gitlab-org/security-products/analyzers/license-finder
+ - docker login -u gitlab-ci-token -p $GITLAB_TOKEN $CI_REGISTRY
+ - docker tag $TARGET_IMAGE registry.gitlab.com/gitlab-org/security-products/analyzers/license-finder:${IMAGE_TAG:-$CI_JOB_NAME}
+ - docker push registry.gitlab.com/gitlab-org/security-products/analyzers/license-finder:${IMAGE_TAG:-$CI_JOB_NAME}
+
+major:
+ extends: .release
+ variables:
+ IMAGE_TAG: $MAJOR
+
+13-0-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.13-0-stable"
+
+12-10-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-10-stable"
+
+12-9-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-9-stable"
+
+12-8-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-8-stable"
+
+12-7-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-7-stable"
+
+12-6-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-6-stable"
+
+12-5-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-5-stable"
+
+12-4-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-4-stable"
+
+12-3-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-3-stable"
+
+12-2-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.12-2-stable"
+
+12-1-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+12-0-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-11-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-10-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-9-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-8-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-7-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-6-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-5-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-4-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-3-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-2-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-1-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
+
+11-0-stable:
+ extends: .release
+ variables:
+ DOTENV: "config/.env.legacy"
diff --git a/.gitlab/release.yml b/.gitlab/release.yml
deleted file mode 100644
index c1ce426..0000000
--- a/.gitlab/release.yml
+++ /dev/null
@@ -1,139 +0,0 @@
-.release:
- extends: .docker_tag
- stage: release
- when: manual
- only:
- - tags
- after_script:
- # Also push to registry.gitlab.com/gitlab-org/security-products/analyzers/license-finder
- - docker login -u gitlab-ci-token -p $GITLAB_TOKEN $CI_REGISTRY
- - docker tag $TARGET_IMAGE registry.gitlab.com/gitlab-org/security-products/analyzers/license-finder:${IMAGE_TAG:-$CI_JOB_NAME}
- - docker push registry.gitlab.com/gitlab-org/security-products/analyzers/license-finder:${IMAGE_TAG:-$CI_JOB_NAME}
-
-major:
- extends: .release
- variables:
- IMAGE_TAG: $MAJOR
-
-latest:
- extends: .release
-
-13-0-stable:
- extends: .release
- variables:
- DOTENV: ".env.13-0-stable"
-
-12-10-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-10-stable"
-
-12-9-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-9-stable"
-
-12-8-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-8-stable"
-
-12-7-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-7-stable"
-
-12-6-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-6-stable"
-
-12-5-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-5-stable"
-
-12-4-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-4-stable"
-
-12-3-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-3-stable"
-
-12-2-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-2-stable"
-
-12-1-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-12-0-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-11-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-10-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-9-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-8-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-7-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-6-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-5-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-4-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-3-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-2-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-1-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
-
-11-0-stable:
- extends: .release
- variables:
- DOTENV: ".env.legacy"
diff --git a/.gitlab/test.yml b/.gitlab/test.yml
index d5c3d7d..fb0b723 100644
--- a/.gitlab/test.yml
+++ b/.gitlab/test.yml
@@ -1,14 +1,13 @@
size:
image: docker:stable
stage: test
- allow_failure: true # temporary until we can shrink the image size.
services:
- docker:stable-dind
tags: [gitlab-org-docker]
timeout: 3 minutes
variables:
GIT_STRATEGY: none
- MAX_SIZE: 2684354560
+ MAX_SIZE: 2147483648
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $TMP_IMAGE
@@ -18,14 +17,6 @@ size:
- echo $CURRENT_SIZE
- test "$MAX_SIZE" -gt "$CURRENT_SIZE"
-lint:
- stage: test
- image: ruby:alpine
- script:
- - apk add build-base shellcheck
- - bin/setup
- - bin/lint
-
.rspec:
stage: test
script:
@@ -86,3 +77,60 @@ integration-ruby:
extends: .rspec
variables:
RSPEC_DIR: spec/integration/ruby
+
+.functional:
+ stage: test
+ trigger: gitlab-org/security-products/tests/common
+ variables:
+ CONTAINER_SCANNING_DISABLED: 'true'
+ DAST_DISABLED: 'true'
+ DEPENDENCY_SCANNING_DISABLED: 'true'
+ LICENSE_MANAGEMENT_VERSION: $CI_COMMIT_SHA
+ SAST_DISABLED: 'true'
+ SECURE_ANALYZERS_PREFIX: $CI_REGISTRY_IMAGE
+ only:
+ - $CI_DEFAULT_BRANCH
+
+functional-csharp-nuget-dotnetcore:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/csharp-nuget-dotnetcore
+
+functional-go-modules:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/go-modules
+
+functional-java-maven-multimodules:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/java-maven-multimodules
+
+functional-java-maven:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/java-maven
+
+functional-js-bower:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/js-bower
+
+functional-js-npm:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/js-npm
+
+functional-js-yarn:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/js-yarn
+
+functional-ruby-bundler_js-yarn:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/ruby-bundler_js-yarn
+
+functional-php-composer:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/php-composer
+
+functional-python-pip:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/python-pip
+
+functional-ruby-bundler:
+ extends: .functional
+ trigger: gitlab-org/security-products/tests/ruby-bundler
diff --git a/README.md b/README.md
index d417cdc..172a4ed 100644
--- a/README.md
+++ b/README.md
@@ -114,22 +114,6 @@ or its shorthand form (`--env MY_SETTING_VAR`) if the configuration comes from a
## Versioning and release process
-1. Create a new entry in the `.gitlab/release.yml` file for the new version to release.
-
- ```yaml
- 12-x-stable:
- extends: .release
- variables:
- DOTENV: ".env.12-x-stable"
- ```
-
-2. Create a new `.env.*` that corresponds to the version to release and specify the default configuration.
-
- ```text
- LM_PYTHON_VERSION '3'
- LM_REPORT_VERSION '2.0'
- ```
-
Please check the [Release Process documentation](https://gitlab.com/gitlab-org/security-products/release/blob/master/docs/release_process.md).
## Upgrading to the latest version of LicenseFinder
diff --git a/.env.12-10-stable b/config/.env.12-10-stable
index 0ee1d53..0ee1d53 100644
--- a/.env.12-10-stable
+++ b/config/.env.12-10-stable
diff --git a/.env.12-2-stable b/config/.env.12-2-stable
index 835c645..835c645 100644
--- a/.env.12-2-stable
+++ b/config/.env.12-2-stable
diff --git a/.env.12-3-stable b/config/.env.12-3-stable
index 835c645..835c645 100644
--- a/.env.12-3-stable
+++ b/config/.env.12-3-stable
diff --git a/.env.12-4-stable b/config/.env.12-4-stable
index 79d7c86..79d7c86 100644
--- a/.env.12-4-stable
+++ b/config/.env.12-4-stable
diff --git a/.env.12-5-stable b/config/.env.12-5-stable
index 0ee1d53..0ee1d53 100644
--- a/.env.12-5-stable
+++ b/config/.env.12-5-stable
diff --git a/.env.12-6-stable b/config/.env.12-6-stable
index 0ee1d53..0ee1d53 100644
--- a/.env.12-6-stable
+++ b/config/.env.12-6-stable
diff --git a/.env.12-7-stable b/config/.env.12-7-stable
index 0ee1d53..0ee1d53 100644
--- a/.env.12-7-stable
+++ b/config/.env.12-7-stable
diff --git a/.env.12-8-stable b/config/.env.12-8-stable
index 0ee1d53..0ee1d53 100644
--- a/.env.12-8-stable
+++ b/config/.env.12-8-stable
diff --git a/.env.12-9-stable b/config/.env.12-9-stable
index 0ee1d53..0ee1d53 100644
--- a/.env.12-9-stable
+++ b/config/.env.12-9-stable
diff --git a/.env.13-0-stable b/config/.env.13-0-stable
index 0ee1d53..0ee1d53 100644
--- a/.env.13-0-stable
+++ b/config/.env.13-0-stable
diff --git a/.env.legacy b/config/.env.legacy
index 996bb9b..996bb9b 100644
--- a/.env.legacy
+++ b/config/.env.legacy
diff --git a/lib/license/finder/ext/go_modules.rb b/lib/license/finder/ext/go_modules.rb
index 9fdd263..3b9042e 100644
--- a/lib/license/finder/ext/go_modules.rb
+++ b/lib/license/finder/ext/go_modules.rb
@@ -12,24 +12,28 @@ module LicenseFinder
end
def current_packages
- stdout, _stderr, status = shell.execute([
- :go, :list, '-m', '-f', "'{{.Path}},{{.Version}},{{.Dir}}'", :all
- ])
+ stdout, _stderr, status = shell.execute(go_list_command)
return [] unless status.success?
- stdout.each_line.map do |line|
- name, version, dir = line.chomp.split(',')
- next if dir.nil?
- next if Pathname(dir).cleanpath == absolute_project_path
-
- Package.new(name, version, install_path: dir)
- end.compact
+ stdout.each_line.map { |line| map_from(line) }.compact
end
private
+ def go_list_command
+ [:go, :list, '-m', '-f', "'{{.Path}},{{.Version}},{{.Dir}}'", :all]
+ end
+
def absolute_project_path
@absolute_project_path ||= Pathname(project_path).cleanpath
end
+
+ def map_from(line)
+ name, version, dir = line.chomp.split(',')
+ return if dir.nil?
+ return if Pathname(dir).cleanpath == absolute_project_path
+
+ Package.new(name, version, install_path: dir)
+ end
end
end
diff --git a/lib/license/management/shell.rb b/lib/license/management/shell.rb
index 9053a3f..9ea66ca 100644
--- a/lib/license/management/shell.rb
+++ b/lib/license/management/shell.rb
@@ -9,7 +9,7 @@ module License
def initialize(logger: License::Management.logger, certificate: ENV['ADDITIONAL_CA_CERT_BUNDLE'])
@logger = logger
@custom_certificate_path = Pathname.new('/usr/local/share/ca-certificates/custom.crt')
- trust!(certificate)
+ trust!(certificate) if present?(certificate)
end
def execute(command, env: {})
@@ -18,8 +18,7 @@ module License
stdout, stderr, status = Open3.capture3(env, expanded_command)
- logger.debug(stdout) unless stdout.nil? || stdout.empty?
- logger.error(stderr) unless stderr.nil? || stderr.empty?
+ record(stdout, stderr)
[stdout, stderr, status]
end
@@ -38,8 +37,6 @@ module License
end
def trust!(certificate)
- return unless present?(certificate)
-
custom_certificate_path.write(certificate)
Dir.chdir custom_certificate_path.dirname do
execute([:awk, SPLIT_SCRIPT, '<', custom_certificate_path])
@@ -48,29 +45,41 @@ 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',
- '-alias', Time.now.to_i,
- '-file', full_path,
- '-trustcacerts',
- '-noprompt',
- '-storepass', 'changeit',
- '-keystore', keystore_path
- ])
- execute([
- :keytool, '-list', '-v',
- '-storepass changeit',
- '-keystore', keystore_path
- ])
+ execute(keytool_import_command(full_path))
+ execute(keytool_list_command)
end
end
end
+ def keytool_import_command(file_path)
+ [
+ :keytool,
+ '-importcert',
+ '-alias', Time.now.to_i,
+ '-file', file_path,
+ '-trustcacerts',
+ '-noprompt',
+ '-storepass', 'changeit',
+ '-keystore', keystore_path
+ ]
+ end
+
+ def keytool_list_command
+ [:keytool, '-list', '-v', '-storepass changeit', '-keystore', keystore_path]
+ end
+
+ def keystore_path
+ "#{ENV['JAVA_HOME']}/jre/lib/security/cacerts"
+ end
+
def present?(item)
!item.nil? && !item.empty?
end
+
+ def record(stdout, stderr)
+ logger.debug(stdout) if present?(stdout)
+ logger.error(stderr) if present?(stderr)
+ end
end
end
end
diff --git a/spec/fixtures/expected/js/bower/v1.0.json b/spec/fixtures/expected/js/bower/v1.0.json
new file mode 100644
index 0000000..cbffaa2
--- /dev/null
+++ b/spec/fixtures/expected/js/bower/v1.0.json
@@ -0,0 +1,159 @@
+{
+ "licenses": [
+ {
+ "count": 7,
+ "name": "MIT"
+ },
+ {
+ "count": 1,
+ "name": "ISC"
+ },
+ {
+ "count": 1,
+ "name": "New BSD, MIT, ISC, Apache 2.0"
+ },
+ {
+ "count": 1,
+ "name": "unknown"
+ }
+ ],
+ "dependencies": [
+ {
+ "license": {
+ "name": "New BSD, MIT, ISC, Apache 2.0",
+ "url": "http://en.wikipedia.org/wiki/ISC_license"
+ },
+ "dependency": {
+ "name": "cli",
+ "url": "https://github.com/npm/cli",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "ev-emitter",
+ "url": "https://github.com/metafizzy/ev-emitter",
+ "description": "lil' event emitter",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "fizzy-ui-utils",
+ "url": "https://github.com/metafizzy/fizzy-ui-utils",
+ "description": "UI utilities",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "get-size",
+ "url": "https://github.com/desandro/get-size",
+ "description": "measures element size",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "jquery",
+ "url": "https://github.com/jquery/jquery-dist",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "ISC",
+ "url": "http://en.wikipedia.org/wiki/ISC_license"
+ },
+ "dependency": {
+ "name": "js-bower",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "masonry-layout",
+ "url": "https://masonry.desandro.com",
+ "description": "Cascading grid layout library",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "matches-selector",
+ "url": "https://github.com/desandro/matches-selector",
+ "description": "matches/matchesSelector helper",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "outlayer",
+ "url": "https://github.com/metafizzy/outlayer",
+ "description": "the brains and guts of a layout library",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "license": {
+ "name": "unknown"
+ },
+ "dependency": {
+ "name": "stimulus.umd",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/spec/fixtures/expected/js/bower/v1.1.json b/spec/fixtures/expected/js/bower/v1.1.json
new file mode 100644
index 0000000..7351634
--- /dev/null
+++ b/spec/fixtures/expected/js/bower/v1.1.json
@@ -0,0 +1,232 @@
+{
+ "version": "1.1",
+ "licenses": [
+ {
+ "count": 7,
+ "name": "MIT"
+ },
+ {
+ "count": 1,
+ "name": "ISC"
+ },
+ {
+ "count": 1,
+ "name": "New BSD, MIT, ISC, Apache 2.0"
+ },
+ {
+ "count": 1,
+ "name": "unknown"
+ }
+ ],
+ "dependencies": [
+ {
+ "licenses": [
+ {
+ "name": "Apache 2.0",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0.txt"
+ },
+ {
+ "name": "ISC",
+ "url": "http://en.wikipedia.org/wiki/ISC_license"
+ },
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ {
+ "name": "New BSD",
+ "url": "http://opensource.org/licenses/BSD-3-Clause"
+ }
+ ],
+ "license": {
+ "name": "New BSD, MIT, ISC, Apache 2.0",
+ "url": "http://en.wikipedia.org/wiki/ISC_license"
+ },
+ "dependency": {
+ "name": "cli",
+ "url": "https://github.com/npm/cli",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ }
+ ],
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "ev-emitter",
+ "url": "https://github.com/metafizzy/ev-emitter",
+ "description": "lil' event emitter",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ }
+ ],
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "fizzy-ui-utils",
+ "url": "https://github.com/metafizzy/fizzy-ui-utils",
+ "description": "UI utilities",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ }
+ ],
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "get-size",
+ "url": "https://github.com/desandro/get-size",
+ "description": "measures element size",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ }
+ ],
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "jquery",
+ "url": "https://github.com/jquery/jquery-dist",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "ISC",
+ "url": "http://en.wikipedia.org/wiki/ISC_license"
+ }
+ ],
+ "license": {
+ "name": "ISC",
+ "url": "http://en.wikipedia.org/wiki/ISC_license"
+ },
+ "dependency": {
+ "name": "js-bower",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ }
+ ],
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "masonry-layout",
+ "url": "https://masonry.desandro.com",
+ "description": "Cascading grid layout library",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ }
+ ],
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "matches-selector",
+ "url": "https://github.com/desandro/matches-selector",
+ "description": "matches/matchesSelector helper",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ }
+ ],
+ "license": {
+ "name": "MIT",
+ "url": "http://opensource.org/licenses/mit-license"
+ },
+ "dependency": {
+ "name": "outlayer",
+ "url": "https://github.com/metafizzy/outlayer",
+ "description": "the brains and guts of a layout library",
+ "pathes": [
+ "."
+ ]
+ }
+ },
+ {
+ "licenses": [
+ {
+ "name": "unknown",
+ "url": ""
+ }
+ ],
+ "license": {
+ "name": "unknown"
+ },
+ "dependency": {
+ "name": "stimulus.umd",
+ "description": "",
+ "pathes": [
+ "."
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/spec/fixtures/expected/js/bower/v2.0.json b/spec/fixtures/expected/js/bower/v2.0.json
new file mode 100644
index 0000000..a8183e6
--- /dev/null
+++ b/spec/fixtures/expected/js/bower/v2.0.json
@@ -0,0 +1,150 @@
+{
+ "version": "2.0",
+ "licenses": [
+ {
+ "id": "MIT",
+ "name": "MIT License",
+ "url": "https://opensource.org/licenses/MIT",
+ "count": 8
+ },
+ {
+ "id": "ISC",
+ "name": "ISC License",
+ "url": "https://opensource.org/licenses/ISC",
+ "count": 2
+ },
+ {
+ "id": "Apache-2.0",
+ "name": "Apache License 2.0",
+ "url": "https://opensource.org/licenses/Apache-2.0",
+ "count": 1
+ },
+ {
+ "id": "BSD-3-Clause",
+ "name": "BSD 3-Clause \"New\" or \"Revised\" License",
+ "url": "https://opensource.org/licenses/BSD-3-Clause",
+ "count": 1
+ },
+ {
+ "id": "unknown",
+ "name": "unknown",
+ "url": "",
+ "count": 1
+ }
+ ],
+ "dependencies": [
+ {
+ "name": "cli",
+ "url": "https://github.com/npm/cli",
+ "description": "",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "Apache-2.0",
+ "BSD-3-Clause",
+ "ISC",
+ "MIT"
+ ]
+ },
+ {
+ "name": "ev-emitter",
+ "url": "https://github.com/metafizzy/ev-emitter",
+ "description": "lil' event emitter",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "MIT"
+ ]
+ },
+ {
+ "name": "fizzy-ui-utils",
+ "url": "https://github.com/metafizzy/fizzy-ui-utils",
+ "description": "UI utilities",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "MIT"
+ ]
+ },
+ {
+ "name": "get-size",
+ "url": "https://github.com/desandro/get-size",
+ "description": "measures element size",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "MIT"
+ ]
+ },
+ {
+ "name": "jquery",
+ "url": "https://github.com/jquery/jquery-dist",
+ "description": "",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "MIT"
+ ]
+ },
+ {
+ "name": "js-bower",
+ "url": "",
+ "description": "",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "ISC"
+ ]
+ },
+ {
+ "name": "masonry-layout",
+ "url": "https://masonry.desandro.com",
+ "description": "Cascading grid layout library",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "MIT"
+ ]
+ },
+ {
+ "name": "matches-selector",
+ "url": "https://github.com/desandro/matches-selector",
+ "description": "matches/matchesSelector helper",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "MIT"
+ ]
+ },
+ {
+ "name": "outlayer",
+ "url": "https://github.com/metafizzy/outlayer",
+ "description": "the brains and guts of a layout library",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "MIT"
+ ]
+ },
+ {
+ "name": "stimulus.umd",
+ "url": "",
+ "description": "",
+ "paths": [
+ "."
+ ],
+ "licenses": [
+ "unknown"
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/spec/integration/js/bower_spec.rb b/spec/integration/js/bower_spec.rb
index 2fe2883..e6d9012 100644
--- a/spec/integration/js/bower_spec.rb
+++ b/spec/integration/js/bower_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
RSpec.describe "bower" do
+ include_examples "each report version", "js", "bower"
+
context "when scanning a simple bower project" do
subject { runner.scan }