To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (an extended version)
* By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

Message submitted.

Your message has been sent. We will email you at

If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

Perl script instead of Blame-notifier o…

Perl script instead of Blame-notifier on Linux OS

Apr 08 2021

As you know, our clients are developers. Sometimes developers can surprise you. For example, one of our users wrote his own script. It allows configuring emails about errors found by PVS-Studio. The difference between this script and our blame-notifier is that it does not require .NET Core on Linux. We decided to write a short note about this Perl script, because we believe that it can be useful to someone.



The Perl script, which we'll discuss further, is published on github under the GPL-2.0 license. So, anyone can use it.

Its main function is to notify about problems found by PVS-Studio via email. We can say that it's an equivalent of our blame-notifier. Perl script sends emails generated in HTML. It also sends an email to the commit's author. Information about the commit and its author is extracted from Git. It's worth noting that there are a number of settings for sending emails. We'll discuss the settings further.

The script stores all warnings in a database (which you must configure in advance). So, it can send notifications not about all problems, but only about new detected errors.

You can also attach something to the message. For example, you can attach a full log of errors detected by PVS-Studio to an email.


Of course, several pre-settings precede the script usage.

First, the project must use the Git version control system, since the script extracts all necessary information about the commit's author via git blame / git annotate.

Secondly, we need to configure the database so that the script can automatically save the errors found. Then, send an email describing new errors. It's also possible to receive notifications not only about new errors but about all errors in the project. In the "Use cases" section, I'll explain it in a little more detail.

Thirdly, you need to set up your email if you don't have it set up yet. We'll also discuss this point in detail in the "Email setup" section.

And last but not least, we need to install Perl. But it's not quite right to call this a requirement, because usually Perl is installed on every Linux OS.


Let's review the installation process in more detail. I'll install it on my virtual machine which is running the openSUSE Linux distribution. By the way, in the README file on the git repository, you can read about configuration for Debian, but there is almost no difference.

So, before setting up, we must clone the repository from github.

Required modules

To use the script, we need to install the following modules (here are the modules for openSUSE):

  • perl-DBI – a database-independent Perl tool;
  • perl-DBD-mysql – MySQL database driver;
  • perl-MIME-Lite – for generating MIME messages;
  • perl-YAML – YML-parser for loading configuration files;
  • perl-List-MoreUtils – additional utilities;
  • perl-FindBin-Real – to search the directory of the Perl script source.

To do it use the following command:

$> sudo zypper install perl-DBI

You can install these modules at will. It eases working with the code, but it won't affect the script's performance:

  • perl-IPC-Filter – highlights syntax;
  • highlight – highlights the GNU source code.

Email setup

To set up email, use msmtp. To start installation, use the following command:

$> sudo zypper install msmtp msmtp-mta

After installation, you need to create the /etc/msmtprc file. The file must contain mail settings. For example, for Yandex-mail, this file will look as follows:

# Set default values for all following accounts.
auth on
tls on
tls_starttls on
tls_certcheck off
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/msmtp.log

# Account
account        default
port           587
auth           on
keepbcc        on
password       emailpassword

# Set a default account
account default: default

# Map local users to mail addresses (for crontab)
aliases /etc/aliases

You will also need to create the msmtp.log file by yourself. The script will write logs to the file.

Also, to send emails, you will need to enable the POP3 and IMAP protocols in your mailbox settings.

At this point, the mail setup is complete. To make sure everything works, you can send a test message:

$> echo "test message" | mail -s "test"

Setting up a database

Next, we need to set up any of the databases that Perl will support. Let's take MariaDB, as the script's author suggests.

To install it, use the following command:

$> sudo zypper install mariadb

Then we need to use:

$> sudo rcmysql start
$> sudo mysql_secure_installation

After installation, we need to create a new database named blame and a new user with the same name:

$> sudo mysql
mysql> CREATE DATABASE blame;
mysql> GRANT ALL on blame.* TO 'blame'@'localhost' IDENTIFIED BY
mysql> quit

Run the database before running the script.


The script will search for the configuration file in two places:

  • /etc/blame.cfg
  • $HOME/.blame.cfg

If it finds both files, the file located in the home directory will override the file with the global settings.

The contents of the file must be in YAML:

# database connection string
dsn: DBI:mysql:blame
# database username
username: blame
# database password
password: secret_mysql_password
# smtp sender address
# smtp subject
smtp_subject: New PVS Issues
# path substitution
path_search: '/root/src/src/'
path_replace: ''

Please note that this file contains confidential data. It shouldn't be accessible to all users.

Use cases

The script takes the path to a file in the errorfile format as an input parameter. This file is obtained as a result of converting the analyzer output via the PlogConverter utility. Read more about this utility here.

For example, we have a PVS-Studio report (let's call it report.plog). To get the file required for the script, issue PlogConverter the following command:

plog-converter report.plog -t errorfile -o report.txt

Now, to run the script, we need to run the following command:

$> ./ < report.txt

Then, you will receive the following email:


In addition, there are a number of extra parameters that will allow you to use the script more flexibly. To get more information, you can use the -h option.

Let's take a look at some examples with additional options.

By default, the script groups the analyzer warnings by author and sends them via email. It is extracted by the script with the git annotate command. In addition, you can change the behavior so that you receive notifications from all authors by redefining their email addresses. You can do this by specifying the -r <>at startup:

$> ./ -r < report.txt

Each time you run the script, the database updates. An email with the latest analyzer warnings is generated. If you want to go beyond mailing which just sends warnings, you can use the -d option. In this case, the SQL DROP TABLE will be applied to the database. The script will send notifications about all PVS-Studio warnings.

$> ./ -d -r < report.txt

Apart from the regular notification, you can also attach something to the message (for example, the report itself or its html version). To use this feature, pass the -a option to the script at startup. It accepts a comma-separated list of files:

$> ./ -a 'report.txt,report.html' < report.txt

Finally, if you want to see a detailed output of what is currently happening in the console, you can pass the -v option to the script.

In conclusion

If you don't want to install .NET Core on Linux, take a closer look at this Perl script. Maybe you'll want to use it instead of the official solution. Anyway, now you know for sure that there is such a way too.

However, please, note that we are not responsible for this solution. We do not guarantee that the script's author will maintain any compatibility with previous versions if logs or file formats change.

And, finally, an important note: the script author does not recommend running it under root. This will require storing configuration files in the user's home directory. Instead, you can run the PVS-Studio analysis in a Docker container.

Popular related articles
Static analysis as part of the development process in Unreal Engine

Date: Jun 27 2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: Nov 21 2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
Appreciate Static Code Analysis!

Date: Oct 16 2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: Jul 31 2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
Free PVS-Studio for those who develops open source projects

Date: Dec 22 2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…
The Last Line Effect

Date: May 31 2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
PVS-Studio for Java

Date: Jan 17 2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
The Evil within the Comparison Functions

Date: May 19 2017

Author: Andrey Karpov

Perhaps, readers remember my article titled "Last line effect". It describes a pattern I've once noticed: in most cases programmers make an error in the last line of similar text blocks. Now I want t…
The way static analyzers fight against false positives, and why they do it

Date: Mar 20 2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: Oct 22 2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…

Comments (0)

Next comments
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →