Skip to content

Commit

Permalink
squashme: fix options to disable/enable onenote parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
micahsnyder committed Nov 28, 2023
1 parent cf9a608 commit 3c938b5
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 1 deletion.
7 changes: 7 additions & 0 deletions clamd/server-th.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,13 @@ int recvloop(int *socketds, unsigned nsockets, struct cl_engine *engine, unsigne
logg(LOGG_INFO, "HWP3 support disabled.\n");
}

if (optget(opts, "ScanOneNote")->enabled) {
logg(LOGG_INFO, "OneNote support enabled.\n");
options.parse |= CL_SCAN_PARSE_ONENOTE;
} else {
logg(LOGG_INFO, "OneNote support disabled.\n");
}

if (optget(opts, "PhishingScanURLs")->enabled) {
/* TODO: Remove deprecated option in a future feature release */
if ((optget(opts, "PhishingAlwaysBlockCloak")->enabled) ||
Expand Down
1 change: 1 addition & 0 deletions clamscan/clamscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ void help(void)
mprintf(LOGG_INFO, " --scan-html[=yes(*)/no] Scan HTML files\n");
mprintf(LOGG_INFO, " --scan-xmldocs[=yes(*)/no] Scan xml-based document files\n");
mprintf(LOGG_INFO, " --scan-hwp3[=yes(*)/no] Scan HWP3 files\n");
mprintf(LOGG_INFO, " --scan-onenote[=yes(*)/no] Scan OneNote files\n");
mprintf(LOGG_INFO, " --scan-archive[=yes(*)/no] Scan archive files (supported by libclamav)\n");
mprintf(LOGG_INFO, " --alert-broken[=yes/no(*)] Alert on broken executable files (PE & ELF)\n");
mprintf(LOGG_INFO, " --alert-broken-media[=yes/no(*)] Alert on broken graphics files (JPEG, TIFF, PNG, GIF)\n");
Expand Down
3 changes: 3 additions & 0 deletions clamscan/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,9 @@ int scanmanager(const struct optstruct *opts)
if (optget(opts, "scan-hwp3")->enabled)
options.parse |= CL_SCAN_PARSE_HWP3;

if (optget(opts, "scan-onenote")->enabled)
options.parse |= CL_SCAN_PARSE_ONENOTE;

/* TODO: Remove deprecated option in a future feature release */
if ((optget(opts, "algorithmic-detection")->enabled) && /* && used due to default-yes for both options */
(optget(opts, "heuristic-alerts")->enabled)) {
Expand Down
2 changes: 2 additions & 0 deletions common/optparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ const struct clam_option __clam_options[] = {

{"ScanHWP3", "scan-hwp3", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option enables scanning HWP3 files.\nIf you turn off this option, the original files will still be scanned, but\nwithout additional processing.", "yes"},

{"ScanOneNote", "scan-onenote", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option enables scanning OneNote files.\nIf you turn off this option, the original files will still be scanned, but\nwithout additional processing.", "yes"},

{"ScanArchive", "scan-archive", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Scan within archives and compressed files.\nIf you turn off this option, the original files will still be scanned, but\nwithout unpacking and additional processing.", "yes"},

{"ForceToDisk", "force-to-disk", 0, CLOPT_TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "This option causes memory or nested map scans to dump the content to disk.\nIf you turn on this option, more data is written to disk and is available\nwhen the leave-temps option is enabled at the cost of more disk writes.", "no"},
Expand Down
7 changes: 7 additions & 0 deletions docs/man/clamd.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,13 @@ If you turn off this option, the original files will still be scanned, but witho
.br
Default: yes
.TP
\fBScanOneNote BOOL\fR
This option enables scanning OneNote files.
.br
If you turn off this option, the original files will still be scanned, but without additional processing.
.br
Default: yes
.TP
\fBScanArchive BOOL\fR
Scan within archives and compressed files.
.br
Expand Down
6 changes: 6 additions & 0 deletions etc/clamd.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ Example
# Default: yes
#ScanHWP3 yes

# This option enables scanning of OneNote files.
# If you turn off this option, the original files will still be scanned, but
# without additional processing.
# Default: yes
#ScanOneNote yes


##
## Mail files
Expand Down
1 change: 1 addition & 0 deletions libclamav/clamav.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ struct cl_scan_options {
#define CL_SCAN_PARSE_OLE2 0x80
#define CL_SCAN_PARSE_HTML 0x100
#define CL_SCAN_PARSE_PE 0x200
#define CL_SCAN_PARSE_ONENOTE 0x400

/* heuristic alerting options */
#define CL_SCAN_HEURISTIC_BROKEN 0x2 /* alert on broken PE and broken ELF files */
Expand Down
1 change: 1 addition & 0 deletions libclamav/dconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ static struct dconf_module modules[] = {
{"DOCUMENT", "OOXML", DOC_CONF_OOXML, 1},
{"DOCUMENT", "MSPML", DOC_CONF_MSXML, 1},
{"DOCUMENT", "HWP", DOC_CONF_HWP, 1},
{"DOCUMENT", "ONENOTE", DOC_CONF_ONENOTE, 1},

{"MAIL", "MBOX", MAIL_CONF_MBOX, 1},
{"MAIL", "TNEF", MAIL_CONF_TNEF, 1},
Expand Down
1 change: 1 addition & 0 deletions libclamav/dconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ struct cli_dconf {
#define DOC_CONF_MSXML 0x80
#define DOC_CONF_OOXML 0x100
#define DOC_CONF_HWP 0x200
#define DOC_CONF_ONENOTE 0x400

/* Mail flags */
#define MAIL_CONF_MBOX 0x1
Expand Down
1 change: 1 addition & 0 deletions libclamav/others.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ extern LIBCLAMAV_EXPORT int have_rar;
#define SCAN_PARSE_OLE2 (ctx->options->parse & CL_SCAN_PARSE_OLE2)
#define SCAN_PARSE_HTML (ctx->options->parse & CL_SCAN_PARSE_HTML)
#define SCAN_PARSE_PE (ctx->options->parse & CL_SCAN_PARSE_PE)
#define SCAN_PARSE_ONENOTE (ctx->options->parse & CL_SCAN_PARSE_ONENOTE)

#define SCAN_HEURISTIC_BROKEN (ctx->options->heuristic & CL_SCAN_HEURISTIC_BROKEN)
#define SCAN_HEURISTIC_BROKEN_MEDIA (ctx->options->heuristic & CL_SCAN_HEURISTIC_BROKEN_MEDIA)
Expand Down
2 changes: 1 addition & 1 deletion libclamav/scanners.c
Original file line number Diff line number Diff line change
Expand Up @@ -4592,7 +4592,7 @@ cl_error_t cli_magic_scan(cli_ctx *ctx, cli_file_t type)
break;

case CL_TYPE_ONENOTE:
if (SCAN_PARSE_ARCHIVE && (DCONF_ARCH & ARCH_CONF_EGG))
if (SCAN_PARSE_ONENOTE && (DCONF_ARCH & DOC_CONF_ONENOTE))
ret = scan_onenote(ctx);
break;

Expand Down
6 changes: 6 additions & 0 deletions win32/conf_examples/clamd.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ TCPAddr localhost
# Default: yes
#ScanHWP3 yes

# This option enables scanning of OneNote files.
# If you turn off this option, the original files will still be scanned, but
# without additional processing.
# Default: yes
#ScanOneNote yes


##
## Mail files
Expand Down

0 comments on commit 3c938b5

Please sign in to comment.