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

Fix bypass rules filter #1837

Merged

Conversation

ChinmayaSharma-hue
Copy link
Contributor

@ChinmayaSharma-hue ChinmayaSharma-hue commented Apr 18, 2024

Related Issue

  • Bypass Rules not leading to pass through

Closes: #1827

Describe the changes you've made

  • Fixed the bug related to bypass rules not working which was basically passing empty bypass rule in the GetOutgoing function in the Start method of the recorder.
  • Concatenation of bypass rules and the extended version of bypass rule - Filter, and modification of function arguments taking []config.BypassRule to []config.Filters.
  • Addition of support to perform bypass based on URL methods and Headers in isPassThrough function.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Please let us know if any test cases are added

NA

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Testcases Working

For flask-mongo application,

  1. Specifying path and port only in filters,
    filters: [
        {
            path: "/students",
            port: 6000,
        }
    ]

The following curl requests aren't being recorded,

curl -k -v http://127.0.0.1:6000/students
curl -X POST http://localhost:6000/students \
     -H "Content-Type: application/json" \
     -d '{"name": "Working John Doe", "age": 21}'
  1. Specifying GET Url method in filter,
    filters: [
        {
            path: "/students",
            port: 6000,
            urlMethods: ["GET"]
        }
    ]

The following curl requests aren't being recorded,

curl -k -v http://127.0.0.1:6000/students

The following curl request is being recorded,

curl -X POST http://localhost:6000/students \
     -H "Content-Type: application/json" \
     -d '{"name": "Working John Doe", "age": 21}'
  1. Specifying POST Url method in filter,
    filters: [
        {
            path: "/students",
            port: 6000,
            urlMethods: ["POST"]
        }
    ]

The following curl requests aren't being recorded,

curl -X POST http://localhost:6000/students \
     -H "Content-Type: application/json" \
     -d '{"name": "Working John Doe", "age": 21}'

The following curl request is being recorded,

curl -k -v http://127.0.0.1:6000/students
  1. Specifying header in filter,
    filters: [
        {
            path: "/students",
            port: 6000,
            urlMethods: ["POST"],
            headers: {
                data: "dummy",
            }

        }
    ]

The following curl requests aren't being recorded,

curl -X POST http://localhost:6000/students \
     -H "Content-Type: application/json" \
     -H "data: dummy" \
     -d '{"name": "Working John Doe", "age": 21}'

The following curl requests are being recorded,

curl -X POST http://localhost:6000/students \
     -H "Content-Type: application/json" \
     -d '{"name": "Working John Doe", "age": 21}'
curl -k -v http://127.0.0.1:6000/students
  1. Specifying header without URL method in filter,
    filters: [
        {
            path: "/students",
            port: 6000,
            headers: {
                data: "dummy",
            }

        }
    ]

The following curl requests aren't being recorded,

curl -k -v -H "data: dummy" http://127.0.0.1:6000/students
curl -X POST http://localhost:6000/students \
     -H "Content-Type: application/json" \
     -H "data: dummy" \
     -d '{"name": "Working John Doe", "age": 21}'

The following curl requests are being recorded,

curl -k -v http://127.0.0.1:6000/students
curl -X POST http://localhost:6000/students \
     -H "Content-Type: application/json" \
     -d '{"name": "Working John Doe", "age": 21}'

Screenshots (if any)

NA

Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
…eader bypass

Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
Signed-off-by: Chinmay <chinmaysharma1020@gmail.com>
@shivamsouravjha shivamsouravjha merged commit f898233 into keploy:main May 10, 2024
18 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: bypass rules not working
2 participants