27.11.2012 Views

IronPort - advanced configuration guide

IronPort - advanced configuration guide

IronPort - advanced configuration guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Writing Efficient Filters<br />

PDFs and Regular Expressions<br />

6-18<br />

Cisco <strong>IronPort</strong> AsyncOS 7.6 for Email Advanced Configuration Guide<br />

Chapter 6 Using Message Filters to Enforce Email Policies<br />

This example shows two filters that do the same thing, but the first one takes much more CPU. The<br />

second filter uses a regular expression that is more efficient.<br />

attachment-filter: if ((recv-listener == "Inbound") AND<br />

((((((((((((((((((((((((((((((((((((((((((((((attachment-filename ==<br />

"\\.386$") OR (attachment-filename == "\\.exe$")) OR (attachment-filename == "\\.ad$"))<br />

OR (attachment-filename == "\\.ade$")) OR (attachment-filename == "\\.adp$")) OR<br />

(attachment-filename == "\\.asp$")) OR (attachment-filename == "\\.bas$")) OR<br />

(attachment-filename == "\\.bat$")) OR (attachment-filename == "\\.chm$")) OR<br />

(attachment-filename == "\\.cmd$")) OR (attachment-filename == "\\.com$")) OR<br />

(attachment-filename == "\\.cpl$")) OR (attachment-filename == "\\.crt$")) OR<br />

(attachment-filename == "\\.exe$")) OR (attachment-filename == "\\.hlp$")) OR<br />

(attachment-filename == "\\.hta$")) OR (attachment-filename == "\\.inf$")) OR<br />

(attachment-filename == "\\.ins$")) OR (attachment- filename == "\\.isp$")) OR<br />

(attachment-filename == "\\.js$")) OR (attachment-filename == "\\.jse$")) OR<br />

(attachment- filename == "\\.lnk$")) OR (attachment-filename == "\\.mdb$")) OR<br />

(attachment-filename == "\\.mde$")) OR (attachment-filename == "\\.msc$")) OR<br />

(attachment-filename == "\\.msi$")) OR (attachment-filename == "\\.msp$")) OR<br />

(attachment-filename == "\\.mst$")) OR (attachment-filename == "\\.pcd$")) OR<br />

(attachment-filename == "\\.pif$")) OR (attachment-filename == "\\.reg$")) OR<br />

(attachment-filename == "\\.scr$")) OR (attachment-filename == "\\.sct$")) OR<br />

(attachment-filename == "\\.shb$")) OR (attachment-filename == "\\.shs$")) OR<br />

(attachment-filename == "\\.url$")) OR (attachment-filename == "\\.vb$")) OR<br />

(attachment-filename == "\\.vbe$")) OR (attachment-filename == "\\.vbs$")) OR<br />

(attachment-filename == "\\.vss$")) OR (attachment-filename == "\\.vst$")) OR<br />

(attachment-filename == "\\.vsw$")) OR (attachment-filename == "\\.ws$")) OR<br />

(attachment-filename == "\\.wsc$")) OR (attachment-filename == "\\.wsf$")) OR<br />

(attachment-filename == "\\.wsh$"))) { bounce(); }<br />

In this instance, AsyncOS will have to start the regular expression engine 30 times, once for each<br />

attachment type and the recv-listener.<br />

Instead, write the filter to look like this:<br />

attachment-filter: if (recv-listener == "Inbound") AND (attachment-filename ==<br />

"\\.(386|exe|ad|ade|adp|asp|bas|bat|chm|cmd|com|cpl|crt|exe|hlp|hta|inf|ins|isp|js|jse|l<br />

nk|mdb|mde|msc|msi|msp|mst|pcd|pif|reg|scr|sct|shb|shs|url|vb|vbe|vbs|vss|vst|vsw|ws|wsc<br />

|wsf|wsh)$") {<br />

}<br />

bounce();<br />

The regular expression engine only has to start twice and the filter is arguably easier to maintain as you<br />

do not have to worry about adding “()”, spelling errors. In contrast to the above, this should show a<br />

decrease in CPU overhead.<br />

Depending on how a PDF is generated, it may contain no spaces or line breaks. When this occurs, the<br />

scanning engine attempts to insert logical spaces and line breaks based on the location of the words on<br />

the page. For example, when a word is constructed using multiple fonts or font sizes, the PDF code is<br />

OL-25137-01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!