Skip to content

Fix: unique ruleid-testid displayed for unit tests #32

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

Merged
merged 1 commit into from
May 7, 2025

Conversation

Sebitosh
Copy link
Contributor

@Sebitosh Sebitosh commented May 7, 2025

As discussed in #24

Goes from displaying go-ftw test ids that are based on the MRTS test id (which is repeated and does not allow to understand what exact rule failed) to displaying test ids based on the generated rule matching the generated test. The fix is to place the generated rule's ID earlier in the file name than any other number (in our case the test ID we name our MRTS test files). This fix appends the ruleid at the beginning of the file instead of at the end.

The display goes from:

👉 executing tests in file MRTS_002_ARGS.yaml
	running 2-1: ✔ passed in 12.842548ms (RTT 54.970028ms)
	running 2-2: ✔ passed in 12.049459ms (RTT 54.891019ms)
	running 2-3: ✔ passed in 10.790834ms (RTT 53.365412ms)
	running 2-4: ✔ passed in 10.695786ms (RTT 53.515826ms)
👉 executing tests in file MRTS_002_ARGS.yaml
	running 2-1: ✔ passed in 8.615306ms (RTT 52.334647ms)
	running 2-2: ✔ passed in 7.64326ms (RTT 52.301444ms)
	running 2-3: ✔ passed in 8.353395ms (RTT 52.289161ms)
	running 2-4: ✔ passed in 8.704224ms (RTT 52.993254ms)

To:

👉 executing tests in file MRTS_002_ARGS_A-GET.yaml
	running 100000-1: ✔ passed in 4.03606ms (RTT 51.456201ms)
	running 100000-2: ✔ passed in 2.100709ms (RTT 50.672271ms)
	running 100000-3: ✔ passed in 3.572981ms (RTT 51.673479ms)
	running 100000-4: ✔ passed in 2.85232ms (RTT 50.599715ms)
👉 executing tests in file MRTS_002_ARGS_A-GET.yaml
	running 100001-1: ✔ passed in 2.102875ms (RTT 50.515938ms)
	running 100001-2: ✔ passed in 2.188394ms (RTT 50.675838ms)
	running 100001-3: ✔ passed in 2.013156ms (RTT 50.583605ms)
	running 100001-4: ✔ passed in 1.750534ms (RTT 50.572695ms)
👉 executing tests in file MRTS_002_ARGS_A-GET.yaml
	running 100002-1: ✔ passed in 1.529288ms (RTT 50.430978ms)
	running 100002-2: ✔ passed in 1.516805ms (RTT 50.58156ms)
	running 100002-3: ✔ passed in 1.440502ms (RTT 50.483487ms)
	running 100002-4: ✔ passed in 1.64741ms (RTT 50.50112ms)

And the generated test files are now named:

$ ls

100000_MRTS_002_ARGS_A-GET.yaml          100032_MRTS_004_ARGS_GET.yaml        100064_MRTS_006_ARGS_NAMES_A-GET.yaml
100001_MRTS_002_ARGS_A-GET.yaml          100033_MRTS_004_ARGS_GET.yaml        100065_MRTS_006_ARGS_NAMES_A-GET.yaml
100002_MRTS_002_ARGS_A-GET.yaml          100034_MRTS_004_ARGS_GET.yaml        100066_MRTS_006_ARGS_NAMES_A-GET.yaml
100003_MRTS_002_ARGS_A-GET.yaml          100035_MRTS_004_ARGS_GET.yaml        100067_MRTS_006_ARGS_NAMES_A-GET.yaml
...

Copy link
Member

@airween airween left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@airween airween merged commit 468481e into owasp-modsecurity:main May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants