SlideShare a Scribd company logo
SYMBOLS AND RULES
RSPAMD
WHAT ARE SYMBOLS AND RULES
DEFINITIONS
RULE SYMBOL
SCORE
GROUP
DESCRIPTION
WEIGHT
*
true/false
OPTIONS
Dynamic part
Static part
∑ Results
FLAGS
WHAT ARE SYMBOLS AND RULES
WHY DO WE NEED SYMBOLS
RULE
SYMBOL_ALLOW
SYMBOL_DENY
SYMBOL_UNKNOWN
Either of symbols
WHAT ARE SYMBOLS AND RULES
WHY DO WE NEED SYMBOLS
RULE
MAP1
MAP2
MAP3
Multiple symbols
WHAT ARE SYMBOLS AND RULES
WHY DO WE NEED SYMBOLS
RULE1 SYMBOL1
RULE2
Dependency
WHAT ARE SYMBOLS AND RULES
RULES
▸ Rules define what is executed:
▸ Regexps expression
▸ Lua code
▸ Plugin logic
▸ Each rule can be associated with one or many symbols
▸ Rule can depend on other rules identified by associated symbols
▸ Each rule can define the current dynamic weight (usually from 0 to 1)
WHAT ARE SYMBOLS AND RULES
SYMBOLS
▸ Symbols define meta-information of a rule:
▸ Name
▸ Static score
▸ Other data (description, group, flags, etc)
▸ Symbols can be:
▸ Normal: associated with exactly one rule
▸ Virtual: are not associated with rules but grouped with normal symbol)
▸ Callback: do not have name or score, just define common rule
▸ Special: have special purpose (e.g. composite symbols)
SYMBOLS
SYMBOLS GROUPS
SYMBOL1
SYMBOL2
SYMBOL3
SYMBOL4
Group1
SYMBOL3
SYMBOL4
SYMBOL5
SYMBOL6
Group2
GROUP LIMIT
GROUP DESCRIPTION
SYMBOLS
SYMBOLS GROUPS
▸ Groups join common symbols logically
▸ Groups can set joint limit for symbols scores enclosed
▸ Groups can be used in composite rules:
▸ SYMBOL5 && G:GROUP1
▸ SYMBOL5 && (G:GROUP1 || !G:GROUP2)
RULES
EXPRESSIONS IN RULES
▸ Expressions are used in:
▸ Regexp rules
▸ Composite symbols
▸ Expressions have common syntax:
▸ Logic operations: AND (&&), OR (||), NOT (!)
▸ Braces
▸ Limit operation: A + B + C > 2
▸ Elements are called atoms
RULES
REGEXP EXPRESSIONS
▸ Atoms are regular expressions (/re/flags):
▸ Header: Header=/re/H
▸ Mime (/P): scan text parts
▸ Body (/B): scan full undecoded body
▸ URL (/U): scan URLs found
▸ There is no order of regexps execution within an expression
▸ Same expressions are cached and executed once
COMPOSITE EXPRESSIONS
COMPOSITES STRUCTURE
SYMBOL3
SYMBOL4
SYMBOL5
SYMBOL1
Group2
NOT SYMBOL6
AND
SYMBOL1 AND GR:GROUP2 AND !SYMBOL6
AND
COMPOSITE EXPRESSIONS
COMPOSITES OPERATIONS
SYMBOL3
SYMBOL4
SYMBOL5
SYMBOL1
Group2
NOT SYMBOL6
AND AND
SYMBOL1
SYMBOL3
Symbols to remove
Stage 1: Check
Stage 2: Remove symbols
COMPOSITE EXPRESSIONS
COMPOSITES STRUCTURE
▸ Composite atoms can include:
▸ Other symbols
▸ Groups (gr:)
▸ Other composites (with recursive references check)
▸ Composite operations can be the following:
▸ Remove symbol and weight (SYMBOL)
▸ Remove weight only (~SYMBOL)
▸ Remove symbol but preserve weight (-SYMBOL)
▸ Always remove symbol and weight (^SYMBOL)
COMPOSITE EXPRESSIONS
COMPOSITES OPERATION
▸ If any composite proposes that a symbol should NOT be
removed, then it is NOT removed:
▸ A & ~B and C & B: B will NOT be removed because of the
first rule, but its weight will be removed
▸ A & -B and C & ~B: neither weight, nor symbol B will be
removed
▸ Removal could be forced by “^” symbol:
▸ A & ^B and C & -B: weight and symbol B are both removed
PRACTICAL EXAMPLES
A SIMPLE REGEXP EXPRESSION
local reconf = config['regexp'] -- Define alias for regexp module
-- Define a single regexp rule
reconf['PRECEDENCE_BULK'] = {
-- Header regexp that detects bulk email
re = 'Precedence=/bulk/Hi',
-- Default score
score = 0.1,
description = "Message marked as bulk",
group = 'upstream_spam_filters'
}
rspamd.local.lua:
PRACTICAL EXAMPLES
A MORE COMPLEX EXAMPLE
rspamd.local.lua:
local reconf = config['regexp'] -- Define alias for regexp module
-- Define encodings types
-- /X is undecoded header
local subject_encoded_b64 = 'Subject=/=?S+?B?/iX'
local subject_encoded_qp = 'Subject=/=?S+?Q?/iX'
-- Define whether subject must be encoded (contains non-7bit characters)
local subject_needs_mime = 'Subject=/[x00-x08x0bx0cx0e-x1fx7f-xff]/X'
-- Final rule
reconf['SUBJECT_NEEDS_ENCODING'] = {
-- Combine regexps
re = string.format('!(%s) & !(%s) & (%s)', subject_encoded_b64,
subject_encoded_qp, subject_needs_mime),
score = 3.5,
description = "Subject contains non-ASCII chars but it is not encoded",
group = 'headers'
}
PRACTICAL EXAMPLES
A MORE COMPLEX EXAMPLE
rspamd.local.lua:
local reconf = config['regexp'] -- Define alias for regexp module
-- Define encodings types
-- /X is undecoded header
local subject_encoded_b64 = 'Subject=/=?S+?B?/iX'
local subject_encoded_qp = 'Subject=/=?S+?Q?/iX'
-- Define whether subject must be encoded (contains non-7bit characters)
local subject_needs_mime = 'Subject=/[x00-x08x0bx0cx0e-x1fx7f-xff]/X'
-- Final rule
reconf['SUBJECT_NEEDS_ENCODING'] = {
-- Combine regexps
re = string.format('!(%s) & !(%s) & (%s)', subject_encoded_b64,
subject_encoded_qp, subject_needs_mime),
score = 3.5,
description = "Subject contains non-ASCII chars but it is not encoded",
group = 'headers'
}
PRACTICAL EXAMPLES
A MORE COMPLEX EXAMPLE
rspamd.local.lua:
local reconf = config['regexp'] -- Define alias for regexp module
-- Define encodings types
-- /X is undecoded header
local subject_encoded_b64 = 'Subject=/=?S+?B?/iX'
local subject_encoded_qp = 'Subject=/=?S+?Q?/iX'
-- Define whether subject must be encoded (contains non-7bit characters)
local subject_needs_mime = 'Subject=/[x00-x08x0bx0cx0e-x1fx7f-xff]/X'
-- Final rule
reconf['SUBJECT_NEEDS_ENCODING'] = {
-- Combine regexps
re = string.format('!(%s) & !(%s) & (%s)', subject_encoded_b64,
subject_encoded_qp, subject_needs_mime),
score = 3.5,
description = "Subject contains non-ASCII chars but it is not encoded",
group = 'headers'
}
PRACTICAL EXAMPLES
COMPOSITES EXAMPLE
local.d/composites.conf:
# Ignore forged recipients in case of mailing list
composite "FORGED_RECIPIENTS_MAILLIST" {
# MALLIST symbol is preserved
expression = "FORGED_RECIPIENTS & -MAILLIST";
}
# Ignore forged sender if a message has been forwarded
composite "FORGED_SENDER_FORWARDING" {
# Symbols from `forwarding` group are removed
expression = "FORGED_SENDER & g:forwarding";
}
# Ignore forged sender if a message has been from the mailing list
composite "FORGED_SENDER_MAILLIST" {
# Symbol 'FORGED_SENDER' is forced to be removed
expression = "^FORGED_SENDER & -MAILLIST";
}
PRACTICAL EXAMPLES
COMPOSITES EXAMPLE
local.d/composites.conf:
# Ignore forged recipients in case of mailing list
composite "FORGED_RECIPIENTS_MAILLIST" {
# MALLIST symbol is preserved
expression = "FORGED_RECIPIENTS & -MAILLIST";
}
# Ignore forged sender if a message has been forwarded
composite "FORGED_SENDER_FORWARDING" {
# Symbols from `forwarding` group are removed
expression = "FORGED_SENDER & g:forwarding";
}
# Ignore forged sender if a message has been from the mailing list
composite "FORGED_SENDER_MAILLIST" {
# Symbol 'FORGED_SENDER' is forced to be removed
expression = "^FORGED_SENDER & -MAILLIST";
}
PRACTICAL EXAMPLES
COMPOSITES EXAMPLE
local.d/composites.conf:
# Ignore forged recipients in case of mailing list
composite "FORGED_RECIPIENTS_MAILLIST" {
# MALLIST symbol is preserved
expression = "FORGED_RECIPIENTS & -MAILLIST";
}
# Ignore forged sender if a message has been forwarded
composite "FORGED_SENDER_FORWARDING" {
# Symbols from `forwarding` group are removed
expression = "FORGED_SENDER & g:forwarding";
}
# Ignore forged sender if a message has been from the mailing list
composite "FORGED_SENDER_MAILLIST" {
# Symbol 'FORGED_SENDER' is forced to be removed
expression = "^FORGED_SENDER & -MAILLIST";
}
PRACTICAL EXAMPLES
COMPOSITES EXAMPLE
local.d/composites.conf:
# Ignore forged recipients in case of mailing list
composite "FORGED_RECIPIENTS_MAILLIST" {
# MALLIST symbol is preserved
expression = "FORGED_RECIPIENTS & -MAILLIST";
}
# Ignore forged sender if a message has been forwarded
composite "FORGED_SENDER_FORWARDING" {
# Symbols from `forwarding` group are removed
expression = "FORGED_SENDER & g:forwarding";
}
# Ignore forged sender if a message has been from the mailing list
composite "FORGED_SENDER_MAILLIST" {
# Symbol 'FORGED_SENDER' is forced to be removed
expression = "^FORGED_SENDER & -MAILLIST";
}
PRACTICAL EXAMPLES
COMPOSITES EXAMPLE
local.d/composites.conf:
# Ignore forged recipients in case of mailing list
composite "FORGED_RECIPIENTS_MAILLIST" {
# MALLIST symbol is preserved
expression = "FORGED_RECIPIENTS & -MAILLIST";
}
# Ignore forged sender if a message has been forwarded
composite "FORGED_SENDER_FORWARDING" {
# Symbols from `forwarding` group are removed
expression = "FORGED_SENDER & g:forwarding";
}
# Ignore forged sender if a message has been from the mailing list
composite "FORGED_SENDER_MAILLIST" {
# Symbol 'FORGED_SENDER' is forced to be removed
expression = "^FORGED_SENDER & -MAILLIST";
}

More Related Content

What's hot

Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...
Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...
Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...
Databricks
 
Architecting Modern Data Platforms
Architecting Modern Data PlatformsArchitecting Modern Data Platforms
Architecting Modern Data Platforms
Ankit Rathi
 
Introduction to azure cosmos db
Introduction to azure cosmos dbIntroduction to azure cosmos db
Introduction to azure cosmos db
Ratan Parai
 
Sizing Your MongoDB Cluster
Sizing Your MongoDB ClusterSizing Your MongoDB Cluster
Sizing Your MongoDB Cluster
MongoDB
 
Kappa vs Lambda Architectures and Technology Comparison
Kappa vs Lambda Architectures and Technology ComparisonKappa vs Lambda Architectures and Technology Comparison
Kappa vs Lambda Architectures and Technology Comparison
Kai Wähner
 
한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019
한국어를 위한  AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019한국어를 위한  AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019
한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019
Amazon Web Services Korea
 
Webinar: When to Use MongoDB
Webinar: When to Use MongoDBWebinar: When to Use MongoDB
Webinar: When to Use MongoDB
MongoDB
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data Storage
Bethmi Gunasekara
 
Deep Dive Amazon Redshift for Big Data Analytics - September Webinar Series
Deep Dive Amazon Redshift for Big Data Analytics - September Webinar SeriesDeep Dive Amazon Redshift for Big Data Analytics - September Webinar Series
Deep Dive Amazon Redshift for Big Data Analytics - September Webinar Series
Amazon Web Services
 
Cloudera Hadoop Distribution
Cloudera Hadoop DistributionCloudera Hadoop Distribution
Cloudera Hadoop Distribution
Thisara Pramuditha
 
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
confluent
 
Building Robust Production Data Pipelines with Databricks Delta
Building Robust Production Data Pipelines with Databricks DeltaBuilding Robust Production Data Pipelines with Databricks Delta
Building Robust Production Data Pipelines with Databricks Delta
Databricks
 
Azure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse Analytics
WinWire Technologies Inc
 
Introduction to Greenplum
Introduction to GreenplumIntroduction to Greenplum
Introduction to Greenplum
Dave Cramer
 
Hadoop
HadoopHadoop
Getting started with postgresql
Getting started with postgresqlGetting started with postgresql
Getting started with postgresql
botsplash.com
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)
Anastasia Lubennikova
 
Virtualization - Sanallaştırma
Virtualization - SanallaştırmaVirtualization - Sanallaştırma
Virtualization - SanallaştırmaMustafa Tanyer
 
Strata sf - Amundsen presentation
Strata sf - Amundsen presentationStrata sf - Amundsen presentation
Strata sf - Amundsen presentation
Tao Feng
 

What's hot (20)

Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...
Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...
Solving Data Discovery Challenges at Lyft with Amundsen, an Open-source Metad...
 
Architecting Modern Data Platforms
Architecting Modern Data PlatformsArchitecting Modern Data Platforms
Architecting Modern Data Platforms
 
Introduction to azure cosmos db
Introduction to azure cosmos dbIntroduction to azure cosmos db
Introduction to azure cosmos db
 
Sizing Your MongoDB Cluster
Sizing Your MongoDB ClusterSizing Your MongoDB Cluster
Sizing Your MongoDB Cluster
 
Kappa vs Lambda Architectures and Technology Comparison
Kappa vs Lambda Architectures and Technology ComparisonKappa vs Lambda Architectures and Technology Comparison
Kappa vs Lambda Architectures and Technology Comparison
 
한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019
한국어를 위한  AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019한국어를 위한  AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019
한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희 솔루션즈 아키텍트, AWS :: AWS Innovate 2019
 
Webinar: When to Use MongoDB
Webinar: When to Use MongoDBWebinar: When to Use MongoDB
Webinar: When to Use MongoDB
 
No SQL- The Future Of Data Storage
No SQL- The Future Of Data StorageNo SQL- The Future Of Data Storage
No SQL- The Future Of Data Storage
 
Deep Dive Amazon Redshift for Big Data Analytics - September Webinar Series
Deep Dive Amazon Redshift for Big Data Analytics - September Webinar SeriesDeep Dive Amazon Redshift for Big Data Analytics - September Webinar Series
Deep Dive Amazon Redshift for Big Data Analytics - September Webinar Series
 
Cloudera Hadoop Distribution
Cloudera Hadoop DistributionCloudera Hadoop Distribution
Cloudera Hadoop Distribution
 
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
 
Building Robust Production Data Pipelines with Databricks Delta
Building Robust Production Data Pipelines with Databricks DeltaBuilding Robust Production Data Pipelines with Databricks Delta
Building Robust Production Data Pipelines with Databricks Delta
 
Azure Synapse Analytics
Azure Synapse AnalyticsAzure Synapse Analytics
Azure Synapse Analytics
 
Introduction to Greenplum
Introduction to GreenplumIntroduction to Greenplum
Introduction to Greenplum
 
Hadoop
HadoopHadoop
Hadoop
 
Getting started with postgresql
Getting started with postgresqlGetting started with postgresql
Getting started with postgresql
 
Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)Advanced backup methods (Postgres@CERN)
Advanced backup methods (Postgres@CERN)
 
NoSql
NoSqlNoSql
NoSql
 
Virtualization - Sanallaştırma
Virtualization - SanallaştırmaVirtualization - Sanallaştırma
Virtualization - Sanallaştırma
 
Strata sf - Amundsen presentation
Strata sf - Amundsen presentationStrata sf - Amundsen presentation
Strata sf - Amundsen presentation
 

Viewers also liked

Pkg slides from BSDCan conference
Pkg slides from BSDCan conferencePkg slides from BSDCan conference
Pkg slides from BSDCan conference
Vsevolod Stakhov
 
New solver for FreeBSD pkg
New solver for FreeBSD pkgNew solver for FreeBSD pkg
New solver for FreeBSD pkg
Vsevolod Stakhov
 
Cryptography and secure systems
Cryptography and secure systemsCryptography and secure systems
Cryptography and secure systems
Vsevolod Stakhov
 

Viewers also liked (6)

Pkg slides from BSDCan conference
Pkg slides from BSDCan conferencePkg slides from BSDCan conference
Pkg slides from BSDCan conference
 
ast-rspamd
ast-rspamdast-rspamd
ast-rspamd
 
New solver for FreeBSD pkg
New solver for FreeBSD pkgNew solver for FreeBSD pkg
New solver for FreeBSD pkg
 
rspamd-hyperscan
rspamd-hyperscanrspamd-hyperscan
rspamd-hyperscan
 
Cryptography and secure systems
Cryptography and secure systemsCryptography and secure systems
Cryptography and secure systems
 
rspamd-slides
rspamd-slidesrspamd-slides
rspamd-slides
 

Similar to Rspamd symbols

Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)ujihisa
 
Array and functions
Array and functionsArray and functions
Array and functions
Sun Technlogies
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisaujihisa
 
Advanced REXX Programming Techniques
Advanced REXX Programming TechniquesAdvanced REXX Programming Techniques
Advanced REXX Programming Techniques
Dan O'Dea
 
Regular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And BeyondRegular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And Beyond
Max Shirshin
 
Functions
FunctionsFunctions
Functions
Ankit Dubey
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat Sheet
Laura Hughes
 
PE1 Module 4.ppt
PE1 Module 4.pptPE1 Module 4.ppt
PE1 Module 4.ppt
balewayalew
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technologyppparthpatel123
 
Gnu octave help book 02 of 02
Gnu octave help book 02 of 02Gnu octave help book 02 of 02
Gnu octave help book 02 of 02
Arun Umrao
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
ssuserd6b1fd
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
Manvendra Singh
 
Perl
PerlPerl
Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)
ujihisa
 
Matching with Regular Expressions
Matching with Regular ExpressionsMatching with Regular Expressions
Matching with Regular Expressions
primeteacher32
 
Subroutines
SubroutinesSubroutines
Sql
SqlSql

Similar to Rspamd symbols (20)

Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)Hacking parse.y (RubyKansai38)
Hacking parse.y (RubyKansai38)
 
Array and functions
Array and functionsArray and functions
Array and functions
 
Hacking Parse.y with ujihisa
Hacking Parse.y with ujihisaHacking Parse.y with ujihisa
Hacking Parse.y with ujihisa
 
11 ruby methods
11 ruby methods11 ruby methods
11 ruby methods
 
Advanced REXX Programming Techniques
Advanced REXX Programming TechniquesAdvanced REXX Programming Techniques
Advanced REXX Programming Techniques
 
Regular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And BeyondRegular Expressions: JavaScript And Beyond
Regular Expressions: JavaScript And Beyond
 
Functions
FunctionsFunctions
Functions
 
Meta Object Protocols
Meta Object ProtocolsMeta Object Protocols
Meta Object Protocols
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat Sheet
 
PE1 Module 4.ppt
PE1 Module 4.pptPE1 Module 4.ppt
PE1 Module 4.ppt
 
Ruby -the wheel Technology
Ruby -the wheel TechnologyRuby -the wheel Technology
Ruby -the wheel Technology
 
Gnu octave help book 02 of 02
Gnu octave help book 02 of 02Gnu octave help book 02 of 02
Gnu octave help book 02 of 02
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Perl
PerlPerl
Perl
 
Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)Hacking parse.y (RubyConf 2009)
Hacking parse.y (RubyConf 2009)
 
Matching with Regular Expressions
Matching with Regular ExpressionsMatching with Regular Expressions
Matching with Regular Expressions
 
SAS 11/01
SAS 11/01SAS 11/01
SAS 11/01
 
Subroutines
SubroutinesSubroutines
Subroutines
 
Sql
SqlSql
Sql
 

Recently uploaded

Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
AkolbilaEmmanuel1
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 

Recently uploaded (20)

Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 

Rspamd symbols

  • 2. WHAT ARE SYMBOLS AND RULES DEFINITIONS RULE SYMBOL SCORE GROUP DESCRIPTION WEIGHT * true/false OPTIONS Dynamic part Static part ∑ Results FLAGS
  • 3. WHAT ARE SYMBOLS AND RULES WHY DO WE NEED SYMBOLS RULE SYMBOL_ALLOW SYMBOL_DENY SYMBOL_UNKNOWN Either of symbols
  • 4. WHAT ARE SYMBOLS AND RULES WHY DO WE NEED SYMBOLS RULE MAP1 MAP2 MAP3 Multiple symbols
  • 5. WHAT ARE SYMBOLS AND RULES WHY DO WE NEED SYMBOLS RULE1 SYMBOL1 RULE2 Dependency
  • 6. WHAT ARE SYMBOLS AND RULES RULES ▸ Rules define what is executed: ▸ Regexps expression ▸ Lua code ▸ Plugin logic ▸ Each rule can be associated with one or many symbols ▸ Rule can depend on other rules identified by associated symbols ▸ Each rule can define the current dynamic weight (usually from 0 to 1)
  • 7. WHAT ARE SYMBOLS AND RULES SYMBOLS ▸ Symbols define meta-information of a rule: ▸ Name ▸ Static score ▸ Other data (description, group, flags, etc) ▸ Symbols can be: ▸ Normal: associated with exactly one rule ▸ Virtual: are not associated with rules but grouped with normal symbol) ▸ Callback: do not have name or score, just define common rule ▸ Special: have special purpose (e.g. composite symbols)
  • 9. SYMBOLS SYMBOLS GROUPS ▸ Groups join common symbols logically ▸ Groups can set joint limit for symbols scores enclosed ▸ Groups can be used in composite rules: ▸ SYMBOL5 && G:GROUP1 ▸ SYMBOL5 && (G:GROUP1 || !G:GROUP2)
  • 10. RULES EXPRESSIONS IN RULES ▸ Expressions are used in: ▸ Regexp rules ▸ Composite symbols ▸ Expressions have common syntax: ▸ Logic operations: AND (&&), OR (||), NOT (!) ▸ Braces ▸ Limit operation: A + B + C > 2 ▸ Elements are called atoms
  • 11. RULES REGEXP EXPRESSIONS ▸ Atoms are regular expressions (/re/flags): ▸ Header: Header=/re/H ▸ Mime (/P): scan text parts ▸ Body (/B): scan full undecoded body ▸ URL (/U): scan URLs found ▸ There is no order of regexps execution within an expression ▸ Same expressions are cached and executed once
  • 13. COMPOSITE EXPRESSIONS COMPOSITES OPERATIONS SYMBOL3 SYMBOL4 SYMBOL5 SYMBOL1 Group2 NOT SYMBOL6 AND AND SYMBOL1 SYMBOL3 Symbols to remove Stage 1: Check Stage 2: Remove symbols
  • 14. COMPOSITE EXPRESSIONS COMPOSITES STRUCTURE ▸ Composite atoms can include: ▸ Other symbols ▸ Groups (gr:) ▸ Other composites (with recursive references check) ▸ Composite operations can be the following: ▸ Remove symbol and weight (SYMBOL) ▸ Remove weight only (~SYMBOL) ▸ Remove symbol but preserve weight (-SYMBOL) ▸ Always remove symbol and weight (^SYMBOL)
  • 15. COMPOSITE EXPRESSIONS COMPOSITES OPERATION ▸ If any composite proposes that a symbol should NOT be removed, then it is NOT removed: ▸ A & ~B and C & B: B will NOT be removed because of the first rule, but its weight will be removed ▸ A & -B and C & ~B: neither weight, nor symbol B will be removed ▸ Removal could be forced by “^” symbol: ▸ A & ^B and C & -B: weight and symbol B are both removed
  • 16. PRACTICAL EXAMPLES A SIMPLE REGEXP EXPRESSION local reconf = config['regexp'] -- Define alias for regexp module -- Define a single regexp rule reconf['PRECEDENCE_BULK'] = { -- Header regexp that detects bulk email re = 'Precedence=/bulk/Hi', -- Default score score = 0.1, description = "Message marked as bulk", group = 'upstream_spam_filters' } rspamd.local.lua:
  • 17. PRACTICAL EXAMPLES A MORE COMPLEX EXAMPLE rspamd.local.lua: local reconf = config['regexp'] -- Define alias for regexp module -- Define encodings types -- /X is undecoded header local subject_encoded_b64 = 'Subject=/=?S+?B?/iX' local subject_encoded_qp = 'Subject=/=?S+?Q?/iX' -- Define whether subject must be encoded (contains non-7bit characters) local subject_needs_mime = 'Subject=/[x00-x08x0bx0cx0e-x1fx7f-xff]/X' -- Final rule reconf['SUBJECT_NEEDS_ENCODING'] = { -- Combine regexps re = string.format('!(%s) & !(%s) & (%s)', subject_encoded_b64, subject_encoded_qp, subject_needs_mime), score = 3.5, description = "Subject contains non-ASCII chars but it is not encoded", group = 'headers' }
  • 18. PRACTICAL EXAMPLES A MORE COMPLEX EXAMPLE rspamd.local.lua: local reconf = config['regexp'] -- Define alias for regexp module -- Define encodings types -- /X is undecoded header local subject_encoded_b64 = 'Subject=/=?S+?B?/iX' local subject_encoded_qp = 'Subject=/=?S+?Q?/iX' -- Define whether subject must be encoded (contains non-7bit characters) local subject_needs_mime = 'Subject=/[x00-x08x0bx0cx0e-x1fx7f-xff]/X' -- Final rule reconf['SUBJECT_NEEDS_ENCODING'] = { -- Combine regexps re = string.format('!(%s) & !(%s) & (%s)', subject_encoded_b64, subject_encoded_qp, subject_needs_mime), score = 3.5, description = "Subject contains non-ASCII chars but it is not encoded", group = 'headers' }
  • 19. PRACTICAL EXAMPLES A MORE COMPLEX EXAMPLE rspamd.local.lua: local reconf = config['regexp'] -- Define alias for regexp module -- Define encodings types -- /X is undecoded header local subject_encoded_b64 = 'Subject=/=?S+?B?/iX' local subject_encoded_qp = 'Subject=/=?S+?Q?/iX' -- Define whether subject must be encoded (contains non-7bit characters) local subject_needs_mime = 'Subject=/[x00-x08x0bx0cx0e-x1fx7f-xff]/X' -- Final rule reconf['SUBJECT_NEEDS_ENCODING'] = { -- Combine regexps re = string.format('!(%s) & !(%s) & (%s)', subject_encoded_b64, subject_encoded_qp, subject_needs_mime), score = 3.5, description = "Subject contains non-ASCII chars but it is not encoded", group = 'headers' }
  • 20. PRACTICAL EXAMPLES COMPOSITES EXAMPLE local.d/composites.conf: # Ignore forged recipients in case of mailing list composite "FORGED_RECIPIENTS_MAILLIST" { # MALLIST symbol is preserved expression = "FORGED_RECIPIENTS & -MAILLIST"; } # Ignore forged sender if a message has been forwarded composite "FORGED_SENDER_FORWARDING" { # Symbols from `forwarding` group are removed expression = "FORGED_SENDER & g:forwarding"; } # Ignore forged sender if a message has been from the mailing list composite "FORGED_SENDER_MAILLIST" { # Symbol 'FORGED_SENDER' is forced to be removed expression = "^FORGED_SENDER & -MAILLIST"; }
  • 21. PRACTICAL EXAMPLES COMPOSITES EXAMPLE local.d/composites.conf: # Ignore forged recipients in case of mailing list composite "FORGED_RECIPIENTS_MAILLIST" { # MALLIST symbol is preserved expression = "FORGED_RECIPIENTS & -MAILLIST"; } # Ignore forged sender if a message has been forwarded composite "FORGED_SENDER_FORWARDING" { # Symbols from `forwarding` group are removed expression = "FORGED_SENDER & g:forwarding"; } # Ignore forged sender if a message has been from the mailing list composite "FORGED_SENDER_MAILLIST" { # Symbol 'FORGED_SENDER' is forced to be removed expression = "^FORGED_SENDER & -MAILLIST"; }
  • 22. PRACTICAL EXAMPLES COMPOSITES EXAMPLE local.d/composites.conf: # Ignore forged recipients in case of mailing list composite "FORGED_RECIPIENTS_MAILLIST" { # MALLIST symbol is preserved expression = "FORGED_RECIPIENTS & -MAILLIST"; } # Ignore forged sender if a message has been forwarded composite "FORGED_SENDER_FORWARDING" { # Symbols from `forwarding` group are removed expression = "FORGED_SENDER & g:forwarding"; } # Ignore forged sender if a message has been from the mailing list composite "FORGED_SENDER_MAILLIST" { # Symbol 'FORGED_SENDER' is forced to be removed expression = "^FORGED_SENDER & -MAILLIST"; }
  • 23. PRACTICAL EXAMPLES COMPOSITES EXAMPLE local.d/composites.conf: # Ignore forged recipients in case of mailing list composite "FORGED_RECIPIENTS_MAILLIST" { # MALLIST symbol is preserved expression = "FORGED_RECIPIENTS & -MAILLIST"; } # Ignore forged sender if a message has been forwarded composite "FORGED_SENDER_FORWARDING" { # Symbols from `forwarding` group are removed expression = "FORGED_SENDER & g:forwarding"; } # Ignore forged sender if a message has been from the mailing list composite "FORGED_SENDER_MAILLIST" { # Symbol 'FORGED_SENDER' is forced to be removed expression = "^FORGED_SENDER & -MAILLIST"; }
  • 24. PRACTICAL EXAMPLES COMPOSITES EXAMPLE local.d/composites.conf: # Ignore forged recipients in case of mailing list composite "FORGED_RECIPIENTS_MAILLIST" { # MALLIST symbol is preserved expression = "FORGED_RECIPIENTS & -MAILLIST"; } # Ignore forged sender if a message has been forwarded composite "FORGED_SENDER_FORWARDING" { # Symbols from `forwarding` group are removed expression = "FORGED_SENDER & g:forwarding"; } # Ignore forged sender if a message has been from the mailing list composite "FORGED_SENDER_MAILLIST" { # Symbol 'FORGED_SENDER' is forced to be removed expression = "^FORGED_SENDER & -MAILLIST"; }