Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover from virus detected during Transfer process #718

Merged
merged 4 commits into from
Jun 10, 2021
Merged

Conversation

JPrevost
Copy link
Member

@JPrevost JPrevost commented Jun 7, 2021

Why are these changes being introduced:

  • the virus scanner removes access to files when a virus is detected
  • Rails tries to access each file being added to ActiveStorage when the
    record is saved
  • files with viruses will throw a error
  • Handling the specific error allows us to signal to the user a problem
    was detected
  • The Transfer record and all files associated with it remain in a fully
    valid state with only the virus infected files being inacessible

Relevant ticket(s):

How does this address that need:

  • We recover from the specific S3 access denied message during Transfer
    saves, modify the message slightly to the user, then continue with the
    rest of the process

Document any side effects to this change:

  • If there is any other reason the S3 file access would be denied during
    this save, it may not be what we expect.
  • Most versions of ruby seem to include the gem json, but for some
    reason this is not happening on my latest laptop. There doesn't seem to be any
    harm in including it in the Gemfile and it makes my life way easier

Developer

  • All new ENV is documented in README
  • All new ENV has been added to Heroku Pipeline, Staging and Prod
  • ANDI or Wave has been run in accordance to
    our guide and
    all issues introduced by these changes have been resolved or opened as new
    issues (link to those issues in the Pull Request details above)
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Requires database migrations?

NO

Includes new or updated dependencies?

YES

@mitlib mitlib temporarily deployed to thesis-submit-pr-718 June 7, 2021 19:25 Inactive
@coveralls
Copy link

coveralls commented Jun 7, 2021

Coverage Status

Coverage decreased (-0.8%) to 94.545% when pulling fc5ed3d on add_json_gem into 42ec41a on main.

@JPrevost JPrevost temporarily deployed to thesis-submit-pr-718 June 9, 2021 15:27 Inactive
@JPrevost JPrevost temporarily deployed to thesis-submit-pr-718 June 9, 2021 16:10 Inactive
@JPrevost JPrevost temporarily deployed to thesis-submit-pr-718 June 9, 2021 16:16 Inactive
@JPrevost JPrevost temporarily deployed to thesis-submit-pr-718 June 9, 2021 17:32 Inactive
@JPrevost JPrevost changed the title Adds json gem Recover from virus detected during Transfer process Jun 9, 2021
@JPrevost JPrevost marked this pull request as ready for review June 9, 2021 19:50
@matt-bernhardt matt-bernhardt self-assigned this Jun 9, 2021
Copy link
Member

@matt-bernhardt matt-bernhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost all of this looks fine - I've confirmed that the tests pass, the email gets sent as expected, and the feedback to the user is shown when appropriate.

I see that coverage goes down, but I'm not sure what the right testing strategy would be here for covering the rescue clause in the transfer controller.

The only thing I think is needed is a comma in app.json after the new entry - I'm not sure what leaving it off will do, so if this is optional somehow let me know and I'm happy to approve as is.

app.json Outdated
@@ -27,6 +27,9 @@
"LANG": {
"required": true
},
"MAINTAINER_EMAIL": {
"required": true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a comma missing on this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. All future PR builds were likely to blow up lol

app.json Outdated
@@ -77,4 +80,4 @@
"url": "heroku/ruby"
}
]
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that this matters, but I see a symbol here that there's no trailing carriage return on this file. Ignore if you like, I'm happy to merge without this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh. yeah my editor seems to remove that railing line in json files for some reason when I save. Since I need to fix the json anyway for the above catch, I'll see if I can get this resolved as well.

@JPrevost JPrevost temporarily deployed to thesis-submit-pr-718 June 10, 2021 13:20 Inactive
JPrevost added 4 commits June 10, 2021 09:37
Why are these changes being introduced:

* Most versions of ruby seem to include this gem bundled, but for some
reason this is not happening on my latest laptop. This experimental
branch is to mostly confirm adding this gem manually doesn't negatively
affect our various environments.

Document any side effects to this change:

We're explicitly including a gem that seems to often already be
included. This may allow us to keep it up to date more than relying
on ruby-included versions that may be installed in various environments.
Why are these changes being introduced:

* the virus scanner removes access to files when a virus is detected
* Rails tries to access each file being added to ActiveStorage when the
  record is saved
* files with viruses will throw a error
* Handling the specific error allows us to signal to the user a problem
  was detected
* The Transfer record and all files associated with it remain in a fully
  valid state with only the virus infected files being inacessible

Relevant ticket(s):

* https://mitlibraries.atlassian.net/browse/ETD-349

How does this address that need:

* We recover from the specific S3 access denied message during Transfer
  saves, modify the message slightly to the user, then continue with the
  rest of the process

Document any side effects to this change:

* If there is any other reason the S3 file access would be denied during
  this save, it may not be what we expect.
Why are these changes being introduced:

* knowing when this error is handled and being able to confirm it is
  due to what we expected and not some other underlying problem with the
  transfer will be helpful
@JPrevost JPrevost temporarily deployed to thesis-submit-pr-718 June 10, 2021 13:38 Inactive
@matt-bernhardt matt-bernhardt self-requested a review June 10, 2021 13:56
Copy link
Member

@matt-bernhardt matt-bernhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@JPrevost JPrevost merged commit c6b5562 into main Jun 10, 2021
@JPrevost JPrevost deleted the add_json_gem branch August 6, 2021 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants