Commit 555c516a authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'bug-dependency-path-iid' into 'master'

Prevent augmenting for orphan dependencies

See merge request gitlab-org/gitlab!47321
parents f0e075d2 4d180e42
...@@ -51,7 +51,7 @@ module Gitlab ...@@ -51,7 +51,7 @@ module Gitlab
def augment_ancestors! def augment_ancestors!
@dependencies.each_value do |dep| @dependencies.each_value do |dep|
next unless dep.iid next unless dep.location[:ancestors]
next if dep.location[:top_level] next if dep.location[:top_level]
if dep.vulnerabilities.empty? if dep.vulnerabilities.empty?
......
...@@ -44,6 +44,19 @@ RSpec.describe Gitlab::Ci::Reports::DependencyList::Report do ...@@ -44,6 +44,19 @@ RSpec.describe Gitlab::Ci::Reports::DependencyList::Report do
expect(ancestors.last).to eq({ name: direct[:name], version: direct[:version] }) expect(ancestors.last).to eq({ name: direct[:name], version: direct[:version] })
end end
context 'when dependency path info is not full' do
let(:orphan_dependency) { build :dependency, :with_vulnerabilities, iid: 3 }
before do
report.add_dependency(orphan_dependency)
end
it 'returns array of hashes' do
expect(dependencies).to be_an(Array)
expect(dependencies.first).to be_a(Hash)
end
end
context 'with multiple dependency files matching same package manager' do context 'with multiple dependency files matching same package manager' do
let(:indirect_other) { build :dependency, :with_vulnerabilities, iid: 32 } let(:indirect_other) { build :dependency, :with_vulnerabilities, iid: 32 }
let(:direct_other) { build :dependency, :direct, :with_vulnerabilities } let(:direct_other) { build :dependency, :direct, :with_vulnerabilities }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment