@@ -3,20 +3,16 @@ use derive_new::new;
3
3
use nom:: {
4
4
branch:: alt,
5
5
bytes:: complete:: { tag, take_while, take_while1, take_while_m_n} ,
6
- character:: {
7
- complete:: { space0, space1} ,
8
- is_alphanumeric,
9
- } ,
6
+ character:: complete:: { space0, space1} ,
10
7
combinator:: map,
11
- sequence:: Tuple ,
12
- IResult , Parser ,
8
+ AsChar , IResult , Parser ,
13
9
} ;
14
10
use std:: { ffi, path:: Path , vec} ;
15
11
16
12
type SeObject < ' a > = Vec < & ' a str > ;
17
13
18
14
fn is_sepolicy_char ( c : char ) -> bool {
19
- is_alphanumeric ( c as u8 ) || c == '_' || c == '-'
15
+ c . is_alphanum ( ) || c == '_' || c == '-'
20
16
}
21
17
22
18
fn parse_single_word ( input : & str ) -> IResult < & str , & str > {
@@ -173,7 +169,8 @@ impl<'a> SeObjectParser<'a> for NormalPerm<'a> {
173
169
tag ( "deny" ) ,
174
170
tag ( "auditallow" ) ,
175
171
tag ( "dontaudit" ) ,
176
- ) ) ( input) ?;
172
+ ) )
173
+ . parse ( input) ?;
177
174
178
175
let ( input, _) = space0 ( input) ?;
179
176
let ( input, source) = parse_seobj ( input) ?;
@@ -193,7 +190,8 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> {
193
190
tag ( "allowxperm" ) ,
194
191
tag ( "auditallowxperm" ) ,
195
192
tag ( "dontauditxperm" ) ,
196
- ) ) ( input) ?;
193
+ ) )
194
+ . parse ( input) ?;
197
195
198
196
let ( input, _) = space0 ( input) ?;
199
197
let ( input, source) = parse_seobj ( input) ?;
@@ -215,7 +213,7 @@ impl<'a> SeObjectParser<'a> for XPerm<'a> {
215
213
216
214
impl < ' a > SeObjectParser < ' a > for TypeState < ' a > {
217
215
fn parse ( input : & ' a str ) -> IResult < & ' a str , Self > {
218
- let ( input, op) = alt ( ( tag ( "permissive" ) , tag ( "enforce" ) ) ) ( input) ?;
216
+ let ( input, op) = alt ( ( tag ( "permissive" ) , tag ( "enforce" ) ) ) . parse ( input) ?;
219
217
220
218
let ( input, _) = space1 ( input) ?;
221
219
let ( input, stype) = parse_seobj_no_star ( input) ?;
@@ -243,7 +241,7 @@ impl<'a> SeObjectParser<'a> for Type<'a> {
243
241
244
242
impl < ' a > SeObjectParser < ' a > for TypeAttr < ' a > {
245
243
fn parse ( input : & ' a str ) -> IResult < & ' a str , Self > {
246
- let ( input, _) = alt ( ( tag ( "typeattribute" ) , tag ( "attradd" ) ) ) ( input) ?;
244
+ let ( input, _) = alt ( ( tag ( "typeattribute" ) , tag ( "attradd" ) ) ) . parse ( input) ?;
247
245
let ( input, _) = space1 ( input) ?;
248
246
let ( input, stype) = parse_seobj_no_star ( input) ?;
249
247
let ( input, _) = space1 ( input) ?;
@@ -265,7 +263,7 @@ impl<'a> SeObjectParser<'a> for Attr<'a> {
265
263
266
264
impl < ' a > SeObjectParser < ' a > for TypeTransition < ' a > {
267
265
fn parse ( input : & ' a str ) -> IResult < & ' a str , Self > {
268
- let ( input, _) = alt ( ( tag ( "type_transition" ) , tag ( "name_transition" ) ) ) ( input) ?;
266
+ let ( input, _) = alt ( ( tag ( "type_transition" ) , tag ( "name_transition" ) ) ) . parse ( input) ?;
269
267
let ( input, _) = space1 ( input) ?;
270
268
let ( input, source) = parse_single_word ( input) ?;
271
269
let ( input, _) = space1 ( input) ?;
@@ -294,7 +292,7 @@ impl<'a> SeObjectParser<'a> for TypeTransition<'a> {
294
292
295
293
impl < ' a > SeObjectParser < ' a > for TypeChange < ' a > {
296
294
fn parse ( input : & ' a str ) -> IResult < & ' a str , Self > {
297
- let ( input, op) = alt ( ( tag ( "type_change" ) , tag ( "type_member" ) ) ) ( input) ?;
295
+ let ( input, op) = alt ( ( tag ( "type_change" ) , tag ( "type_member" ) ) ) . parse ( input) ?;
298
296
let ( input, _) = space1 ( input) ?;
299
297
let ( input, source) = parse_single_word ( input) ?;
300
298
let ( input, _) = space1 ( input) ?;
@@ -337,7 +335,8 @@ impl<'a> PolicyStatement<'a> {
337
335
map ( TypeTransition :: parse, PolicyStatement :: TypeTransition ) ,
338
336
map ( TypeChange :: parse, PolicyStatement :: TypeChange ) ,
339
337
map ( GenFsCon :: parse, PolicyStatement :: GenFsCon ) ,
340
- ) ) ( input) ?;
338
+ ) )
339
+ . parse ( input) ?;
341
340
let ( input, _) = space0 ( input) ?;
342
341
let ( input, _) = take_while ( |c| c == ';' ) ( input) ?;
343
342
let ( input, _) = space0 ( input) ?;
0 commit comments