Coder Social home page Coder Social logo

dburkart / check-sieve Goto Github PK

View Code? Open in Web Editor NEW
34.0 6.0 7.0 561 KB

Syntax checker for mail sieves.

License: MIT License

Makefile 0.65% C++ 77.01% Python 21.17% Lex 1.08% Shell 0.03% Sieve 0.07%
rfc sieve mail-sieves c email-filtering managesieve

check-sieve's People

Contributors

dburkart avatar eklitzke avatar fischerling avatar grawlinson avatar johnlettman avatar rensoliemans avatar stmontgomery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

check-sieve's Issues

Homebrew formula for macOS installs

It would be nice to have a brew formula for installing check-sieve.

Unsure if it's worth it for you to have a whole tap just for this, and I'm not sure this would be accepted into homebrew core just yet, but at least good to provide the formula for anyone coming across this:

# See upstream issue: https://github.com/dburkart/check-sieve/issues/46
class CheckSieve < Formula
  version '0.9'
  sha256 'cc9a8ee4fe3e6464d1934325d2c17c4f37799aedb85d7fda9e00991e23d93c60'

  desc 'CLI to check Sieve files for errors.'
  homepage 'https://github.com/dburkart/check-sieve'
  url "https://github.com/dburkart/check-sieve/archive/refs/tags/check-sieve-#{version}.tar.gz"
  license 'MIT'

  def install
    system 'make', 'install', "INSTALL_PREFIX=#{prefix}"
  end
end

I also pushed it to my personal tap, so can be installed with:

brew install gibfahn/tap/check-sieve

Improve library API

Make sure libchecksieve.a has a uniform API, and investigate what else can be added.

Construct abstract syntax tree in parser

We should build an abstract syntax tree as we go along, since that will provide us multiple benefits in the long run. Once we have that, we can move much of the verification code into that, and it will make things like testing a sieve against e-mail possible.

Feature: Implement a C/C++ style guide with linting

Implementing a style guide and enforcing a uniform syntax style would significantly enhance development, particularly as the codebase expands.

Linting and Formatting Tools

Presently, there are several tools available and up to the task:

  • clang-format: A clang-based formatter that formats C and C++ code according to a style guide, such as Google, LLVM, Mozilla, Webkit, and Chromium.

    ClangFormat describes a set of tools that are built on top of LibFormat. It can support your workflow in a variety of ways including a standalone tool and editor integrations.

  • clang-tidy: A clang-based C and C++ linter tool to detect typical syntax and semantic errors.

    clang-tidy is a clang-based C++ “linter” tool. Its purpose is to provide an extensible framework for diagnosing and fixing typical programming errors, like style violations, interface misuse, or bugs that can be deduced via static analysis. clang-tidy is modular and provides a convenient interface for writing new checks.

  • cppcheck: A static analysis tool for C and C++ code to detect bugs, undefined behavior, and dangerous constructs.

    Cppcheck is a static analysis tool for C/C++ code. It provides unique code analysis to detect bugs and focuses on detecting undefined behaviour and dangerous coding constructs. The goal is to have very few false positives. Cppcheck is designed to be able to analyze your C/C++ code even if it has non-standard syntax (common in embedded projects).

  • cpplint: A C and C++ linter tool following Google's C++ style guide.

    Cpplint is a command-line tool to check C/C++ files for style issues following Google's C++ style guide. Cpplint is developed and maintained by Google Inc. at google/styleguide, also see the wikipedia entry
    While Google maintains cpplint, Google is not (very) responsive to issues and pull requests, this fork aims to be (somewhat) more open to add fixes to cpplint to enable fixes, when those fixes make cpplint usable in wider contexts. Also see discussion here google/styleguide#528.

  • uncrustify: A source code formatter (or, "beautifier") supporting C, C++, C#, Objective-C, D, Java, Pawn, and Vala.

    A source code beautifier for C, C++, C#, Objective-C, D, Java, Pawn and Vala.

Conventions and Style Guides

Maintaining a shared programming style and implementing that standard using automation and analysis tools requires a well-formed style guide. The following major style guides exist:

Recommendation

Based on conventions in the wild, the trend seems to lean toward the Google style guide; however, I leave this personal preference to @dburkart.

Existing Style

I will now examine and compare the existing code to the listed conventions.

Brace Placement

Starting with functions, the opening brace { is on the same line as the function declaration:

bool Command::validate(const ASTNode *node) {

This alone eliminates the following style guides based on brace placement:

  • GNU: next line braces
  • Microsoft: next line braces
  • Mozilla: next line braces
  • WebKit: next line braces

This leaves the following style guides:

  • Chromium
  • Google
  • LLVM

Return Type Placement

Next, the return type of a function is on the same line as the function declaration:

bool Command::_validateDeleteHeadersCommand(const ASTNode *node) {

The following style guides also implement this preference:

  • Chromium
  • Google
  • LLVM
  • Microsoft
  • WebKit

Summary

The following style guides appear to be the most compatible:

  • Chromium
  • Google
  • LLVM

Overall Summary

Implementing clang-format, clang-tidy, and cppcheck would greatly improve QA across the codebase. These can be passively enforced via GitHub actions to contextualize pull requests.

Note

Implementing the change will also require a refactor of the existing code -- creating a particularly messy commit diff.

Make check-sieve more robust

The tool has no --help, for instance. In addition we should support the following options:

  • --trace-scanner
  • --trace-parser
  • Support for piping input in.

Implement Relational Extension (RFC 5231)

Abstract:

This document describes the RELATIONAL extension to the Sieve mail
filtering language defined in RFC 3028.  This extension extends
existing conditional tests in Sieve to allow relational operators.
In addition to testing their content, it also allows for testing of
the number of entities in header and envelope fields.

This document obsoletes RFC 3431.

https://tools.ietf.org/html/rfc5231

Problems installing on openSuse

Dear check-sieve team,
I get the following error when trying to install check-sieve at my opensuse Tumbleweed:

make install --debug

GNU Make 4.4.1
Gebaut für x86_64-suse-linux-gnu
Copyright (C) 1988-2023 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder später https://gnu.org/licenses/gpl.html
Dies ist freie Software: Sie können sie nach Belieben ändern und weiter verteilen.
Soweit es die Gesetze erlauben, gibt es KEINE GARANTIE.
Makedateien werden gelesen …
Makedateien werden aktualisiert …
Ziele werden aktualisiert …
Die Datei „install“ existiert nicht.
Die Datei „all“ existiert nicht.
Die Datei „libchecksieve.a“ existiert nicht.
Das Ziel „libchecksieve.a“ muss neu erzeugt werden.
make -C ./gen
GNU Make 4.4.1
Gebaut für x86_64-suse-linux-gnu
Copyright (C) 1988-2023 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder später https://gnu.org/licenses/gpl.html
Dies ist freie Software: Sie können sie nach Belieben ändern und weiter verteilen.
Soweit es die Gesetze erlauben, gibt es KEINE GARANTIE.
Makedateien werden gelesen …
make[1]: Verzeichnis „/opt/check-sieve/gen“ wird betreten
Makedateien werden aktualisiert …
Ziele werden aktualisiert …
Die Datei „all“ existiert nicht.
Die Datei „../gen/sieve_parser.tab.o“ existiert nicht.
Das Ziel „../gen/sieve_parser.tab.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../gen/sieve_parser.tab.cc -o ../gen/sieve_parser.tab.o
Die Zieldatei „../gen/sieve_parser.tab.o“ wurde erfolgreich aktualisiert.
Die Datei „../gen/sieve_scanner.o“ existiert nicht.
Das Ziel „../gen/sieve_scanner.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../gen/sieve_scanner.cc -o ../gen/sieve_scanner.o
Die Zieldatei „../gen/sieve_scanner.o“ wurde erfolgreich aktualisiert.
Das Ziel „all“ muss neu erzeugt werden.
Die Zieldatei „all“ wurde erfolgreich aktualisiert.
make[1]: Verzeichnis „/opt/check-sieve/gen“ wird verlassen
make -C ./src lib
GNU Make 4.4.1
Gebaut für x86_64-suse-linux-gnu
Copyright (C) 1988-2023 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder später https://gnu.org/licenses/gpl.html
Dies ist freie Software: Sie können sie nach Belieben ändern und weiter verteilen.
Soweit es die Gesetze erlauben, gibt es KEINE GARANTIE.
Makedateien werden gelesen …
make[1]: Verzeichnis „/opt/check-sieve/src“ wird betreten
Makedateien werden aktualisiert …
Ziele werden aktualisiert …
Die Datei „lib“ existiert nicht.
Die Datei „../src/sieve_driver.o“ existiert nicht.
Das Ziel „../src/sieve_driver.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/sieve_driver.cc -o ../src/sieve_driver.o
Die Zieldatei „../src/sieve_driver.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/checksieve.o“ existiert nicht.
Das Ziel „../src/checksieve.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/checksieve.cc -o ../src/checksieve.o
Die Zieldatei „../src/checksieve.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/diagnostic.o“ existiert nicht.
Das Ziel „../src/diagnostic.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/diagnostic.cc -o ../src/diagnostic.o
Die Zieldatei „../src/diagnostic.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/Validation/Command.o“ existiert nicht.
Das Ziel „../src/AST/Validation/Command.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/Validation/Command.cc -o ../src/AST/Validation/Command.o
Die Zieldatei „../src/AST/Validation/Command.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/Validation/Test.o“ existiert nicht.
Das Ziel „../src/AST/Validation/Test.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/Validation/Test.cc -o ../src/AST/Validation/Test.o
Die Zieldatei „../src/AST/Validation/Test.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/Validation/Tag.o“ existiert nicht.
Das Ziel „../src/AST/Validation/Tag.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/Validation/Tag.cc -o ../src/AST/Validation/Tag.o
Die Zieldatei „../src/AST/Validation/Tag.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTTraceVisitor.o“ existiert nicht.
Das Ziel „../src/AST/ASTTraceVisitor.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTTraceVisitor.cc -o ../src/AST/ASTTraceVisitor.o
Die Zieldatei „../src/AST/ASTTraceVisitor.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTVerificationVisitor.o“ existiert nicht.
Das Ziel „../src/AST/ASTVerificationVisitor.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTVerificationVisitor.cc -o ../src/AST/ASTVerificationVisitor.o
Die Zieldatei „../src/AST/ASTVerificationVisitor.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTBlock.o“ existiert nicht.
Das Ziel „../src/AST/ASTBlock.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTBlock.cc -o ../src/AST/ASTBlock.o
Die Zieldatei „../src/AST/ASTBlock.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTBoolean.o“ existiert nicht.
Das Ziel „../src/AST/ASTBoolean.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTBoolean.cc -o ../src/AST/ASTBoolean.o
Die Zieldatei „../src/AST/ASTBoolean.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTBranch.o“ existiert nicht.
Das Ziel „../src/AST/ASTBranch.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTBranch.cc -o ../src/AST/ASTBranch.o
Die Zieldatei „../src/AST/ASTBranch.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTCommand.o“ existiert nicht.
Das Ziel „../src/AST/ASTCommand.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTCommand.cc -o ../src/AST/ASTCommand.o
Die Zieldatei „../src/AST/ASTCommand.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTCondition.o“ existiert nicht.
Das Ziel „../src/AST/ASTCondition.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTCondition.cc -o ../src/AST/ASTCondition.o
Die Zieldatei „../src/AST/ASTCondition.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTNoOp.o“ existiert nicht.
Das Ziel „../src/AST/ASTNoOp.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTNoOp.cc -o ../src/AST/ASTNoOp.o
Die Zieldatei „../src/AST/ASTNoOp.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTNumeric.o“ existiert nicht.
Das Ziel „../src/AST/ASTNumeric.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTNumeric.cc -o ../src/AST/ASTNumeric.o
Die Zieldatei „../src/AST/ASTNumeric.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTRequire.o“ existiert nicht.
Das Ziel „../src/AST/ASTRequire.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTRequire.cc -o ../src/AST/ASTRequire.o
Die Zieldatei „../src/AST/ASTRequire.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTSieve.o“ existiert nicht.
Das Ziel „../src/AST/ASTSieve.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTSieve.cc -o ../src/AST/ASTSieve.o
Die Zieldatei „../src/AST/ASTSieve.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTString.o“ existiert nicht.
Das Ziel „../src/AST/ASTString.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTString.cc -o ../src/AST/ASTString.o
Die Zieldatei „../src/AST/ASTString.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTStringList.o“ existiert nicht.
Das Ziel „../src/AST/ASTStringList.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTStringList.cc -o ../src/AST/ASTStringList.o
Die Zieldatei „../src/AST/ASTStringList.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTTag.o“ existiert nicht.
Das Ziel „../src/AST/ASTTag.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTTag.cc -o ../src/AST/ASTTag.o
Die Zieldatei „../src/AST/ASTTag.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTTest.o“ existiert nicht.
Das Ziel „../src/AST/ASTTest.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTTest.cc -o ../src/AST/ASTTest.o
Die Zieldatei „../src/AST/ASTTest.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/AST/ASTTestList.o“ existiert nicht.
Das Ziel „../src/AST/ASTTestList.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/AST/ASTTestList.cc -o ../src/AST/ASTTestList.o
Die Zieldatei „../src/AST/ASTTestList.o“ wurde erfolgreich aktualisiert.
Die Datei „../src/Server/MailServer.o“ existiert nicht.
Das Ziel „../src/Server/MailServer.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/Server/MailServer.cc -o ../src/Server/MailServer.o
Die Zieldatei „../src/Server/MailServer.o“ wurde erfolgreich aktualisiert.
Das Ziel „lib“ muss neu erzeugt werden.
Die Zieldatei „lib“ wurde erfolgreich aktualisiert.
make[1]: Verzeichnis „/opt/check-sieve/src“ wird verlassen
ar rc libchecksieve.a ./gen/sieve_parser.tab.o ./gen/sieve_scanner.o ./src/sieve_driver.o ./src/checksieve.o ./src/diagnostic.o ./src/AST/Validation/Command.o ./src/AST/Validation/Test.o ./src/AST/Validation/Tag.o ./src/AST/ASTTraceVisitor.o ./src/AST/ASTVerificationVisitor.o ./src/AST/ASTBlock.o ./src/AST/ASTBoolean.o ./src/AST/ASTBranch.o ./src/AST/ASTCommand.o ./src/AST/ASTCondition.o ./src/AST/ASTNoOp.o ./src/AST/ASTNumeric.o ./src/AST/ASTRequire.o ./src/AST/ASTSieve.o ./src/AST/ASTString.o ./src/AST/ASTStringList.o ./src/AST/ASTTag.o ./src/AST/ASTTest.o ./src/AST/ASTTestList.o ./src/Server/MailServer.o
Die Zieldatei „libchecksieve.a“ wurde erfolgreich aktualisiert.
Die Datei „check-sieve“ existiert nicht.
Das Ziel „check-sieve“ muss neu erzeugt werden.
make -C ./src binary
GNU Make 4.4.1
Gebaut für x86_64-suse-linux-gnu
Copyright (C) 1988-2023 Free Software Foundation, Inc.
Lizenz GPLv3+: GNU GPL Version 3 oder später https://gnu.org/licenses/gpl.html
Dies ist freie Software: Sie können sie nach Belieben ändern und weiter verteilen.
Soweit es die Gesetze erlauben, gibt es KEINE GARANTIE.
Makedateien werden gelesen …
make[1]: Verzeichnis „/opt/check-sieve/src“ wird betreten
Makedateien werden aktualisiert …
Ziele werden aktualisiert …
Die Datei „binary“ existiert nicht.
Die Datei „../src/sieve.o“ existiert nicht.
Das Ziel „../src/sieve.o“ muss neu erzeugt werden.
g++ -c -I../gen/ -I../src/ -I../src/AST -I../src/Server -std=c++11 -fPIC -Wno-deprecated-register -DPLATFORM="x86_64-Linux" ../src/sieve.cc -o ../src/sieve.o
In Datei, eingebunden von ../src/sieve.cc:8:
../src/Server/MailServer.hh:17:38: Fehler: »uint32_t« wurde nicht deklariert
17 | MailServer(std::string hostname, uint32_t port);
| ^~~~~~~~
../src/Server/MailServer.hh:24:5: Fehler: »uint32_t« bezeichnet keinen Typ
24 | uint32_t _port;
| ^~~~~~~~
../src/Server/MailServer.hh:1:1: Anmerkung: »uint32_t« ist im Header »« definiert; haben Sie vergessen, »#include « zu schreiben?
+++ |+#include
1 | #pragma once
cc1plus: Anmerkung: Unbekannte Kommandozeilenoption »-Wno-deprecated-register« könnte den Zweck haben, bisherige Diagnosemeldungen zu unterdrücken
make[1]: *** [Makefile:22: ../src/sieve.o] Fehler 1
make[1]: Verzeichnis „/opt/check-sieve/src“ wird verlassen
make: *** [Makefile:25: check-sieve] Fehler 2

Am I missing any dependency? I did checkout the master from git.

CR/LF line endings should be supported

Hello,

I'm really sorry to post this problem, but I don't understand how it works

  1. I cloned the repository
  2. I installed g++ on my debian system and built with make.
  3. it generated me a "check-sieve" executable
  4. I give it a .sieve file that I know is valid.

at this point, I get a response:

jeremy@jerem-debian:~/git/check-sieve (master) $ ./check-sieve /tmp/managesieve.sieve
Errors found in "/tmp/managesieve.sieve":

invalid character
On line 1:
require ["fileinto","regex"];
^
jeremy@jerem-debian:~/git/check-sieve (master) $

I think I'm forgetting something, but I don't see what :(

i've read the readme several times, but i must be missing something. i don't think i should care what's in the tests folder

thanks for the help !

Add support for warnings

There are some things we may want to allow which is not technically correct syntax, but is allowed by most sieve software. For example, extraneous semicolons are sometimes allowed (particularly after blocks), however that is syntactically invalid.

[RFC 5229] Variable names aren't validated

The first argument to the "set" action is a quoted string, but it actually needs to validate to these rules:

variable-name       =  num-variable / identifier
num-variable        =  1*DIGIT

Implement Date and Index Extensions (RFC 5260)

This document describes the "date" and "index" extensions to the
Sieve email filtering language.  The "date" extension gives Sieve the
ability to test date and time values in various ways.  The "index"
extension provides a means to limit header and address tests to
specific instances of header fields when header fields are repeated.

https://tools.ietf.org/html/rfc5260

Use abstract syntax tree to "simulate" mail sorting

The idea is that we could pass an e-mail message to check-sieve, and walk over the AST, generating a list of actions we would have taken. This would allow true testing of the logic of a mail sieve script.

Get up to spec on RFC 3028

RFC 3028 is only partially supported at the moment. Known areas which need improvement are:

  • test is supposed to conform to identifier arguments, but does not.
  • command should conform to identifier arguments ( ";" / block ), but does not.
  • multi-line comments have not been implemented
  • multi-line strings have not been implemented

arguments and tests should be vectors

Right now, arguments and tests are simply integers which count the number of arguments or tests. This needs to change so that we can complete issue #1.

This is blocking issue #1.

Support Include Extension (RFC 6609)

The Sieve Email Filtering "include" extension permits users to
include one Sieve script inside another.  This can make managing
large scripts or multiple sets of scripts much easier, and allows a
site and its users to build up libraries of scripts.  Users are able
to include their own personal scripts or site-wide scripts.

https://tools.ietf.org/html/rfc6609

Rename mail-sieve-verifier to check-sieve

I wanted to do a package on Arch User Repository, but I thought that installing mail-sieve-verifier(-git) and having a check-sieve command was kinda odd. Shall we change the name of the executable or leave like this?

Can't distinguish between single-item test-list and single test

While investigating Issue #47, I found this small sieve script which validates, but really shouldn't:

if not (address :is "Foo") {
    discard;
}

The problem is that there is no ASTNode to indicate the existence of a test-list; it is simply implied by sibling tests in the syntax tree. So a single-item list validates fine, because all the verifier sees is a single test.

Implement error recovery

Right now, the parser stops on first error. Let's teach it some error recovery so we can have it be more useful when there are multiple errors in a mail sieve.

Add ability to match part of a required extension

For instance, the :comparator flag is governed by "comparator-*", i.e. to use syntax like:

if header :value "lt" :comparator "i;ascii-numeric"
            ["x-priority"] ["3"]
 {
     fileinto "Priority";
 }

One would need the following require statement:

require "comparator-i;ascii-numerif";

To support this, we need the ability to match part of a required extension.

Factor out user reporting to a separate API

Right now, the driver class reports out errors to STDOUT as it goes along. Instead of this, we should add an API to generate our reporting from a relevant parse_result struct.

Extend check-sieve to enable / disable extensions

check-sieve should allow the user to 'enable' or 'disable' extensions via the command line. In this way, the user can simulate whatever is enabled on their particular mail server.

Perhaps one way to do this is to pass in the mail server, and check-sieve can figure out what the server's capabilities are.

Undefined reference to sieve::<things>

Hi!

I'm looking forward to use mail-sieve-verifier, however when I'm running make I'm getting the following:

$ make
g++ -Igen/ -Isrc/ -std=c++0x -fPIC -Wno-deprecated-register -DPLATFORM=\"x86_64-Linux\" -c src/sieve.cc
g++ -Igen/ -Isrc/ -std=c++0x -fPIC -Wno-deprecated-register -DPLATFORM=\"x86_64-Linux\" libchecksieve.a sieve.o -o check-sieve
sieve.o: In function `print_version()':
sieve.cc:(.text+0xa): undefined reference to `sieve::version()'
sieve.o: In function `main':
sieve.cc:(.text+0x179): undefined reference to `sieve::driver::driver()'
sieve.cc:(.text+0x413): undefined reference to `sieve::driver::parse_file(std::string const&)'
sieve.cc:(.text+0x483): undefined reference to `sieve::driver::~driver()'
sieve.cc:(.text+0x4bb): undefined reference to `sieve::driver::~driver()'
collect2: error: ld returned 1 exit status
Makefile:11: recipe for target 'check-sieve' failed
make: *** [check-sieve] Error 1

Am I missing a dependency? Sieve, bison and flex are installed with the correct version.

Some infos that may be useful:

$ uname -a
Linux geoffrey-vps 4.0.6-1-ARCH #1 SMP PREEMPT Tue Jun 23 14:25:08 CEST 2015 x86_64 GNU/Linux
$ g++ --version
g++ (GCC) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ pacman -Q gcc-multilib
gcc-multilib 5.2.0-2
$ pacman -Q bison
bison 3.0.4-1
$ pacman -Q flex
flex 2.5.39-1
$ pacman -Q pigeonhole
pigeonhole 0.4.8-1

Implement "Copying Without Side Effects" (RFC 3894)

The Abstract:

The Sieve scripting language allows users to control handling and
disposal of their incoming e-mail.  By default, an e-mail message
that is processed by a Sieve script is saved in the owner's "inbox".
Actions such as "fileinto" and "redirect" cancel this default
behavior.

This document defines a new keyword parameter, ":copy", to be used
with the Sieve "fileinto" and "redirect" actions.  Adding ":copy" to
an action suppresses cancellation of the default "inbox" save.  It
allows users to add commands to an existing script without changing
the meaning of the rest of the script.

http://tools.ietf.org/html/rfc3894

test-lists with one element produce "Unrecognized command" error

If I have a test-list with a single element, check-sieve produces an "Unrecognized command" error for the test identifier. The only exceptions are for true and false. Adding a second element fixes this, but shouldn't be necessary. The Sieve grammar defines a test-list as containing 1 or more tests, not 2 or more.

It's also a bit surprising that the error says "Unrecognized command" instead of something like "unrecognized test".

This bug is new in version 0.7, version 0.6 accepts this syntax without comment. Version 0.6 also uses the correct "Unrecognized test" warning if I put an actual bogus test in there, as opposed to 0.7's "Unrecognized command".

Example:

if anyof (not true) {
  keep;
} else {
  discard;
}

This produces Unrecognized command "not".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.