Skip to content
New issue

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

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

Already on GitHub? # to your account

JUnit output format fails: invalid memory address #1306

Closed
OhMyGuus opened this issue Dec 18, 2024 · 6 comments · Fixed by #1307
Closed

JUnit output format fails: invalid memory address #1306

OhMyGuus opened this issue Dec 18, 2024 · 6 comments · Fixed by #1307

Comments

@OhMyGuus
Copy link

Hey, I'm trying to use the JUnit output, but for some reason, it fails with a memory error.
Tried other formats and those are working fine.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xf2245c]

goroutine 1 [running]:
github.com/styrainc/regal/pkg/reporter.JUnitReporter.Publish({{0x1943a20?, 0xc0000a6028?}}, {0xc000b08ef8?, 0xc000a2e5c0?}, {0x0, 0x0, 0x0, 0x0, {0xc000245008, 0x28, ...}, ...})
        /home/runner/work/regal/regal/pkg/reporter/reporter.go:525 +0x85c
github.com/styrainc/regal/cmd.lint({0xc000896a80, 0x1, 0x3}, 0xc000c7d680)
        /home/runner/work/regal/regal/cmd/lint.go:341 +0x17f4
github.com/styrainc/regal/cmd.init.4.func2({0xc000896a80, 0x1, 0x3})
        /home/runner/work/regal/regal/cmd/lint.go:109 +0xb4
github.com/styrainc/regal/cmd.init.4.wrapProfiling.func3(0xc0002bf208, {0xc000896a80, 0x1, 0x3})
        /home/runner/work/regal/regal/cmd/profiling.go:16 +0x733
github.com/spf13/cobra.(*Command).execute(0xc0002bf208, {0xc000896a20, 0x3, 0x3})
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0x222b560)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x0?)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041 +0x13
main.main()
        /home/runner/work/regal/regal/main.go:16 +0x2b

command used:

regal lint --format junit ./policies/claims

@anderseknert
Copy link
Member

Hi there, and thanks for reporting this issue. The JUnit format is a recent contribution, and I guess not as well-tested as the others. But that's no excuse! And that's a nil dereference alright

strings.TrimSpace(*violation.Location.Text),

While I wasn't able to directly reproduce it here, what seems to happen is that you have a violation that doesn't have a corresponding text attribute, and we're trying to print something that doesn't exist. Fixing.

anderseknert added a commit that referenced this issue Dec 18, 2024
Fixes #1306

Thanks @OhMyGuus for reporting the issue!

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Dec 18, 2024
Fixes #1306

Thanks @OhMyGuus for reporting the issue!

(Unrelated to the issue, but I'm also reverting the URL change of that integration
 test we changed recently... as the URL in OPA is now back to what it was before :)

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert
Copy link
Member

PR is up and the fix will be included in the next release. Might be that's after the holidays though, so if you want, you can download a binary with the fix from the PR build. You'll find the artifacts in the bottom of this page https://github.com/StyraInc/regal/actions/runs/12400026924

(There's no Windows build there though, for reasons I don't remember 😅 so if that's your platform, you'll have to go build yourself)

anderseknert added a commit that referenced this issue Dec 18, 2024
Fixes #1306

Thanks @OhMyGuus for reporting the issue!

(Unrelated to the issue, but I'm also reverting the URL change of that integration
 test we changed recently... as the URL in OPA is now back to what it was before :)

Signed-off-by: Anders Eknert <anders@styra.com>
@OhMyGuus
Copy link
Author

OhMyGuus commented Dec 19, 2024

Thanks a lot @anderseknert for the fast response, seems to work fine with the new build! 😄

@anderseknert
Copy link
Member

Awesome! May I ask what you’re using the JUnit output for? I think the contributor of that format mentioned GitLab support, but I could be wrong. Mostly just curious to learn which tools people use together with Regal, and how 🙂

@OhMyGuus
Copy link
Author

Awesome! May I ask what you’re using the JUnit output for? I think the contributor of that format mentioned GitLab support, but I could be wrong. Mostly just curious to learn which tools people use together with Regal, and how 🙂

We use the JUnit output in the Azure pipelines, along with the PublishTestResults@2 task to publish them to an overview within Azure DevOps.

@anderseknert
Copy link
Member

Thanks! 👍

charlieegan3 pushed a commit to charlieegan3/regal that referenced this issue Jan 6, 2025
Fixes StyraInc#1306

Thanks @OhMyGuus for reporting the issue!

(Unrelated to the issue, but I'm also reverting the URL change of that integration
 test we changed recently... as the URL in OPA is now back to what it was before :)

Signed-off-by: Anders Eknert <anders@styra.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants