Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard based packet filtering isn't working as expected #2075

Closed
5 tasks done
hu55a1n1 opened this issue Apr 6, 2022 · 1 comment · Fixed by #2076
Closed
5 tasks done

Wildcard based packet filtering isn't working as expected #2075

hu55a1n1 opened this issue Apr 6, 2022 · 1 comment · Fixed by #2076
Assignees
Labels
A: bug Admin: something isn't working
Milestone

Comments

@hu55a1n1
Copy link
Member

hu55a1n1 commented Apr 6, 2022

Summary of Bug

Packet filtering wildcards are not working as expected, for eg. the below wilcard PortId 'transfer*' is matching 'ft-transfer'.

policy = 'allow'
list = [
    ['transfer*', 'channel-1'],
]

Version

v0.13.0

Failing test

#[test]
fn packet_filter_regex() {
    let allow_policy = r#"
            policy = 'allow'
            list = [
              ['transfer*', 'channel-1'],
            ]
            "#;

    let pf: PacketFilter = toml::from_str(allow_policy).expect("could not parse filter policy");
    assert!(!pf.is_allowed(
        &PortId::from_str("ft-transfer").unwrap(),
        &ChannelId::from_str("channel-1").unwrap()
    ));
}

Acceptance Criteria

The above test must pass or we should clarify what the wildcard means/matches; the documentation describes the wildcard ica* as all identifiers starting with ica -> https://github.com/informalsystems/ibc-rs/blob/master/config.toml#L206-L212

#             Optionally, each element may also contains wildcards, for eg. 'ica*'
#             to match all identifiers starting with 'ica' or '*' to match all identifiers.

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@romac
Copy link
Member

romac commented Apr 7, 2022

Looks like we forgot to anchor the regex with ^ and $, therefore it matches anywhere within the string. Should be an easy fix, thanks for the report and the test!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: bug Admin: something isn't working
Projects
No open projects
Status: Closed
2 participants