; ; SANS security digests ; (defun nndoc-sans-security-type-p nil "Decide whether an article is a SANS Security digest" (let ((case-fold-search nil)) (not (not (and (re-search-forward "^From: The SANS Institute" nil t) (re-search-forward "^[ \t]*@RISK: The Consensus Security Vulnerability Alert" nil t)) ))) ) (defun nndoc-sans-security-body-begin nil "Find the beginning of a SANS security body" (beginning-of-line) ) (defun nndoc-sans-security-body-end nil "Find the end of a SANS security body" (re-search-forward "^$") (when (looking-at "\nSHA ") (forward-line 1) (re-search-forward "^$"))) (defun nndoc-generate-sans-security-head (article) "Generate headers for a SANS security article" (let ((entry (cdr (assq article nndoc-dissection-alist))) (from "SANS") (subject "Couldn't find subject")) (save-excursion (set-buffer nndoc-current-buffer) (save-restriction (narrow-to-region (car entry) (nth 3 entry)) (goto-char (point-min)) (cond ((looking-at "^Title: \\(.*\\)$") (setq subject (match-string 1))) ((looking-at "^ID: \\(: \\)?\\(CVE-[-0-9]+\\) *$") (setq from (match-string 2)) (re-search-forward "^Title: \\(.*\\)$" nil t) (setq subject (match-string 1))) (t (re-search-forward "^\\(.*\\)$") (setq subject (match-string 1))) ))) (insert "Subject: " subject "\n" "From: " from "\n") )) (defun nndoc-transform-sans-security-article (article) "Transform a SANS security article so that it matches nndoc expectations." (goto-char (point-min)) (while (eq (following-char) ?\n) (delete-char 1)) (if (re-search-forward "^Title: " nil t) (let ((here (point)) (subjstart (point)) subject) (end-of-line) (setq subject (buffer-substring here (point))) (forward-char 1) (while (not (looking-at "^Description:")) (setq here (point)) (end-of-line) (setq subject (concat subject " " (buffer-substring here (point)))) (forward-char 1)) (setq here (point)) (goto-char subjstart) (beginning-of-line) (delete-region (point) here) (goto-char (point-min)) (insert "Subject: " subject "\n\n") )) ) (nndoc-add-type '(sans-security (article-begin . "^#[0-9]+\n\\|^ID: \\(: \\)?CVE-\\|^Title: ") (article-transform-function . nndoc-transform-sans-security-article) (head-end . "\n") (body-begin-function . nndoc-sans-security-body-begin) (body-end-function . nndoc-sans-security-body-end) (file-end . "^(c) 20[0-9][0-9]. +All rights reserved.") (generate-head-function . nndoc-generate-sans-security-head) ))