File tree 12 files changed +476
-653
lines changed
lib/cc/engine/bundler_audit
12 files changed +476
-653
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,13 @@ RUN apk --update add ruby ruby-dev ruby-bundler build-base git
6
6
COPY Gemfile /usr/src/app/
7
7
COPY Gemfile.lock /usr/src/app/
8
8
RUN bundle install -j 4 && \
9
- bundle-audit update && \
10
9
apk del build-base && rm -fr /usr/share/ri
11
10
12
11
RUN adduser -u 9000 -D app
13
12
USER app
14
13
14
+ RUN bundle-audit update
15
+
15
16
COPY . /usr/src/app
16
17
17
18
CMD ["/usr/src/app/bin/bundler-audit" ]
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ def remediation_points
67
67
end
68
68
69
69
def severity
70
- SEVERITIES [ advisory . criticality ]
70
+ SEVERITIES . fetch ( advisory . criticality , "normal" )
71
71
end
72
72
73
73
def solution
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ module BundlerAudit
4
4
class UnpatchedGemRemediation
5
5
MAJOR_UPGRADE_POINTS = 50_000_000
6
6
MINOR_UPGRADE_POINTS = 5_000_000
7
- PATCH_UPGRADE_POINTS = 500_000
7
+ TINY_UPGRADE_POINTS = 500_000
8
+ MINIMUM_UPGRADE_POINTS = 50_000
8
9
UNPATCHED_VERSION_POINTS = 500_000_000
9
10
10
11
def initialize ( gem_version , patched_versions )
@@ -31,7 +32,9 @@ def calculate_points(upgrade_version)
31
32
when current_version . minor != upgrade_version . minor
32
33
MINOR_UPGRADE_POINTS
33
34
when current_version . tiny != upgrade_version . tiny
34
- PATCH_UPGRADE_POINTS
35
+ TINY_UPGRADE_POINTS
36
+ else
37
+ MINIMUM_UPGRADE_POINTS
35
38
end
36
39
end
37
40
Original file line number Diff line number Diff line change @@ -15,15 +15,19 @@ module CC::Engine::BundlerAudit
15
15
16
16
issues = analyze_directory ( directory )
17
17
18
- expect ( issues ) . to eq ( expected_issues ( "unpatched_versions" ) )
18
+ expected_issues ( "unpatched_versions" ) . each do |expected_issue |
19
+ expect ( issues ) . to include ( expected_issue )
20
+ end
19
21
end
20
22
21
23
it "emits issues for insecure sources in Gemfile.lock" do
22
- directory = fixture_directory ( "insecure_source " )
24
+ directory = fixture_directory ( "insecure_sources " )
23
25
24
26
issues = analyze_directory ( directory )
25
27
26
- expect ( issues ) . to eq ( expected_issues ( "insecure_source" ) )
28
+ expected_issues ( "insecure_sources" ) . each do |expected_issue |
29
+ expect ( issues ) . to include ( expected_issue )
30
+ end
27
31
end
28
32
29
33
it "logs to stderr when we encounter an unsupported vulnerability" do
Original file line number Diff line number Diff line change @@ -15,10 +15,28 @@ module CC::Engine::BundlerAudit
15
15
expect ( remediation . points ) . to eq ( UnpatchedGemRemediation ::MINOR_UPGRADE_POINTS )
16
16
end
17
17
18
- it "returns patch upgrade remediation points when an upgrade requies a patch version bump" do
19
- remediation = UnpatchedGemRemediation . new ( "1.0.0 " , %w[ 1.0.3 2.0.3 ] )
18
+ it "returns tiny upgrade remediation points when an upgrade requies a tiny version bump" do
19
+ remediation = UnpatchedGemRemediation . new ( "1.0" , %w[ 1.0.2 ] )
20
20
21
- expect ( remediation . points ) . to eq ( UnpatchedGemRemediation ::PATCH_UPGRADE_POINTS )
21
+ expect ( remediation . points ) . to eq ( UnpatchedGemRemediation ::TINY_UPGRADE_POINTS )
22
+ end
23
+
24
+ it "returns minimum upgrade remediation points when an upgrade requies a <= tiny2 version bump" do
25
+ remediation = UnpatchedGemRemediation . new ( "1.0" , %w[ 1.0.0.2-2 ] )
26
+
27
+ expect ( remediation . points ) . to eq ( UnpatchedGemRemediation ::MINIMUM_UPGRADE_POINTS )
28
+
29
+ remediation = UnpatchedGemRemediation . new ( "1.0" , %w[ 1.0.0.2-2 ] )
30
+
31
+ expect ( remediation . points ) . to eq ( UnpatchedGemRemediation ::MINIMUM_UPGRADE_POINTS )
32
+
33
+ remediation = UnpatchedGemRemediation . new ( "1.0" , %w[ 1.0a2 ] )
34
+
35
+ expect ( remediation . points ) . to eq ( UnpatchedGemRemediation ::MINIMUM_UPGRADE_POINTS )
36
+
37
+ remediation = UnpatchedGemRemediation . new ( "1.0" , %w[ 1.0b2 ] )
38
+
39
+ expect ( remediation . points ) . to eq ( UnpatchedGemRemediation ::MINIMUM_UPGRADE_POINTS )
22
40
end
23
41
24
42
it "returns unpatched version remediation points when an upgrade is not possible" do
You can’t perform that action at this time.
0 commit comments