Skip to content

Commit

Permalink
🐛 Filename() panics when non-file URI is passed
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
  • Loading branch information
pranavgaikwad committed Apr 15, 2024
1 parent ef5b9ec commit 3d71f9a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"context"
"fmt"
"net/url"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -414,6 +415,10 @@ func processRule(ctx context.Context, rule Rule, ruleCtx ConditionContext, log l
func (r *ruleEngine) getRelativePathForViolation(fileURI uri.URI) (uri.URI, error) {
var sourceLocation string
if fileURI != "" {
u, err := url.ParseRequestURI(string(fileURI))
if err != nil || u.Scheme != uri.FileScheme {
return fileURI, nil
}
file := fileURI.Filename()
// get the correct source
for _, locationPrefix := range r.locationPrefixes {
Expand Down

0 comments on commit 3d71f9a

Please sign in to comment.