Merge pull request #1 from duesee/use_gh_actions

Use GitHub Actions
This commit is contained in:
Damian Poddebniak 2021-07-20 21:53:57 +02:00 committed by GitHub
commit 1b4ff2b2d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 116 additions and 51 deletions

22
.github/workflows/audit.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Audit
on:
schedule:
- cron: '0 0 * * *'
push:
branches: [ main ]
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
pull_request:
branches: [ main ]
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

26
.github/workflows/rust.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Rust
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
- name: Test
run: cargo test --verbose
- name: Fmt
run: cargo fmt -- --check --config imports_granularity=Crate,group_imports=StdExternalCrate
- name: Clippy
run: cargo clippy

View File

@ -1,6 +1,7 @@
use smtp_codec::parse::command::command;
use std::io::Write; use std::io::Write;
use smtp_codec::parse::command::command;
fn main() -> std::io::Result<()> { fn main() -> std::io::Result<()> {
let mut args = std::env::args(); let mut args = std::env::args();

View File

@ -1,6 +1,5 @@
//! 4.1.3. Address Literals (RFC 5321) //! 4.1.3. Address Literals (RFC 5321)
use crate::parse::Ldh_str;
use abnf_core::streaming::is_DIGIT; use abnf_core::streaming::is_DIGIT;
use nom::{ use nom::{
branch::alt, branch::alt,
@ -12,6 +11,8 @@ use nom::{
IResult, IResult,
}; };
use crate::parse::Ldh_str;
/// address-literal = "[" ( /// address-literal = "[" (
/// IPv4-address-literal / /// IPv4-address-literal /
/// IPv6-address-literal / /// IPv6-address-literal /

View File

@ -1,7 +1,3 @@
use crate::{
parse::{address::address_literal, base64, Atom, Domain, Quoted_string, String},
types::{Command, DomainOrAddress, Parameter},
};
use abnf_core::streaming::{is_ALPHA, is_DIGIT, CRLF, SP}; use abnf_core::streaming::{is_ALPHA, is_DIGIT, CRLF, SP};
use nom::{ use nom::{
branch::alt, branch::alt,
@ -12,6 +8,11 @@ use nom::{
IResult, IResult,
}; };
use crate::{
parse::{address::address_literal, base64, Atom, Domain, Quoted_string, String},
types::{Command, DomainOrAddress, Parameter},
};
pub fn command(input: &[u8]) -> IResult<&[u8], Command> { pub fn command(input: &[u8]) -> IResult<&[u8], Command> {
alt(( alt((
helo, ehlo, mail, rcpt, data, rset, vrfy, expn, help, noop, quit, helo, ehlo, mail, rcpt, data, rset, vrfy, expn, help, noop, quit,

View File

@ -4,7 +4,6 @@
/// 3.2.1. Quoted characters /// 3.2.1. Quoted characters
pub mod quoted_characters { pub mod quoted_characters {
use super::obsolete::obs_qp;
use abnf_core::streaming::{is_VCHAR, WSP}; use abnf_core::streaming::{is_VCHAR, WSP};
use nom::{ use nom::{
branch::alt, branch::alt,
@ -14,6 +13,8 @@ pub mod quoted_characters {
IResult, IResult,
}; };
use super::obsolete::obs_qp;
/// quoted-pair = ("\" (VCHAR / WSP)) / obs-qp /// quoted-pair = ("\" (VCHAR / WSP)) / obs-qp
pub fn quoted_pair(input: &[u8]) -> IResult<&[u8], &[u8]> { pub fn quoted_pair(input: &[u8]) -> IResult<&[u8], &[u8]> {
let parser = alt(( let parser = alt((
@ -57,7 +58,6 @@ pub mod folding_ws_and_comment {
/// 3.2.3. Atom /// 3.2.3. Atom
pub mod atom { pub mod atom {
use super::folding_ws_and_comment::CFWS;
use abnf_core::streaming::{is_ALPHA, is_DIGIT}; use abnf_core::streaming::{is_ALPHA, is_DIGIT};
use nom::{ use nom::{
bytes::streaming::{tag, take_while1}, bytes::streaming::{tag, take_while1},
@ -67,6 +67,8 @@ pub mod atom {
IResult, IResult,
}; };
use super::folding_ws_and_comment::CFWS;
/// Printable US-ASCII characters not including specials. /// Printable US-ASCII characters not including specials.
/// Used for atoms. /// Used for atoms.
/// ///
@ -131,11 +133,6 @@ pub mod atom {
/// 3.2.4. Quoted Strings /// 3.2.4. Quoted Strings
pub mod quoted_strings { pub mod quoted_strings {
use super::{
folding_ws_and_comment::{CFWS, FWS},
obsolete::is_obs_qtext,
quoted_characters::quoted_pair,
};
use abnf_core::streaming::DQUOTE; use abnf_core::streaming::DQUOTE;
use nom::{ use nom::{
branch::alt, branch::alt,
@ -146,6 +143,12 @@ pub mod quoted_strings {
IResult, IResult,
}; };
use super::{
folding_ws_and_comment::{CFWS, FWS},
obsolete::is_obs_qtext,
quoted_characters::quoted_pair,
};
/// Printable US-ASCII characters not including "\" or the quote character. /// Printable US-ASCII characters not including "\" or the quote character.
/// ///
/// qtext = %d33 / %d35-91 / %d93-126 / obs-qtext /// qtext = %d33 / %d35-91 / %d93-126 / obs-qtext
@ -185,9 +188,10 @@ pub mod quoted_strings {
/// 3.2.5. Miscellaneous Tokens /// 3.2.5. Miscellaneous Tokens
pub mod miscellaneous { pub mod miscellaneous {
use super::{atom::atom, quoted_strings::quoted_string};
use nom::{branch::alt, IResult}; use nom::{branch::alt, IResult};
use super::{atom::atom, quoted_strings::quoted_string};
/// word = atom / quoted-string /// word = atom / quoted-string
pub fn word(input: &[u8]) -> IResult<&[u8], &[u8]> { pub fn word(input: &[u8]) -> IResult<&[u8], &[u8]> {
alt((atom, quoted_string))(input) alt((atom, quoted_string))(input)
@ -202,7 +206,6 @@ pub mod miscellaneous {
/// 3.3. Date and Time Specification /// 3.3. Date and Time Specification
pub mod datetime { pub mod datetime {
use super::folding_ws_and_comment::{CFWS, FWS};
use abnf_core::streaming::is_DIGIT; use abnf_core::streaming::is_DIGIT;
use nom::{ use nom::{
branch::alt, branch::alt,
@ -212,6 +215,8 @@ pub mod datetime {
IResult, IResult,
}; };
use super::folding_ws_and_comment::{CFWS, FWS};
// date-time = [ day-of-week "," ] date time [CFWS] // date-time = [ day-of-week "," ] date time [CFWS]
pub fn date_time(input: &[u8]) -> IResult<&[u8], &[u8]> { pub fn date_time(input: &[u8]) -> IResult<&[u8], &[u8]> {
let parser = tuple((opt(tuple((day_of_week, tag(b",")))), date, time, opt(CFWS))); let parser = tuple((opt(tuple((day_of_week, tag(b",")))), date, time, opt(CFWS)));
@ -365,12 +370,6 @@ pub mod datetime {
/// 3.4.1. Addr-Spec Specification /// 3.4.1. Addr-Spec Specification
pub mod addr_spec { pub mod addr_spec {
use super::{
atom::dot_atom,
folding_ws_and_comment::{CFWS, FWS},
obsolete::{obs_domain, obs_dtext, obs_local_part},
quoted_strings::quoted_string,
};
use nom::{ use nom::{
branch::alt, branch::alt,
bytes::streaming::{tag, take_while_m_n}, bytes::streaming::{tag, take_while_m_n},
@ -380,6 +379,13 @@ pub mod addr_spec {
IResult, IResult,
}; };
use super::{
atom::dot_atom,
folding_ws_and_comment::{CFWS, FWS},
obsolete::{obs_domain, obs_dtext, obs_local_part},
quoted_strings::quoted_string,
};
// addr-spec = local-part "@" domain // addr-spec = local-part "@" domain
/// local-part = dot-atom / quoted-string / obs-local-part /// local-part = dot-atom / quoted-string / obs-local-part
@ -442,12 +448,6 @@ pub mod addr_spec {
/// 3.6.4. Identification Fields /// 3.6.4. Identification Fields
pub mod identification { pub mod identification {
use super::{
addr_spec::dtext,
atom::dot_atom_text,
folding_ws_and_comment::CFWS,
obsolete::{obs_id_left, obs_id_right},
};
use nom::{ use nom::{
branch::alt, branch::alt,
bytes::streaming::tag, bytes::streaming::tag,
@ -457,6 +457,13 @@ pub mod identification {
IResult, IResult,
}; };
use super::{
addr_spec::dtext,
atom::dot_atom_text,
folding_ws_and_comment::CFWS,
obsolete::{obs_id_left, obs_id_right},
};
// message-id = "Message-ID:" msg-id CRLF // message-id = "Message-ID:" msg-id CRLF
// ... // ...
@ -513,12 +520,6 @@ pub mod identification {
/// 4.1. Miscellaneous Obsolete Tokens /// 4.1. Miscellaneous Obsolete Tokens
pub mod obsolete { pub mod obsolete {
use super::{
addr_spec::{domain, local_part},
atom::atom,
miscellaneous::word,
quoted_characters::quoted_pair,
};
use abnf_core::streaming::{CR, LF}; use abnf_core::streaming::{CR, LF};
use nom::{ use nom::{
branch::alt, branch::alt,
@ -529,6 +530,13 @@ pub mod obsolete {
IResult, IResult,
}; };
use super::{
addr_spec::{domain, local_part},
atom::atom,
miscellaneous::word,
quoted_characters::quoted_pair,
};
/// US-ASCII control characters that do not include the carriage /// US-ASCII control characters that do not include the carriage
/// return, line feed, and white space characters /// return, line feed, and white space characters
/// ///

View File

@ -1,6 +1,7 @@
#![allow(non_snake_case)] #![allow(non_snake_case)]
use crate::{parse::imf::atom::is_atext, types::AtomOrQuoted, utils::unescape_quoted}; use std::{borrow::Cow, str::from_utf8};
use abnf_core::streaming::{is_ALPHA, is_DIGIT, DQUOTE}; use abnf_core::streaming::{is_ALPHA, is_DIGIT, DQUOTE};
use nom::{ use nom::{
branch::alt, branch::alt,
@ -11,7 +12,8 @@ use nom::{
sequence::{delimited, tuple}, sequence::{delimited, tuple},
IResult, IResult,
}; };
use std::{borrow::Cow, str::from_utf8};
use crate::{parse::imf::atom::is_atext, types::AtomOrQuoted, utils::unescape_quoted};
pub mod address; pub mod address;
pub mod command; pub mod command;

View File

@ -1,7 +1,3 @@
use crate::{
parse::{address::address_literal, number, Domain},
types::{AuthMechanism, Capability, Response},
};
use abnf_core::streaming::{is_ALPHA, is_DIGIT, CRLF, SP}; use abnf_core::streaming::{is_ALPHA, is_DIGIT, CRLF, SP};
use nom::{ use nom::{
branch::alt, branch::alt,
@ -12,6 +8,11 @@ use nom::{
IResult, IResult,
}; };
use crate::{
parse::{address::address_literal, number, Domain},
types::{AuthMechanism, Capability, Response},
};
/// Greeting = ( "220 " (Domain / address-literal) [ SP textstring ] CRLF ) / /// Greeting = ( "220 " (Domain / address-literal) [ SP textstring ] CRLF ) /
/// ( "220-" (Domain / address-literal) [ SP textstring ] CRLF /// ( "220-" (Domain / address-literal) [ SP textstring ] CRLF
/// *( "220-" [ textstring ] CRLF ) /// *( "220-" [ textstring ] CRLF )

View File

@ -1,13 +1,3 @@
use crate::parse::{
address::address_literal,
command::{Mailbox, Path, Reverse_path},
imf::{
datetime::date_time,
folding_ws_and_comment::{CFWS, FWS},
identification::msg_id,
},
Atom, Domain, String,
};
/// 4.4. Trace Information (RFC 5321) /// 4.4. Trace Information (RFC 5321)
use abnf_core::streaming::CRLF; use abnf_core::streaming::CRLF;
use nom::{ use nom::{
@ -19,6 +9,17 @@ use nom::{
IResult, IResult,
}; };
use crate::parse::{
address::address_literal,
command::{Mailbox, Path, Reverse_path},
imf::{
datetime::date_time,
folding_ws_and_comment::{CFWS, FWS},
identification::msg_id,
},
Atom, Domain, String,
};
/// Return-path-line = "Return-Path:" FWS Reverse-path <CRLF> /// Return-path-line = "Return-Path:" FWS Reverse-path <CRLF>
pub fn Return_path_line(input: &[u8]) -> IResult<&[u8], &[u8]> { pub fn Return_path_line(input: &[u8]) -> IResult<&[u8], &[u8]> {
let parser = tuple((tag_no_case(b"Return-Path:"), FWS, Reverse_path, CRLF)); let parser = tuple((tag_no_case(b"Return-Path:"), FWS, Reverse_path, CRLF));

View File

@ -1,7 +1,9 @@
use crate::utils::escape_quoted; use std::io::Write;
#[cfg(feature = "serdex")] #[cfg(feature = "serdex")]
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::io::Write;
use crate::utils::escape_quoted;
#[derive(Clone, Debug, PartialEq, Eq)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum Command { pub enum Command {