Browse code

add switches for pdf

git-svn: trunk@2841

Tomasz Kojm authored on 2007/02/23 02:49:57
Showing 13 changed files
... ...
@@ -1,3 +1,10 @@
1
+Thu Feb 22 16:51:33 CET 2007 (tk)
2
+---------------------------------
3
+  * libclamav: new scan setting CL_SCAN_PDF
4
+  * clamd: new option ScanPDF (default: no)
5
+  * clamscan: new switch --no-pdf (PDF scanning enabled by default)
6
+  * docs: update
7
+
1 8
 Thu Feb 22 15:32:33 GMT 2007 (njh)
2 9
 ----------------------------------
3 10
   * libclamav:	s/sanitiseFilename/cli_sanitise_filename/, patch from trog
... ...
@@ -412,6 +412,13 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_engine *engine, unsigne
412 412
 	logg("OLE2 support disabled.\n");
413 413
     }
414 414
 
415
+    if(cfgopt(copt, "ScanPDF")->enabled) {
416
+	logg("PDF support enabled.\n");
417
+	options |= CL_SCAN_PDF;
418
+    } else {
419
+	logg("PDF support disabled.\n");
420
+    }
421
+
415 422
     if(cfgopt(copt, "ScanHTML")->enabled) {
416 423
 	logg("HTML support enabled.\n");
417 424
 	options |= CL_SCAN_HTML;
... ...
@@ -269,6 +269,7 @@ void help(void)
269 269
     mprintf("    --no-pe                              Disable PE analysis\n");
270 270
     mprintf("    --no-elf                             Disable ELF support\n");
271 271
     mprintf("    --no-ole2                            Disable OLE2 support\n");
272
+    mprintf("    --no-pdf                             Disable PDF support\n");
272 273
     mprintf("    --no-html                            Disable HTML support\n");
273 274
     mprintf("    --no-archive                         Disable libclamav archive support\n");
274 275
     mprintf("    --detect-broken                      Try to detect broken executable files\n");
... ...
@@ -71,6 +71,7 @@ static struct option clamscan_longopt[] = {
71 71
     {"no-pe", 0, 0, 0},
72 72
     {"no-elf", 0, 0, 0},
73 73
     {"no-ole2", 0, 0, 0},
74
+    {"no-pdf", 0, 0, 0},
74 75
     {"no-html", 0, 0, 0},
75 76
     {"no-mail", 0, 0, 0},
76 77
     {"mail-follow-urls", 0, 0, 0},
... ...
@@ -269,6 +269,11 @@ int scanmanager(const struct optstruct *opt)
269 269
     else
270 270
 	options |= CL_SCAN_OLE2;
271 271
 
272
+    if(opt_check(opt, "no-pdf"))
273
+	options &= ~CL_SCAN_PDF;
274
+    else
275
+	options |= CL_SCAN_PDF;
276
+
272 277
     if(opt_check(opt, "no-html"))
273 278
 	options &= ~CL_SCAN_HTML;
274 279
     else
... ...
@@ -830,6 +830,8 @@ struct cl_limits {
830 830
 	\item \textbf{CL\_SCAN\_OLE2}\\
831 831
 	      Enables support for OLE2 containers (used by MS Office and .msi
832 832
 	      files).
833
+	\item \textbf{CL\_SCAN\_PDF}\\
834
+	      Enables scanning within PDF files.
833 835
 	\item \textbf{CL\_SCAN\_PE}\\
834 836
 	      This flag enables deep scanning of Portable Executable files and
835 837
 	      allows libclamav to unpack executables compressed with run-time
... ...
@@ -215,6 +215,11 @@ This option enables scanning of OLE2 files, such as Microsoft Office documents a
215 215
 .br 
216 216
 Default: yes
217 217
 .TP 
218
+\fBScanPDF BOOL\fR
219
+This option enables scanning within PDF files.
220
+.br 
221
+Default: no
222
+.TP 
218 223
 \fBScanHTML BOOL\fR
219 224
 Enables HTML detection and normalisation.
220 225
 .br 
... ...
@@ -99,6 +99,9 @@ Executable and Linking Format is a standard format for UN*X executables. This op
99 99
 \fB\-\-no\-ole2\fR
100 100
 Disable support for Microsoft Office documents and .msi files.
101 101
 .TP 
102
+\fB\-\-no\-pdf\fR
103
+Disable scanning within PDF files.
104
+.TP 
102 105
 \fB\-\-no\-html\fR
103 106
 Disable support for HTML detection and normalisation.
104 107
 .TP 
... ...
@@ -201,6 +201,10 @@ LocalSocket /tmp/clamd
201 201
 # Default: yes
202 202
 #ScanOLE2 yes
203 203
 
204
+# This option enables scanning within PDF files.
205
+# Default: no
206
+#ScanPDF yes
207
+
204 208
 ##
205 209
 ## Mail files
206 210
 ##
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2002 - 2006 Tomasz Kojm <tkojm@clamav.net>
2
+ *  Copyright (C) 2002 - 2007 Tomasz Kojm <tkojm@clamav.net>
3 3
  *
4 4
  *  This program is free software; you can redistribute it and/or modify
5 5
  *  it under the terms of the GNU General Public License as published by
... ...
@@ -94,6 +94,7 @@ extern "C"
94 94
 #define CL_SCAN_PHISHING_BLOCKSSL   0x800 /* ssl mismatches, not ssl by itself*/
95 95
 #define CL_SCAN_PHISHING_BLOCKCLOAK 0x1000
96 96
 #define CL_SCAN_ELF		    0x2000
97
+#define CL_SCAN_PDF		    0x4000
97 98
 
98 99
 /* recommended scan settings */
99 100
 #define CL_SCAN_STDOPT		(CL_SCAN_ARCHIVE | CL_SCAN_MAIL | CL_SCAN_OLE2 | CL_SCAN_HTML | CL_SCAN_PE | CL_SCAN_ALGORITHMIC | CL_SCAN_ELF) 
... ...
@@ -73,6 +73,7 @@ typedef struct {
73 73
 #define SCAN_ARCHIVE	    (ctx->options & CL_SCAN_ARCHIVE)
74 74
 #define SCAN_MAIL	    (ctx->options & CL_SCAN_MAIL)
75 75
 #define SCAN_OLE2	    (ctx->options & CL_SCAN_OLE2)
76
+#define SCAN_PDF	    (ctx->options & CL_SCAN_PDF)
76 77
 #define SCAN_HTML	    (ctx->options & CL_SCAN_HTML)
77 78
 #define SCAN_PE		    (ctx->options & CL_SCAN_PE)
78 79
 #define SCAN_ELF	    (ctx->options & CL_SCAN_ELF)
... ...
@@ -1958,7 +1958,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
1958 1958
 	    break;
1959 1959
 
1960 1960
 	case CL_TYPE_PDF:
1961
-	    if(SCAN_ARCHIVE && (DCONF_DOC & DOC_CONF_PDF))    /* you may wish to change this line */
1961
+	    if(SCAN_PDF && (DCONF_DOC & DOC_CONF_PDF))
1962 1962
 		ret = cli_scanpdf(desc, ctx);
1963 1963
 	    break;
1964 1964
 
... ...
@@ -61,6 +61,7 @@ struct cfgoption cfg_options[] = {
61 61
     {"AlgorithmicDetection", OPT_BOOL, 1, NULL, 0, OPT_CLAMD},
62 62
     {"ScanHTML", OPT_BOOL, 1, NULL, 0, OPT_CLAMD},
63 63
     {"ScanOLE2", OPT_BOOL, 1, NULL, 0, OPT_CLAMD},
64
+    {"ScanPDF", OPT_BOOL, 0, NULL, 0, OPT_CLAMD},
64 65
     {"ScanArchive", OPT_BOOL, 1, NULL, 0, OPT_CLAMD},
65 66
     {"ArchiveMaxFileSize", OPT_COMPSIZE, 10485760, NULL, 0, OPT_CLAMD},
66 67
     {"ArchiveMaxRecursion", OPT_NUM, 8, NULL, 0, OPT_CLAMD},