Skip to content

Commit

Permalink
[ExcelAnalyzer] Add threshold for hidden rows
Browse files Browse the repository at this point in the history
We've had no serious data breaches at this level and it would reduce the
number of hidden row hits by over half.
  • Loading branch information
gbp committed May 14, 2024
1 parent 4a226a9 commit 7f6380c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions gems/excel_analyzer/lib/excel_analyzer/xlsx_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def suspected_problem?(data)
return false if total_count == 0
return false if data[:named_ranges] == total_count
return false if data[:external_links] == total_count
return false if data[:hidden_rows] == total_count && total_count <= 50

true
end
Expand Down
16 changes: 16 additions & 0 deletions gems/excel_analyzer/spec/excel_analyzer/xlsx_analyzer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,21 @@
expect(ExcelAnalyzer.on_hidden_metadata).to receive(:call)
end
end

context 'when metadata contains 50 hidden rows only' do
let(:metadata) { { hidden_rows: 50 } }

it 'should not be run' do
expect(ExcelAnalyzer.on_hidden_metadata).to_not receive(:call)
end
end

context 'when metadata contains 50 hidden rows and anything else' do
let(:metadata) { { hidden_rows: 50, other: 1 } }

it 'should run' do
expect(ExcelAnalyzer.on_hidden_metadata).to receive(:call)
end
end
end
end

0 comments on commit 7f6380c

Please sign in to comment.