Debian Codegraph @

cvdupdate.egg-info/PKG-INFO

raw
1 Metadata-Version: 2.4
2 Name: cvdupdate
3 Version: 1.2.0
4 Summary: ClamAV Private Database Mirror Updater Tool
5 Home-page: https://github.com/Cisco-Talos/cvdupdate
6 Author: The ClamAV Team
7 Author-email: [email protected]
8 Classifier: Programming Language :: Python :: 3
9 Classifier: License :: OSI Approved :: Apache Software License
10 Classifier: Operating System :: OS Independent
11 Description-Content-Type: text/markdown
12 License-File: LICENSE
13 Requires-Dist: click>=7.0
14 Requires-Dist: colorlog>=6.7
15 Requires-Dist: colorama
16 Requires-Dist: requests
17 Requires-Dist: dnspython>=2.1.0
18 Requires-Dist: rangehttpserver
19 Requires-Dist: packaging
20 Dynamic: author
21 Dynamic: author-email
22 Dynamic: classifier
23 Dynamic: description
24 Dynamic: description-content-type
25 Dynamic: home-page
26 Dynamic: license-file
27 Dynamic: requires-dist
28 Dynamic: summary
29
30 <p align="center">A tool to download and update clamav databases and database patch files
31 for the purposes of hosting your own database mirror.
32 <p align="center"><em>Copyright (C) 2021-2025 Cisco Systems, Inc. and/or its affiliates. All rights reserved.</em></p>
33
34 <p align="center">
35 <a href="https://pypi.org/project/cvdupdate/">
36 <img src="https://badge.fury.io/py/cvdupdate.svg" alt="PyPI version" height="18">
37 </a>
38 <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/cvdupdate" height="18">
39 <a href="https://discord.gg/6vNAqWnVgw"><img src="https://img.shields.io/discord/636023333074370595.svg?logo=discord" height="18"/></a>
40 <a href="https://twitter.com/clamav"><img src="https://abs.twimg.com/favicons/twitter.ico" width="18" height="18"></a>
41 </p>
42
43 ## About
44
45 This tool downloads the latest ClamAV databases along with the latest database patch files.
46
47 This project replaces the `clamdownloader.pl` Perl script by Frederic Vanden Poel, formerly provided here: https://www.clamav.net/documents/private-local-mirrors
48
49 Run 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 using `cvd clean all` and `cvd update` repeatedly), 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.
50
51 ## Requirements
52
53 - Python 3.6 or newer.
54 - An internet connection with DNS enabled.
55 - The following Python packages. These will be installed automatically if you use `pip`, but may need to be installed manually otherwise:
56 - `click` v7.0 or newer
57 - `colorlog` v6.7 or newer
58 - `colorama`
59 - `requests`
60 - `dnspython` v2.1.0 or newer
61 - `rangehttpserver`
62
63 ## Installation
64
65 You may install `cvdupdate` from PyPI using `pip`, or you may clone the project Git repository and use `pip` to install it locally.
66
67 Install `cvdupdate` from PyPI:
68
69 ```bash
70 python3 -m pip install --user cvdupdate
71 ```
72
73 ### Updating Your Installation
74
75 When running `cvd update` to update the databases, it will also check if there is a new version of the `cvdupdate` package on Python's PyPI package repository. If there is a newer version of `cvdupdate`, you will see a message prompting you to upgrade. It will look someething like this:
76 ```
77 WARNING You are running cvdupdate version: 1.1.0.
78 WARNING There is a newer version on PyPI: 1.1.1. Please update!
79 ```
80
81 To upgrade the `cvdupdate` package through PyPI, run:
82
83 ```bash
84 python3 -m pip install --user --upgrade cvdupdate
85 ```
86
87 ## Basic Usage
88
89 Use the `--help` option with any `cvd` command to get help.
90
91 ```bash
92 cvd --help
93 ```
94
95 > _Tip_: You may not be able to run the `cvd` or `cvdupdate` shortcut directly if your Python Scripts directory is not in your `PATH` environment 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:
96 >
97 > ```bash
98 > python -m cvdupdate --help
99 > ```
100
101 (optional) You may wish to customize where the databases are stored:
102
103 ```bash
104 cvd config set --dbdir <your www path>
105 ```
106
107 Run this to download the latest database and associated CDIFF patch files:
108
109 ```bash
110 cvd update
111 ```
112
113 Downloaded databases will be placed in `~/.cvdupdate/database` unless you customized it to use a different directory.
114
115 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.
116
117 Run this to serve up the database directory on `http://localhost:8000` so you can test it with FreshClam.
118
119 ```bash
120 cvd serve
121 ```
122
123 > _Disclaimer_: The `cvd serve` feature is not intended for production use, just for testing. You probably want to use a more robust HTTP server for production work.
124
125 Install ClamAV if you don't already have it and, in another terminal window, modify your `freshclam.conf` file. Replace:
126 ```
127 DatabaseMirror database.clamav.net
128 ```
129
130 ... with:
131 ```
132 DatabaseMirror http://localhost:8000
133 ```
134
135 > _Tip_: A default install on Linux/Unix places `freshclam.conf` in `/usr/local/etc/freshclam.conf`. If one does not exist, you may need to create it using `freshclam.conf.sample` as a template.
136
137 Now, run `freshclam -v` or `freshclam.exe -v` to see what happens. You should see FreshClam successfully update it's own database directory from your private database server.
138
139 Run `cvd update` as often as you need. Maybe put it in a `cron` job.
140
141 > _Tip_: Each command supports a `--verbose` (`-V`) mode, which often provides more details about what's going on under the hood.
142
143 ### Cron Example
144
145 Cron is a popular choice to automate frequent tasks on Linux / Unix systems.
146
147 1. Open a terminal running as the user which you want CVD-Update to run under, do the following:
148
149 ```bash
150 crontab -e
151 ```
152
153 2. Press `i` to insert new text, and add this line:
154
155 ```bash
156 30 */4 * * * /bin/sh -c "~/.local/bin/cvd update &> /dev/null"
157 ```
158
159 Or instead of `~/`, you can do this, replacing `username` with your user name:
160
161 ```bash
162 30 */4 * * * /bin/sh -c "/home/username/.local/bin/cvd update &> /dev/null"
163 ```
164
165 3. Press <Escape>, then type `:wq` and press <Enter> to write the file to disk and quit.
166
167 **About these settings**:
168
169 I selected `30 */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.
170
171 CVD-Update will write logs to the `~/.cvdupdate/logs` directory, which is why I directed `stdout` and `stderr` to `/dev/null` instead of a log file. You can use the `cvd config set` command to customize the log directory if you like, or redirect `stdout` and `stderr` to a log file if you prefer everything in one log instead of separate daily logs.
172
173 ## Optional Functionality
174
175 ### Using a custom DNS server
176
177 DNS 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 available
178
179 1. Set the nameserver in the config. Eg:
180
181 ```bash
182 cvd config set --nameserver 208.67.222.222
183 ```
184
185 2. Set the environment variable `CVDUPDATE_NAMESERVER`. Eg:
186
187 ```bash
188 CVDUPDATE_NAMESERVER="208.67.222.222" cvd update
189 ```
190
191 The environment variable will take precedence over the nameserver config setting.
192
193 Note: Both options can be used to provide a comma-delimited list of nameservers to utilize for resolution.
194
195 ### Using a proxy
196
197 Depending on your type of proxy, you may be able to use CVD-Update with your proxy by running CVD-Update like this:
198
199 First, set a custom domain name server to use the proxy:
200
201 ```bash
202 cvd config set --nameserver <proxy_ip>
203 ```
204
205 Then run CVD-Update like this:
206
207 ```bash
208 http_proxy=http://<proxy_ip>:<proxy_port> https_proxy=http://<proxy_ip>:<proxy_port> cvd update -V
209 ```
210
211 Or create a script to wrap the CVD-Update call. Something like:
212
213 ```bash
214 #!/bin/bash
215 http_proxy=http://<proxy_ip>:<proxy_port>
216 export http_proxy
217 https_proxy=http://<proxy_ip>:<proxy_port>
218 export https_proxy
219 cvd update -V
220 ```
221
222 > _Disclaimer_: 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 form `CVDUPDATE/<version> (<uuid>)` where the `uuid` is unique to your installation and can be found in the `~/.cvdupdate/state.json` file (or `~/.cvdupdate/config.json` for cvdupdate <=1.0.2). See https://github.com/Cisco-Talos/cvdupdate/issues/9 for more details.
223 >
224 > Adding support for proxy authentication is a ripe opportunity for a community contribution to the project.
225
226 ## Files and directories created by CVD-Update
227
228 This tool is to creates the following directories:
229 - `~/.cvdupdate`
230 - `~/.cvdupdate/logs`
231 - `~/.cvdupdate/databases`
232
233 This tool creates the following files:
234 - `~/.cvdupdate/config.json`
235 - `~/.cvdupdate/state.json`
236 - `~/.cvdupdate/databases/<database>.cvd`
237 - `~/.cvdupdate/databases/<database>-<version>.cdiff`
238 - `~/.cvdupdate/logs/<date>.log`
239
240 > _Tip_: You can set custom `database` and `logs` directories with the `cvd config set` command. It is likely you will want to customize the `database` directory to point to your HTTP server's `www` directory (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.
241
242 > _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.
243
244 ## Additional Usage
245
246 ### Get familiar with the tool
247
248 Familiarize yourself with the various commands using the `--help` option.
249
250 ```bash
251 cvd --help
252 cvd config --help
253 cvd update --help
254 cvd add --help
255 cvd clean --help
256 ```
257
258 Print out the current list of databases.
259
260 ```bash
261 cvd list -V
262 ```
263
264 Print out the config to see what it looks like.
265
266 ```bash
267 cvd config show
268 ```
269
270 ### Do an update
271
272 Do an update, use "verbose mode" to so you can get a feel for how it works.
273
274 ```bash
275 cvd update -V
276 ```
277
278 List out the databases again:
279
280 ```bash
281 cvd list -V
282 ```
283
284 The print out the config again so you can see what's changed.
285
286 ```bash
287 cvd config show
288 ```
289
290 And maybe take a peek in the database directory as well to see it for yourself.
291
292 ```bash
293 ls ~/.cvdupdate/database
294 ```
295
296 Have a look at the logs if you wish.
297
298 ```bash
299 ls ~/.cvdupdate/logs
300
301 cat ~/.cvdupdate/logs/*
302 ```
303
304 ### Add an additional database
305
306 Maybe add an additional database that is not part of the default set of databases.
307
308 ```bash
309 cvd add linux.cvd https://database.clamav.net/linux.cvd
310 ```
311
312 List out the databases again:
313
314 ```bash
315 cvd list -V
316 ```
317
318 ### Serve it up, Test out FreshClam
319
320 Test out your mirror with FreshClam on the same computer.
321
322 This tool includes a `--serve` feature that will host the current database directory on http://localhost (default port: 8000).
323
324 You can test it by running `freshclam` or `freshclam.exe` locally, where you've configured `freshclam.conf` with:
325
326 ```
327 DatabaseMirror http://localhost:8000
328 ```
329
330 ## Use docker
331
332 Build docker image
333
334 ```bash
335 docker build . --tag cvdupdate:latest
336 ```
337
338 Run image, that will automaticly update databases in folder `/srv/cvdupdate` and write logs to `/var/log/cvdupdate`
339
340 ```bash
341 docker run -d \
342 -v /srv/cvdupdate:/cvdupdate/database \
343 -v /var/log/cvdupdate:/cvdupdate/logs \
344 cvdupdate:latest
345 ```
346
347 Run image, that will automaticly update databases in folder `/srv/cvdupdate`, write logs to `/var/log/cvdupdate` and set owner of files to user with ID 1000
348
349 ```bash
350 docker run -d \
351 -v /srv/cvdupdate:/cvdupdate/database \
352 -v /var/log/cvdupdate:/cvdupdate/logs \
353 -e USER_ID=1000 \
354 cvdupdate:latest
355 ```
356
357 Default update interval is `30 */4 * * *` (see [Cron Example](#cron-example))
358
359 You may pass custom update interval in environment variable `CRON`
360
361 For example - update every day in 00:00
362
363 ```bash
364 docker run -d \
365 -v /srv/cvdupdate:/cvdupdate/database \
366 -v /var/log/cvdupdate:/cvdupdate/logs \
367 -e CRON='0 0 * * *' \
368 cvdupdate:latest
369 ```
370 ## Use Docker Compose
371
372 A Docker `compose.yaml` is provided to:
373 1. Regularly update a Docker volume with the latest ClamAV databases.
374 2. Serve a database mirror on port 8000 using the Apache webserver.
375
376 Edit the `compose.yaml` file if you need to change the default values:
377
378 * Port 8000
379 * USER_ID=0
380 * CRON=30 */4 * * *
381
382 ### Build
383 ```bash
384 docker compose build
385 ```
386
387 ### Start
388 ```bash
389 docker compose up -d
390 ```
391
392 ### Stop
393 ```bash
394 docker compose down
395 ```
396
397 ### Volumes
398 Volumes are defined in `compose.yaml` and will be auto-created when you run `docker compose up`
399 ```
400 DRIVER VOLUME NAME
401 local cvdupdate_database
402 local cvdupdate_log
403 ```
404
405 ## Contribute
406
407 We'd love your help. There are many ways to contribute!
408
409 ### Community
410
411 Join the ClamAV community on the [ClamAV Discord chat server](https://discord.gg/sGaxA5Q).
412
413 ### Report issues
414
415 If you find an issue with CVD-Update or the CVD-Update documentation, please submit an issue to our [GitHub issue tracker](https://github.com/Cisco-Talos/cvdupdate/issues). Before you submit, please check to if someone else has already reported the issue.
416
417 ### Development
418
419 If you find a bug and you're able to craft a fix yourself, consider submitting the fix in a [pull request](https://github.com/Cisco-Talos/cvdupdate/pulls). Your help will be greatly appreciated.
420
421 If you want to contribute to the project and don't have anything specific in mind, please check out our [issue tracker](https://github.com/Cisco-Talos/cvdupdate/issues). Perhaps you'll be able to fix a bug or add a cool new feature.
422
423 _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._
424
425 #### Development Set-up
426
427 The following steps are intended to help users that wish to contribute to development of the CVD-Update project get started.
428
429 1. Create a fork of the [CVD-Update git repository](https://github.com/Cisco-Talos/cvdupdate), and then clone your fork to a local directory.
430
431 For example:
432
433 ```bash
434 git clone https://github.com/<your username>/cvdupdate.git
435 ```
436
437 2. Make sure CVD-Update is not already installed. If it is, remove it.
438
439 ```bash
440 python3 -m pip uninstall cvdupdate
441 ```
442
443 3. Use pip to install CVD-Update in "edit" mode.
444
445 ```bash
446 python3 -m pip install -e --user ./cvdupdate
447 ```
448
449 Once installed in "edit" mode, any changes you make to your clone of the CVD-Update code will be immediately usable simply by running the `cvdupdate` / `cvd` commands.
450
451 ### Conduct
452
453 This 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.
454
455 ## License
456
457 CVD-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.
458
459 A copy of the license is located [here](LICENSE), and is also available online at [apache.org](http://www.apache.org/licenses/LICENSE-2.0).
460
461 Unless required by applicable law or agreed to in writing, software
462 distributed under the License is distributed on an "AS IS" BASIS,
463 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
464 See the License for the specific language governing permissions and
465 limitations under the License.