Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/services/info_request_batch_zip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def prepare_incoming_message(message)
def prepare_foi_attachment(attachment)
message = attachment.incoming_message
return if cannot?(:read, message)
return if cannot?(:read, attachment)

sent_at = message.sent_at.to_formatted_s(:filename)

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/alaveteli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
load "util.rb"

# Application version
ALAVETELI_VERSION = '0.46.2.1'
ALAVETELI_VERSION = '0.46.3.0'

# Add new inflection rules using the following format
# (all these examples are active by default):
Expand Down
22 changes: 18 additions & 4 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# 0.46.2.0
# 0.46.3.0

## Highlighted Features

* Use SecureRandom when generating tokens.
* This release includes an update to the commonlib submodule - you
should be warned about this when running `rails-post-deploy`.
* Fix visibility check for attachments when downloading a batch request as a zip
file (Gareth Rees)

# 0.46.2.0

Expand Down Expand Up @@ -261,6 +260,21 @@ to match the new templates.
app/views/user/wrong_user.html.erb
app/views/user_mailer/already_registered.text.erb

# 0.45.5.0

## Highlighted Features

* Fix visibility check for attachments when downloading a batch request as a zip
file (Gareth Rees)

# 0.45.4.1

## Highlighted Features

* Use SecureRandom when generating tokens.
* This release includes an update to the commonlib submodule - you
should be warned about this when running `rails-post-deploy`.

# 0.45.4.0

## Highlighted Features
Expand Down
31 changes: 27 additions & 4 deletions spec/services/info_request_batch_zip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@
let(:message) { event.incoming_message }
let(:attachment) { message.get_attachments_for_display.first }

context 'can read message' do
before { ability.can :read, message }
context 'can read message and attachment' do
before do
ability.can :read, message
ability.can :read, attachment
end

it 'includes attachments' do
expect(paths).to include(
Expand All @@ -121,7 +124,24 @@
end

context 'cannot read message' do
before { ability.cannot :read, message }
before do
ability.cannot :read, message
ability.can :read, attachment
end

it 'does not include attachments' do
expect(paths).not_to include(
"#{base_path}/2019-11-11-103000/attachments-#{message.id}/" \
"#{attachment.display_filename}"
)
end
end

context 'cannot read attachment' do
before do
ability.can :read, message
ability.cannot :read, attachment
end

it 'does not include attachments' do
expect(paths).not_to include(
Expand All @@ -132,7 +152,10 @@
end

context 'when a censor rule redacts an attachment filename' do
before { ability.can :read, message }
before do
ability.can :read, message
ability.can :read, attachment
end

it 'uses the redacted filename in the zip path' do
request.censor_rules.create!(
Expand Down
Loading