ksud: upgrade nom to 8.0

This commit is contained in:
weishu
2025-02-24 16:45:24 +08:00
parent bcdc860a5b
commit e245e3419d
3 changed files with 17 additions and 25 deletions

View File

@@ -935,12 +935,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.8.5"
@@ -952,12 +946,11 @@ dependencies = [
[[package]]
name = "nom"
version = "7.1.3"
version = "8.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]

View File

@@ -27,7 +27,7 @@ libc = "0.2"
extattr = "1"
jwalk = "0.8"
is_executable = "1"
nom = "=7"
nom = "8"
derive-new = "0.7"
rust-embed = { version = "8", features = [
"debug-embed",

View File

@@ -3,20 +3,16 @@ use derive_new::new;
use nom::{
branch::alt,
bytes::complete::{tag, take_while, take_while1, take_while_m_n},
character::{
complete::{space0, space1},
is_alphanumeric,
},
character::complete::{space0, space1},
combinator::map,
sequence::Tuple,
IResult, Parser,
AsChar, IResult, Parser,
};
use std::{ffi, path::Path, vec};
type SeObject<'a> = Vec<&'a str>;
fn is_sepolicy_char(c: char) -> bool {
is_alphanumeric(c as u8) || c == '_' || c == '-'
c.is_alphanum() || c == '_' || c == '-'
}
fn parse_single_word(input: &str) -> IResult<&str, &str> {
@@ -173,7 +169,8 @@ impl<'a> SeObjectParser<'a> for NormalPerm<'a> {
tag("deny"),
tag("auditallow"),
tag("dontaudit"),
))(input)?;
))
.parse(input)?;
let (input, _) = space0(input)?;
let (input, source) = parse_seobj(input)?;
@@ -193,7 +190,8 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> {
tag("allowxperm"),
tag("auditallowxperm"),
tag("dontauditxperm"),
))(input)?;
))
.parse(input)?;
let (input, _) = space0(input)?;
let (input, source) = parse_seobj(input)?;
@@ -215,7 +213,7 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> {
impl<'a> SeObjectParser<'a> for TypeState<'a> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
let (input, op) = alt((tag("permissive"), tag("enforce")))(input)?;
let (input, op) = alt((tag("permissive"), tag("enforce"))).parse(input)?;
let (input, _) = space1(input)?;
let (input, stype) = parse_seobj_no_star(input)?;
@@ -243,7 +241,7 @@ impl<'a> SeObjectParser<'a> for Type<'a> {
impl<'a> SeObjectParser<'a> for TypeAttr<'a> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
let (input, _) = alt((tag("typeattribute"), tag("attradd")))(input)?;
let (input, _) = alt((tag("typeattribute"), tag("attradd"))).parse(input)?;
let (input, _) = space1(input)?;
let (input, stype) = parse_seobj_no_star(input)?;
let (input, _) = space1(input)?;
@@ -265,7 +263,7 @@ impl<'a> SeObjectParser<'a> for Attr<'a> {
impl<'a> SeObjectParser<'a> for TypeTransition<'a> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
let (input, _) = alt((tag("type_transition"), tag("name_transition")))(input)?;
let (input, _) = alt((tag("type_transition"), tag("name_transition"))).parse(input)?;
let (input, _) = space1(input)?;
let (input, source) = parse_single_word(input)?;
let (input, _) = space1(input)?;
@@ -294,7 +292,7 @@ impl<'a> SeObjectParser<'a> for TypeTransition<'a> {
impl<'a> SeObjectParser<'a> for TypeChange<'a> {
fn parse(input: &'a str) -> IResult<&'a str, Self> {
let (input, op) = alt((tag("type_change"), tag("type_member")))(input)?;
let (input, op) = alt((tag("type_change"), tag("type_member"))).parse(input)?;
let (input, _) = space1(input)?;
let (input, source) = parse_single_word(input)?;
let (input, _) = space1(input)?;
@@ -337,7 +335,8 @@ impl<'a> PolicyStatement<'a> {
map(TypeTransition::parse, PolicyStatement::TypeTransition),
map(TypeChange::parse, PolicyStatement::TypeChange),
map(GenFsCon::parse, PolicyStatement::GenFsCon),
))(input)?;
))
.parse(input)?;
let (input, _) = space0(input)?;
let (input, _) = take_while(|c| c == ';')(input)?;
let (input, _) = space0(input)?;