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

Ctskf 632 virus scan #6392

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
14 changes: 14 additions & 0 deletions .k8s/live/dev-lgfs/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ spec:
spec:
serviceAccountName: cccd-dev-lgfs-service
containers:
- name: clamav
image: ghcr.io/ministryofjustice/hmpps-clamav:sha-ae9a953
imagePullPolicy: IfNotPresent
ports:
- name: clamav
containerPort: 3310
protocol: TCP
resources:
limits:
cpu: 500m
memory: 3Gi
requests:
cpu: 10m
memory: 1Gi
- name: cccd-app
imagePullPolicy: Always
image: 754256621582.dkr.ecr.eu-west-2.amazonaws.com/laa-get-paid/cccd:set-me
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ gem 'active_storage_validations'
gem 'faraday', '~> 1.10'
gem 'faraday_middleware', '~> 1.2'
gem 'puma'
gem 'ratonvirus'
gem 'ratonvirus-clamby'

group :development, :test do
gem 'annotate'
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ GEM
case_transform (0.2)
activesupport
chartkick (5.0.5)
clamby (1.6.10)
cocoon (1.2.15)
coderay (1.1.3)
coercible (1.0.0)
Expand Down Expand Up @@ -512,6 +513,11 @@ GEM
thor (~> 1.0)
rainbow (3.1.1)
rake (13.1.0)
ratonvirus (0.3.2)
activesupport (~> 6.0)
ratonvirus-clamby (0.3.0)
clamby (~> 1.6)
ratonvirus (~> 0.3.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
Expand Down Expand Up @@ -764,6 +770,8 @@ DEPENDENCIES
rack-livereload (~> 0.5.1)
rails (~> 6.1.7)
rails-controller-testing
ratonvirus
ratonvirus-clamby
redis (~> 5.0.8)
remotipart (~> 1.4)
rest-client (~> 2.1)
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/super_admins/service_status_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module SuperAdmins
class ServiceStatusController < ApplicationController
skip_load_and_authorize_resource

def index; end
end
end
1 change: 1 addition & 0 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Document < ApplicationRecord
image/bmp
image/x-bitmap
]
validates :document, antivirus: true

alias attachment document # to have a consistent interface to both Document and Message
delegate :provider_id, to: :external_user
Expand Down
1 change: 1 addition & 0 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Message < ApplicationRecord
image/bmp
image/x-bitmap
]
validates :attachment, antivirus: true

validates :sender, presence: true
validates :body, presence: true
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/_primary_navigation.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
= govuk_link_to t('.offences'), super_admins_offences_path, class: cp(super_admins_offences_path)
%li
= govuk_link_to t('.stats'), super_admins_stats_path, class: cp(super_admins_stats_path)
%li
= govuk_link_to t('.service_status'), super_admins_service_status_index_path, class: cp(super_admins_service_status_index_path)

- elsif current_user.persona.is_a?(ExternalUser)
%li
Expand Down
12 changes: 12 additions & 0 deletions app/views/super_admins/service_status/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
= content_for :page_title, flush: true do
= 'Service Status'

= render partial: 'layouts/header', locals: { page_heading: 'Service Status' }

= govuk_table do
= govuk_table_tbody do
= govuk_table_row do
= govuk_table_th do
= 'Virus scanner available'
= govuk_table_td do
= Ratonvirus.scanner.available? ? 'Yes' : 'No'
2 changes: 2 additions & 0 deletions config/clamd.container.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TCPSocket 3310
TCPAddr localhost
16 changes: 16 additions & 0 deletions config/initializers/clamby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Clamby.configure({
# check: false,
# daemonize: true,
config_file: Rails.root.join('config', 'clamd.container.conf'),
# error_clamscan_missing: true,
# error_clamscan_client_error: false,
# error_file_missing: true,
# error_file_virus: false,
# fdpass: false,
stream: true,
# reload: false,
# output_level: 'medium',
# executable_path_clamscan: 'clamscan',
# executable_path_clamdscan: 'clamdscan',
# executable_path_freshclam: 'freshclam',
Comment on lines +2 to +15
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we want to enable any of these options when we implement this? I notice on Paul's PR that several of them are set to true. Not necessarily something for now, it can probably be decided on when we do the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied this from the README of clamby and I believe that they are all the defaults except the two that I have changed. I left them in for reference in case we decide there are any we need to change.

})
4 changes: 4 additions & 0 deletions config/initializers/ratonvirus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Ratonvirus.configure do |config|
config.scanner = :clamby
config.storage = :active_storage
end
1 change: 1 addition & 0 deletions config/locales/en/views/layouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ en:
sub_navigation: Sub navigation
users: Users
offences: Offences
service_status: Service Status

skip_content: Skip to main content

Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
patch 'update_password', on: :member
end
end

resources :service_status, only: :index
end

namespace :provider_management do
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ RUN apk --update-cache upgrade \
postgresql-client \
redis \
runit \
ttf-freefont
ttf-freefont \
clamav-clamdscan

RUN addgroup -g 1000 -S appgroup \
&& adduser -u 1000 -S appuser -G appgroup
Expand Down