Skip to content

Commit

Permalink
ANother try
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubosky committed May 3, 2024
1 parent 2f7cdf8 commit 4619af7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 36 deletions.
84 changes: 49 additions & 35 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Ruby on Rails CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:
Expand All @@ -24,37 +24,51 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
clamav:
image: mkodockx/docker-clamav
ports:
- 3310:3310 # ClamAV listens on this port for connections

steps:
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.7' # Adjust the Ruby version to match your project's version

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev libmagic-dev clamav clamav-daemon
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup Database
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/vigilion_scanner_test
run: |
bin/rails db:create
bin/rails db:schema:load
- name: Run tests
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/vigilion_scanner_test
CLAMD_HOST: clamav
run: bundle exec rspec
- uses: actions/checkout@v2

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0.7' # Adjust the Ruby version to match your project's version

- name: Install ClamAV
run: >
sudo apt-get install -y clamav clamav-daemon
&& sudo mkdir /var/run/clamav
&& sudo chown clamav:clamav /var/run/clamav
- name: Refresh ClamAV
run: sudo systemctl stop clamav-freshclam.service && sudo freshclam

- name: ClamAV Status
run: sudo systemctl restart clamav-daemon && sleep 30 && sudo systemctl status clamav-daemon

- name: clamdscan
run: clamdscan --stream public/dummy.pdf

- name: clamscan
run: clamscan public/dummy.pdf

- name: Install dependencies
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup Database
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/vigilion_scanner_test
run: |
bin/rails db:create
bin/rails db:schema:load
- name: Run tests
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:password@localhost:5432/vigilion_scanner_test
CLAMD_TCP_SOCKET: 3310
CLAMD_TCP_ADDR: 127.0.0.1
CLAMD_USE_TCP: True
run: bundle exec rspec
2 changes: 2 additions & 0 deletions app/services/av_runner/clamav.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def engine
private

def extract_message(stdout)
puts "+"*100
puts stdout.read
first_line = stdout.read.split("\n")[0]
# Strip filepath out of message
first_line.gsub(/.*: /im, '')
Expand Down
2 changes: 1 addition & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test:
<<: *default
dashboard_api_key: "vigilion"
engines:
clamav: "clamdscan --server=clamav --port=3310 --fdpass"
clamav: "clamdscan --fdpass"
avg: "avgscan"
avg_opts: "-P -a -w -j -i"
eset: "esets_scan"
Expand Down
Binary file added public/dummy.pdf
Binary file not shown.

0 comments on commit 4619af7

Please sign in to comment.