This repository was archived by the owner on Oct 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
This repository was archived by the owner on Oct 10, 2023. It is now read-only.
Regular expressions in port detection might panic #220
Copy link
Copy link
Closed
Labels
kind/bugSomething isn't workingSomething isn't working
Description
Which area this feature is related to?
/kind bug
What versions of software are you using?
Go project
Operating System and version:
Fedora 38
Go Pkg Version:
We are currently using Alizer on a1115da, but I locally tested by using the latest commit (59b155e), and the issue still persists.
Bug Summary
Describe the bug:
Tried to run odo analyze against https://github.com/backstage/backstage.
odo analyze is basically a wrapper around Alizer for Devfile, port and component name detection.
To Reproduce:
git clone https://github.com/backstage/backstage
cd backstage
# Install odo: https://odo.dev/docs/overview/installation
odo analyze -o jsonExpected behavior
Not panicking, but returning an appropriate error to the caller, so they can handle it.
Any logs, error output, screenshots etc? Provide the devfile that sees this bug, if applicable
$ odo analyze -o json
panic: regexp: Compile("(let|const|var)\\s+{\n onUnhandledRequest: ({ headers }\\s*=\\s*([^;]*)"): error parsing regexp: missing closing ): `(let|const|var)\s+{
onUnhandledRequest: ({ headers }\s*=\s*([^;]*)`
goroutine 71 [running]:
regexp.MustCompile({0xc000b4bc70, 0x48})
/home/asoro/.asdf/installs/golang/1.19.6/go/src/regexp/regexp.go:319 +0xbb
github.com/redhat-developer/alizer/go/pkg/apis/enricher/framework/javascript/nodejs.getPort({0xc000744c80, 0xc6d}, {0xc000b81d80, 0x111f11f?, 0x33acb6e?})
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/enricher/framework/javascript/nodejs/express_detector.go:86 +0x199
github.com/redhat-developer/alizer/go/pkg/apis/enricher/framework/javascript/nodejs.ExpressDetector.DoPortsDetection({}, 0xc0000c3a90, 0xd?)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/enricher/framework/javascript/nodejs/express_detector.go:51 +0x20b
github.com/redhat-developer/alizer/go/pkg/apis/enricher.JavaScriptEnricher.DoEnrichComponent({}, 0xc0000c3a90, {{0xc00005c184, 0x1e}, {0xc000a98b10, 0x3, 0x3}}, 0x4cc5010?)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/enricher/javascript_enricher.go:94 +0x5e8
github.com/redhat-developer/alizer/go/pkg/apis/recognizer.enrichComponent(0xc0000c3a90, {{0xc00005c184, 0x1e}, {0xc000a98b10, 0x3, 0x3}}, 0xc000492150?)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/recognizer/component_recognizer.go:331 +0x89
github.com/redhat-developer/alizer/go/pkg/apis/recognizer.detectComponentByAnalyzingConfigFile({0xc000a33680, 0x41}, {0xc000867610, 0xa}, {{0xc00005c184, 0x1e}, {0xc000a98b10, 0x3, 0x3}}, 0xc000ac6050)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/recognizer/component_recognizer.go:303 +0x3ae
github.com/redhat-developer/alizer/go/pkg/apis/recognizer.detectComponentUsingConfigFile({0xc000a33680, 0x41}, {0xc00080de40?, 0x2, 0x2}, {{0xc00005c184, 0x1e}, {0xc000a98b10, 0x3, 0x3}}, ...)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/recognizer/component_recognizer.go:316 +0x15a
github.com/redhat-developer/alizer/go/pkg/apis/recognizer.DetectComponentsFromFilesList({0xc0010b6000, 0x2b50, 0xc000ac6050?}, {{0xc00005c184, 0x1e}, {0xc000a98b10, 0x3, 0x3}}, 0xc000a98b10?)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/recognizer/component_recognizer.go:229 +0x327
github.com/redhat-developer/alizer/go/pkg/apis/recognizer.detectComponentsWithSettings({{0xc00005c184, 0x1e}, {0xc000a98b10, 0x3, 0x3}}, 0x4b4e680?)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/recognizer/component_recognizer.go:86 +0xa5
github.com/redhat-developer/alizer/go/pkg/apis/recognizer.detectComponentsWithPathAndPortStartegy(...)
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/recognizer/component_recognizer.go:55
github.com/redhat-developer/alizer/go/pkg/apis/recognizer.DetectComponents({0xc00005c184, 0x1e})
/home/asoro/work/projects/odo/vendor/github.com/redhat-developer/alizer/go/pkg/apis/recognizer/component_recognizer.go:34 +0xd1
github.com/redhat-developer/odo/pkg/alizer.(*Alizer).DetectPorts(0x34442f0?, {0xc00005c184, 0x1e})
/home/asoro/work/projects/odo/pkg/alizer/alizer.go:128 +0x2d
github.com/redhat-developer/odo/pkg/init/backend.(*AlizerBackend).SelectDevfile.func1.1(0xc000699ae0, {0x380a598, 0xc000992fc0}, {0xc00005c184, 0x1e})
/home/asoro/work/projects/odo/pkg/init/backend/alizer.go:57 +0x3af
github.com/redhat-developer/odo/pkg/init/backend.(*AlizerBackend).SelectDevfile.func1()
/home/asoro/work/projects/odo/pkg/init/backend/alizer.go:80 +0x36
created by github.com/redhat-developer/odo/pkg/init/backend.(*AlizerBackend).SelectDevfile
/home/asoro/work/projects/odo/pkg/init/backend/alizer.go:46 +0x12a
Additional context
Observed in the following issues:
- Unable to use odo with complex NodeJS project (big number of dependencies) odo#6836
odo devfreezes then panics when run from~odo#6780
Any workaround?
—
Suggestion on how to fix the bug
We guessed Alizer should take care with regexp.MustCompile when the regular expression is dynamic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done