user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] doc: PublicInbox::SaPlugin::ListMirror manpage
Date: Tue,  8 Oct 2019 08:58:06 +0000	[thread overview]
Message-ID: <20191008085806.8514-1-e@80x24.org> (raw)

This is a plugin for SpamAssassin that happens to be quite
useful in keeping spam off lists I mirror.  Hopefully more
people can find it useful now that it has a manpage.
---
 MANIFEST                                |   1 +
 Makefile.PL                             |   3 +-
 lib/PublicInbox/SaPlugin/ListMirror.pod | 114 ++++++++++++++++++++++++
 sa_config/user/.spamassassin/user_prefs |   2 +-
 4 files changed, 118 insertions(+), 2 deletions(-)
 create mode 100644 lib/PublicInbox/SaPlugin/ListMirror.pod

diff --git a/MANIFEST b/MANIFEST
index aeeb3d83..7d2ac17c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -130,6 +130,7 @@ lib/PublicInbox/ProcessPipe.pm
 lib/PublicInbox/Qspawn.pm
 lib/PublicInbox/Reply.pm
 lib/PublicInbox/SaPlugin/ListMirror.pm
+lib/PublicInbox/SaPlugin/ListMirror.pod
 lib/PublicInbox/Search.pm
 lib/PublicInbox/SearchIdx.pm
 lib/PublicInbox/SearchIdxShard.pm
diff --git a/Makefile.PL b/Makefile.PL
index 39b9b198..adc7e518 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -13,9 +13,10 @@ my $PM_FILES = join(' ', grep(m!^lib/.*\.pm$!, @manifest));
 my %man3 = map {; # semi-colon tells Perl this is a BLOCK (and not EXPR)
 	my $base = $_;
 	my $mod = $base;
+	$mod =~ s!/!::!g;
 	$mod =~ s/\.\w+\z//;
 	"lib/PublicInbox/$_" => "blib/man3/PublicInbox::$mod.3"
-} qw(Git.pm Import.pm WWW.pod);
+} qw(Git.pm Import.pm WWW.pod SaPlugin/ListMirror.pod);
 
 WriteMakefile(
 	NAME => 'PublicInbox',
diff --git a/lib/PublicInbox/SaPlugin/ListMirror.pod b/lib/PublicInbox/SaPlugin/ListMirror.pod
new file mode 100644
index 00000000..bb54c1fe
--- /dev/null
+++ b/lib/PublicInbox/SaPlugin/ListMirror.pod
@@ -0,0 +1,114 @@
+=head1 NAME
+
+PublicInbox::SaPlugin::ListMirror - SpamAssassin plugin for mailing list mirrors
+
+=head1 SYNOPSIS
+
+  loadplugin PublicInbox::SaPlugin::ListMirror
+
+Declare some mailing lists based on the expected List-Id value,
+expected servers, and mailing list address:
+
+  list_mirror List-Id <foo.example.com> *.example.com foo@example.com
+  list_mirror List-Id <bar.example.com> *.example.com bar@example.com
+
+Bump the score for messages which come from unexpected servers:
+
+  header LIST_MIRROR_RECEIVED eval:check_list_mirror_received()
+  describe LIST_MIRROR_RECEIVED Received does not match expected
+  score LIST_MIRROR_RECEIVED 10
+
+Bump the score for messages which Bcc the list:
+
+  header LIST_MIRROR_BCC eval:check_list_mirror_bcc()
+  describe LIST_MIRROR_BCC Mailing list was Bcc-ed
+  score LIST_MIRROR_BCC 5
+
+=head1 DESCRIPTION
+
+This plugin contains common functions to provide accurate, ongoing
+mirrors of existing mailing lists.  It may be used independently of the
+rest of public-inbox, it does not depend on any public-inbox code, only
+SpamAssassin.
+
+=head1 ADMINISTRATOR SETTINGS
+
+This plugin has no administrator settings, aside from the need
+to load it via C<loadplugin> and enabling user rules
+C<allow_user_rules 1>
+
+=head1 USER SETTINGS
+
+=over 4
+
+=item list_mirror HEADER HEADER_VALUE HOSTNAME_GLOB [LIST_ADDRESS]
+
+Declare a list based on an expected C<HEADER> matching C<HEADER_NAME>
+exactly coming from C<HOSTNAME_GLOB>.  C<LIST_ADDRESS> is optional,
+but may specify the address of the mailing list being mirrored.
+
+C<List-Id> or C<X-Mailing-List> are common values of C<HEADER>
+
+An example of C<HEADER_VALUE> is C<E<lt>foo.example.orgE<gt>>
+if C<HEADER> is C<List-Id>.
+
+C<HOSTNAME_GLOB> may be a wildcard match for machines where mail can
+come from or an exact match.
+
+C<LIST_ADDRESS> is only required if using the L</check_list_mirror_bcc>
+eval rule
+
+C<list_mirror> may be specified multiple times.
+
+=back
+
+=head1 EVAL FUNCTIONS
+
+=over 4
+
+=item header LIST_MIRROR_RECEIVED eval:check_list_mirror_received()
+
+The C<check_list_mirror_received> function implements C<Received:>
+header checking based on L</list_mirror> configuration values.
+
+This rule can be used to score and prevent messages from being injected
+directly into your mirror without going through the expected mailing
+list servers:
+
+  ifplugin PublicInbox::SaPlugin::ListMirror
+    header LIST_MIRROR_RECEIVED eval:check_list_mirror_received()
+    describe LIST_MIRROR_RECEIVED Received does not match expected
+  endif
+
+=item header LIST_MIRROR_BCC eval:check_list_mirror_bcc()
+
+The C<check_list_mirror_bcc> function checks for Bcc to mailing lists
+declared with a C<LIST_ADDRESS> via L</list_mirror>
+
+Spammers will often Bcc mailing lists; while it's uncommon and
+strange for valid messages to be Bcc-ed to any public mailing list.
+This rule allows users to assign a score to Bcc-ed messages
+
+  ifplugin PublicInbox::SaPlugin::ListMirror
+    header LIST_MIRROR_BCC eval:check_list_mirror_bcc()
+    describe LIST_MIRROR_BCC Mailing list was Bcc-ed
+  endif
+
+=back
+
+=head1 CONTACT
+
+Feedback welcome via plain-text mail to L<mailto:meta@public-inbox.org>
+
+The mail archives are hosted at L<https://public-inbox.org/meta/>
+and L<http://hjrcffqmbrq6wope.onion/meta/>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2016-2019 all contributors L<mailto:meta@public-inbox.org>
+
+License: AGPL-3.0+ L<http://www.gnu.org/licenses/agpl-3.0.txt>
+
+=head1 SEE ALSO
+
+L<Mail::SpamAssassin::Conf>
diff --git a/sa_config/user/.spamassassin/user_prefs b/sa_config/user/.spamassassin/user_prefs
index 9c3bb16c..34c3dc03 100644
--- a/sa_config/user/.spamassassin/user_prefs
+++ b/sa_config/user/.spamassassin/user_prefs
@@ -102,7 +102,7 @@ score RCVD_IN_RP_CERTIFIED 0.0
 
 # this depends on PublicInbox::SaPlugin::ListMirror:
 # header LIST_MIRROR_RECEIVED eval:check_list_mirror_received()
-# describe LIST_MIRROR_RECEIVED Received does not match trusted list server
+# describe LIST_MIRROR_RECEIVED Received does not match expected
 # score LIST_MIRROR_RECEIVED 10
 #
 # this depends on PublicInbox::SaPlugin::ListMirror:

                 reply	other threads:[~2019-10-08  8:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191008085806.8514-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).