Package: cvdupdate
A tool to download and update clamav databases and database patch files
for the purposes of hosting your own database mirror.Copyright (C) 2021-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved.AboutThis tool downloads the latest ClamAV databases along with the latest database patch files.This project replaces theclamdownloader.plPerl script by Frederic Vanden Poel, formerly provided here:https://www.clamav.net/documents/private-local-mirrorsRun this tool as often as you like, but it will only download new content if there is new content to download. If you somehow manage to download too frequently (eg: by usingcvd clean allandcvd updaterepeatedly), then the official database server may refuse your download request, and one or more databases may go on cool-down until it's safe to try again.RequirementsPython 3.6 or newer.An internet connection with DNS enabled.The following Python packages.  These will be installed automatically if you usepip, but may need to be installed manually otherwise:clickv7.0 or newercoloredlogsv10.0 or newercoloramarequestsdnspythonv2.1.0 or newerrangehttpserverInstallationYou may installcvdupdatefrom PyPI usingpip, or you may clone the project Git repository and usepipto install it locally.Installcvdupdatefrom PyPI:python3-mpipinstall--usercvdupdateBasic UsageUse the--helpoption with anycvdcommand to get help.cvd--helpTip: You may not be able to run thecvdorcvdupdateshortcut directly if your Python Scripts directory is not in yourPATHenvironment variable. If you run into this issue, and do not wish to add the Python Scripts directory to your path, you can run CVD-Update like this:python-mcvdupdate--help(optional) You may wish to customize where the databases are stored:cvdconfigset--dbdir<yourwwwpath>Run this to download the latest database and associated CDIFF patch files:cvdupdateDownloaded databases will be placed in~/.cvdupdate/databaseunless you customized it to use a different directory.Newly downloaded databases will replace the previous database version, but the CDIFF patch files will accumulate up to a configured maximum before it starts deleting old CDIFFs (default: 30 CDIFFs). You can configure it to keep more CDIFFs by manually editing the config (default:~/.cvdupdate/config.json). The same behavior applies for CVD-Update log rotation.Run this to serve up the database directory onhttp://localhost:8000so you can test it with FreshClam.cvdserveDisclaimer: Thecvd servefeature is not intended for production use, just for testing. You probably want to use a more robust HTTP server for production work.Install ClamAV if you don't already have it and, in another terminal window, modify yourfreshclam.conffile. Replace:DatabaseMirror database.clamav.net... with:DatabaseMirror http://localhost:8000Tip: A default install on Linux/Unix placesfreshclam.confin/usr/local/etc/freshclam.conf. If one does not exist, you may need to create it usingfreshclam.conf.sampleas a template.Now, runfreshclam -vorfreshclam.exe -vto see what happens. You should see FreshClam successfully update it's own database directory from your private database server.Runcvd updateas often as you need.  Maybe put it in acronjob.Tip: Each command supports a--verbose(-V) mode, which often provides more details about what's going on under the hood.Cron ExampleCron is a popular choice to automate frequent tasks on Linux / Unix systems.Open a terminal running as the user which you want CVD-Update to run under, do the following:crontab-ePressito insert new text, and add this line:30*/4***/bin/sh-c"~/.local/bin/cvd update &> /dev/null"Or instead of~/, you can do this, replacingusernamewith your user name:30*/4***/bin/sh-c"/home/username/.local/bin/cvd update &> /dev/null"Press , then type:wqand press  to write the file to disk and quit.About these settings:I selected30 */4 * * *to run at minute 30 past every 4th hour. CVD-Update uses a DNS check to do version checks before it attempts to download any files, just like FreshClam. Running CVD-Update more than once a day should not be an issue.CVD-Update will write logs to the~/.cvdupdate/logsdirectory, which is why I directedstdoutandstderrto/dev/nullinstead of a log file. You can use thecvd config setcommand to customize the log directory if you like, or redirectstdoutandstderrto a log file if you prefer everything in one log instead of separate daily logs.Optional FunctionalityUsing a custom DNS serverDNS is required for CVD-Update to function properly (to gather the TXT record containing the current definition database version). You can select a specific nameserver to ensure said nameserver is used when querying the TXT record containing the current database definition version availableSet the nameserver in the config. Eg:cvdconfigset--nameserver208.67.222.222Set the environment variableCVDUPDATE_NAMESERVER. Eg:CVDUPDATE_NAMESERVER="208.67.222.222"cvdupdateThe environment variable will take precedence over the nameserver config setting.Note:  Both options can be used to provide a comma-delimited list of nameservers to utilize for resolution.Using a proxyDepending on your type of proxy, you may be able to use CVD-Update with your proxy by running CVD-Update like this:First, set a custom domain name server to use the proxy:cvdconfigset--nameserver<proxy_ip>Then run CVD-Update like this:http_proxy=http://<proxy_ip>:<proxy_port>https_proxy=http://<proxy_ip>:<proxy_port>cvdupdate-VOr create a script to wrap the CVD-Update call. Something like:#!/bin/bashhttp_proxy=http://<proxy_ip>:<proxy_port>exporthttp_proxyhttps_proxy=http://<proxy_ip>:<proxy_port>exporthttps_proxy
cvdupdate-VDisclaimer: CVD-Update doesn't support proxies that require authentication at this time. If your network admin allows it, you may be able to work around it by updating your proxy to allow HTTP requests through unauthenticated if the User-Agent matches your specific CVD-Update user agent. The CVD-Update User-Agent follows the formCVDUPDATE/<version> (<uuid>)where theuuidis unique to your installation and can be found in the~/.cvdupdate/state.jsonfile (or~/.cvdupdate/config.jsonfor cvdupdate <=1.0.2). Seehttps://github.com/Cisco-Talos/cvdupdate/issues/9for more details.Adding support for proxy authentication is a ripe opportunity for a community contribution to the project.Files and directories created by CVD-UpdateThis tool is to creates the following directories:~/.cvdupdate~/.cvdupdate/logs~/.cvdupdate/databasesThis tool creates the following files:~/.cvdupdate/config.json~/.cvdupdate/state.json~/.cvdupdate/databases/<database>.cvd~/.cvdupdate/databases/<database>-<version>.cdiff~/.cvdupdate/logs/<date>.logTip: You can set customdatabaseandlogsdirectories with thecvd config setcommand. It is likely you will want to customize thedatabasedirectory to point to your HTTP server'swwwdirectory (or equivalent). Bare in mind that if you already downloaded the databases to the old directory, you may want to move them to the new directory.Important: If you want to use a custom config path, you'll have to use it in every command. If you're fine with having it go in~/.cvdupdate/config.json, don't worry about it.Additional UsageGet familiar with the toolFamiliarize yourself with the various commands using the--helpoption.cvd--help
cvdconfig--help
cvdupdate--help
cvdclean--helpPrint out the current list of databases.cvdlist-VPrint out the config to see what it looks like.cvdconfigshowDo an updateDo an update, use "verbose mode" to so you can get a feel for how it works.cvdupdate-VList out the databases again:cvdlist-VThe print out the config again so you can see what's changed.cvdconfigshowAnd maybe take a peek in the database directory as well to see it for yourself.ls~/.cvdupdate/databaseHave a look at the logs if you wish.ls~/.cvdupdate/logs

cat~/.cvdupdate/logs/*Serve it up, Test out FreshClamTest out your mirror with FreshClam on the same computer.This tool includes a--servefeature that will host the current database directory onhttp://localhost(default port: 8000).You can test it by runningfreshclamorfreshclam.exelocally, where you've configuredfreshclam.confwith:DatabaseMirror http://localhost:8000ContributeWe'd love your help. There are many ways to contribute!CommunityJoin the ClamAV community on theClamAV Discord chat server.Report issuesIf you find an issue with CVD-Update or the CVD-Update documentation, please submit an issue to ourGitHub issue tracker.  Before you submit, please check to if someone else has already reported the issue.DevelopmentIf you find a bug and you're able to craft a fix yourself, consider submitting the fix in apull request. Your help will be greatly appreciated.If you want to contribute to the project and don't have anything specific in mind, please check out ourissue tracker.  Perhaps you'll be able to fix a bug or add a cool new feature.By submitting a contribution to the project, you acknowledge and agree to assign Cisco Systems, Inc the copyright for the contribution. If you submit a significant contribution such as a new feature or capability or a large amount of code, you may be asked to sign a contributors license agreement comfirming that Cisco will have copyright license and patent license and that you are authorized to contribute the code.Development Set-upThe following steps are intended to help users that wish to contribute to development of the CVD-Update project get started.Create a fork of theCVD-Update git repository, and then clone your fork to a local directory.For example:gitclonehttps://github.com/<yourusername>/cvdupdate.gitMake sure CVD-Update is not already installed.  If it is, remove it.python3-mpipuninstallcvdupdateUse pip to install CVD-Update in "edit" mode.python3-mpipinstall-e--user./cvdupdateOnce installed in "edit" mode, any changes you make to your clone of the CVD-Update code will be immediately usable simply by running thecvdupdate/cvdcommands.ConductThis project has not selected a specific Code-of-Conduct document at this time. However, contributors are expected to behave in professional and respectful manner. Disrespectful or inappropriate behavior will not be tolerated.LicenseCVD-Update is licensed under the Apache License, Version 2.0 (the "License"). You may not use the CVD-Update project except in compliance with the License.A copy of the license is locatedhere, and is also available online atapache.org.Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.