Skip to content

Commit

Permalink
Merge branch 'master' into customize-salus-yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
maitrayshah-cb authored Jan 4, 2023
2 parents c0bfdcf + 1b823a4 commit 20548c9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
6 changes: 4 additions & 2 deletions lib/salus/scanners/language_version/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ def run

if min_version && (version < min_version)
error_msg = "Repository language version (#{version}) is less " \
"than minimum configured version (#{min_version})"
"than minimum configured version (#{min_version}). " \
"Please upgrade the language version."
report_error(error_msg)
return report_failure
end

if max_version && (version > max_version)
error_msg = "Repository language version (#{version}) is greater " \
"than maximum configured version (#{max_version})"
"than maximum configured version (#{max_version}). " \
"Please downgrade the language version."
report_error(error_msg)
return report_failure
end
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/salus/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def remove_key(json_string, key = 'running_time')
json['scans'].each do |scanner, _|
json['scans'][scanner].delete(key)
end
# Trufflehog outputs the newest available version, even if
# it is not the installed version, so just don't compare Trufflehog version
json['scans']['Trufflehog']&.delete('version')

return json if json.dig('config', 'report_uris').nil?

Expand Down Expand Up @@ -292,7 +295,6 @@ def remove_key(json_string, encoded = false)
processor = Salus::Processor.new(repo_path: 'spec/fixtures/processor/local_uri')
processor.scan_project
processor.export_report

expect(File.read(local_uri)).to match_report_json(expected_report, true)

# remove report file that was generated from Salus execution
Expand Down
10 changes: 1 addition & 9 deletions spec/lib/salus/scanners/gosec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,12 @@
let(:repo) { Salus::Repo.new('spec/fixtures/gosec/gosec_rules') }
let(:exceptions) do
[{ 'advisory_id' => "G101",
'expiration' => '2022-12-31',
'expiration' => '3022-12-31',
'changed_by' => 'appsec',
'notes' => 'foo' }]
end
let(:config) { { "exceptions" => exceptions, "nosec" => "true" } }

before(:each) do
allow(Date).to receive(:today).and_return Date.new(2021, 12, 31)
end

it 'should honor active exceptions' do
expect(config_scanner.report.passed?).to eq(true)
end
Expand All @@ -284,10 +280,6 @@
end
let(:config) { { "exceptions" => exceptions, "nosec" => "true" } }

before(:each) do
allow(Date).to receive(:today).and_return Date.new(2021, 12, 31)
end

it 'should ignore expired exceptions' do
expect(config_scanner.report.passed?).to eq(false)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
'go_version_scanner/invalid_version_1'

error_msg = 'Repository language version (1.14) is less '\
'than minimum configured version (1.15.0)'
'than minimum configured version (1.15.0). '\
'Please upgrade the language version.'

it_behaves_like "language version scanner sarif",
Salus::Scanners::LanguageVersion::GoVersionScanner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
'ruby_version_scanner/invalid_version_1'

error_msg = 'Repository language version (2.1.0) is less '\
'than minimum configured version (2.6.0)'
'than minimum configured version (2.6.0). ' \
'Please upgrade the language version.'

it_behaves_like "language version scanner sarif",
Salus::Scanners::LanguageVersion::RubyVersionScanner,
Expand Down

0 comments on commit 20548c9

Please sign in to comment.