media assets: fix md5 leak in media assets.

Fix unprivileged users being able to see images and MD5 hashes of media
assets belonging to censored posts.
This commit is contained in:
evazion
2022-01-30 23:23:55 -06:00
parent 2fe058eccf
commit 0132c5f0a5
5 changed files with 34 additions and 7 deletions

View File

@@ -25,6 +25,15 @@ class MediaAssetsControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
should "not show the md5 for assets belonging to posts not visible to the current user" do
@media_asset = create(:media_asset)
@post = create(:post, md5: @media_asset.md5, is_banned: true)
get media_asset_path(@media_asset), as: :json
assert_response :success
assert_equal(nil, response.parsed_body[:md5])
end
end
end
end