Given the increased reliance on XML in scripts and exchanging data, a number of different solutions leverage XML traversal options to get all the things done. We frequently use path to bring a file into a script or program, or accept input from STDIN. The most basic task that we then perform is simply selecting an item from that file or STDIN and then variabalizing it. One common tool that we use here is Path. XPath calls these objects nodes, and uses path expressions to select these nodes. A path expression is the path along the xml input that is followed to find a piece of data.
There are some pretty standard wildcards the can be used with xpath, where node() watches any node, * matches any element node, @* matches any attribute node, helping to constrain output.
Supported expressions include:
Overall, as you can see xpath really makes traversing XML structures simple. Other tools and languages have their own ways, but most are similar in syntax.
krypted November 15th, 2016
The built-in message hygiene in Lion Server is provided by Spam Assassin and clamav (amavis). Lion Server’s Server Admin application has an easy-to-use way of configuring some of the more basic settings for Spam Assassin. Spam Assassin’s rules are configured in /etc/mail/spamassassin/local.cf. If you open this into a standard text editor then you can insert blocks that are rules. Each rule has the ability to either locate text within a header (such as an email address), a subject or in the text of an email. To use Spam Assassin to block messages that have the word viagra in them, for example, you would insert the following block:
body NO_MORE_VIAGRA /viagra/i
score NO_MORE_VIAGRA 10
description NO_MORE_VIAGRA messages that contain the word Viagra
The first line looks for any email with the word viagra. The second line assigns it a score of 10 and the third gives us an easy to read description. You can also effectively whitelist email addresses or words. For example, the following would subtract 100 from the score of any email sent from my iCloud account:
header FROM_KRYPTED ALL =~ /email@example.com/i
score FROM_KRYPTED -100
description FROM_KRYPTED messages from krypted
The above block is similar to the previous one, but instead of adding to the likelihood that the message is spam we’re subtracting so much that even if I’m talking about viagra, the message still wouldn’t be flagged as spam.
Once you’ve entered the rules that you feel are needed for your environment, run the spam assassin command followed by the –lint option:
krypted March 29th, 2012