Skip to content

Commit edfe07d

Browse files
author
local
committed
Merge upstream master and resolve conflicts
2 parents d964d9e + a297e77 commit edfe07d

5 files changed

Lines changed: 190 additions & 13 deletions

File tree

.github/dependabot.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: bundler
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
cooldown:
8+
semver-major-days: 7
9+
semver-minor-days: 3
10+
semver-patch-days: 2
11+
default-days: 7
12+
13+
- package-ecosystem: github-actions
14+
directory: "/"
15+
groups:
16+
github-actions:
17+
patterns:
18+
- "*"
19+
schedule:
20+
interval: weekly
21+
cooldown:
22+
default-days: 7

.github/workflows/ruby.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
name: CI
22

3-
on: [ push, pull_request ]
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
types: [ opened, synchronize ]
8+
9+
permissions: {}
410

511
jobs:
612
tests:
713
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
816
strategy:
917
fail-fast: false
1018
matrix:
@@ -14,7 +22,6 @@ jobs:
1422
- '3.2'
1523
- '3.3'
1624
- '3.4'
17-
- '3.5'
1825
- '4.0'
1926
- jruby
2027
- truffleruby
@@ -25,15 +32,18 @@ jobs:
2532
rubygems_version: '3.6.9'
2633
name: Ruby ${{ matrix.ruby }}
2734
steps:
28-
- uses: actions/checkout@v2
35+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
36+
with:
37+
persist-credentials: false
2938
- name: Set up Ruby
30-
uses: ruby/setup-ruby@v1
39+
uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
3140
with:
3241
ruby-version: ${{ matrix.ruby }}
3342
- name: Update RubyGems
3443
env:
3544
RUBYGEMS_VERSION: ${{ matrix.rubygems_version }}
3645
run: |
46+
# shellcheck disable=SC2086 # empty version is intentional: no arg means update to latest
3747
gem update --system ${RUBYGEMS_VERSION:-}
3848
gem -v
3949
- name: Install dependencies
@@ -44,13 +54,36 @@ jobs:
4454
# rubocop linting
4555
rubocop:
4656
runs-on: ubuntu-latest
57+
permissions:
58+
contents: read
4759
steps:
48-
- uses: actions/checkout@v2
60+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
61+
with:
62+
persist-credentials: false
4963
- name: Set up Ruby
50-
uses: ruby/setup-ruby@v1
64+
uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
5165
with:
5266
ruby-version: 2.7
5367
- name: Install dependencies
5468
run: bundle install --jobs 4 --retry 3
5569
- name: Run rubocop
5670
run: bundle exec rubocop --parallel
71+
72+
lint-actions:
73+
name: GitHub Actions audit
74+
runs-on: ubuntu-latest
75+
permissions:
76+
contents: read
77+
78+
steps:
79+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
80+
with:
81+
persist-credentials: false
82+
83+
- name: Run actionlint
84+
uses: rhysd/actionlint@914e7df21a07ef503a81201c76d2b11c789d3fca # v1.7.12
85+
86+
- name: Run zizmor
87+
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
88+
with:
89+
advanced-security: false

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# bundler-audit
22

33
[![CI](https://github.com/rubysec/bundler-audit/actions/workflows/ruby.yml/badge.svg)](https://github.com/rubysec/bundler-audit/actions/workflows/ruby.yml)
4-
[![Code Climate](https://codeclimate.com/github/rubysec/bundler-audit.svg)](https://codeclimate.com/github/rubysec/bundler-audit)
54
[![Gem Version](https://badge.fury.io/rb/bundler-audit.svg)](https://badge.fury.io/rb/bundler-audit)
65

76
* [Homepage](https://github.com/rubysec/bundler-audit#readme)

spec/bundle/secure/Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ GEM
5959
marcel (1.0.2)
6060
method_source (1.0.0)
6161
mini_mime (1.1.2)
62-
mini_portile2 (2.8.0)
62+
mini_portile2 (2.8.9)
6363
minitest (5.17.0)
6464
nio4r (2.5.8)
65-
nokogiri (1.13.10)
66-
mini_portile2 (~> 2.8.0)
65+
nokogiri (1.19.3)
66+
mini_portile2 (~> 2.8.2)
6767
racc (~> 1.4)
68-
nokogiri (1.13.10-x86_64-linux)
68+
nokogiri (1.19.3-x86_64-linux-gnu)
6969
racc (~> 1.4)
70-
racc (1.6.1)
71-
rack (2.2.6.3)
70+
racc (1.8.1)
71+
rack (2.2.23)
7272
rack-test (1.1.0)
7373
rack (>= 1.0, < 3)
7474
rails (5.2.8)

spec/scanner_spec.rb

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,129 @@
1515
}.to raise_error(Scanner::InvalidGemfileLock,/is not a valid Gemfile\.lock/)
1616
end
1717
end
18+
19+
context "when given no arguments" do
20+
subject { described_class }
21+
22+
context "when a Gemfile.lock exists in Dir.pwd" do
23+
it "must default root to Dir.pwd" do
24+
Dir.chdir(directory) do
25+
scanner = subject.new
26+
expect(scanner.root).to eq(File.expand_path(Dir.pwd))
27+
end
28+
end
29+
end
30+
end
31+
32+
context "when given a root directory" do
33+
let(:root) { directory }
34+
35+
subject { described_class.new(root) }
36+
37+
it "must set #root to the expanded directory path" do
38+
expect(subject.root).to eq(File.expand_path(root))
39+
end
40+
41+
it "must set #database" do
42+
expect(subject.database).to be_kind_of(Database)
43+
end
44+
45+
it "must set #lockfile by parsing the Gemfile.lock" do
46+
expect(subject.lockfile).to be_kind_of(Bundler::LockfileParser)
47+
end
48+
49+
it "must set #config to a default Configuration when no config file exists" do
50+
expect(subject.config).to be_kind_of(Configuration)
51+
expect(subject.config.ignore).to be_empty
52+
end
53+
end
54+
55+
context "when the Gemfile.lock does not exist in the root directory" do
56+
let(:bad_dir) { File.join('spec','bundle','nonexistent') }
57+
58+
it "must raise Bundler::GemfileLockNotFound" do
59+
expect {
60+
described_class.new(bad_dir)
61+
}.to raise_error(Bundler::GemfileLockNotFound)
62+
end
63+
64+
it "must include the lock file name and root in the error message" do
65+
expect {
66+
described_class.new(bad_dir)
67+
}.to raise_error(Bundler::GemfileLockNotFound, /Gemfile\.lock/)
68+
end
69+
end
70+
71+
context "when given a custom gemfile_lock name" do
72+
it "must raise Bundler::GemfileLockNotFound if the custom lock file does not exist" do
73+
expect {
74+
described_class.new(directory, 'NoSuchLockFile.lock')
75+
}.to raise_error(Bundler::GemfileLockNotFound)
76+
end
77+
78+
it "must use the custom gemfile_lock name" do
79+
scanner = described_class.new(directory, 'Gemfile.lock')
80+
expect(scanner.lockfile).to be_kind_of(Bundler::LockfileParser)
81+
end
82+
end
83+
84+
context "when given a custom database" do
85+
let(:custom_db) { Database.new }
86+
87+
subject { described_class.new(directory, 'Gemfile.lock', custom_db) }
88+
89+
it "must set #database to the custom database" do
90+
expect(subject.database).to be(custom_db)
91+
end
92+
end
93+
94+
context "when a .bundler-audit.yml config file exists" do
95+
let(:bundle) { 'unpatched_gems_with_dot_configuration' }
96+
97+
subject { described_class.new(directory) }
98+
99+
it "must load the configuration from the config file" do
100+
expect(subject.config).to be_kind_of(Configuration)
101+
expect(subject.config.ignore).to include('OSVDB-89025')
102+
end
103+
end
104+
105+
context "when given a custom config_dot_file" do
106+
let(:config_path) { File.join('spec','bundle','unpatched_gems_with_dot_configuration','.bundler-audit.yml') }
107+
108+
context "when the config_dot_file is an absolute path" do
109+
let(:absolute_config_path) { File.absolute_path(config_path) }
110+
111+
subject { described_class.new(directory, 'Gemfile.lock', Database.new, absolute_config_path) }
112+
113+
it "must load the configuration from the absolute path" do
114+
expect(subject.config).to be_kind_of(Configuration)
115+
expect(subject.config.ignore).to include('OSVDB-89025')
116+
end
117+
end
118+
119+
context "when the config_dot_file is a relative path" do
120+
let(:relative_config_path) { File.join('..','unpatched_gems_with_dot_configuration','.bundler-audit.yml') }
121+
122+
subject { described_class.new(directory, 'Gemfile.lock', Database.new, relative_config_path) }
123+
124+
it "must load the configuration from the relative path" do
125+
expect(subject.config).to be_kind_of(Configuration)
126+
expect(subject.config.ignore).to include('OSVDB-89025')
127+
end
128+
end
129+
end
130+
131+
context "when no .bundler-audit.yml config file exists" do
132+
let(:bundle) { 'secure' }
133+
134+
subject { described_class.new(directory) }
135+
136+
it "must set #config to a default empty Configuration" do
137+
expect(subject.config).to be_kind_of(Configuration)
138+
expect(subject.config.ignore).to be_empty
139+
end
140+
end
18141
end
19142

20143
describe "#scan" do

0 commit comments

Comments
 (0)