Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Enhance go port recognition#181

Merged
thepetk merged 6 commits intoredhat-developer:mainfrom
thepetk:enhance_go_port_recognition
Apr 19, 2023
Merged

Enhance go port recognition#181
thepetk merged 6 commits intoredhat-developer:mainfrom
thepetk:enhance_go_port_recognition

Conversation

@thepetk
Copy link
Collaborator

@thepetk thepetk commented Apr 14, 2023

What does this PR do?

Implements an additional check for port recognition upon go_enricher checks. More detailed, inside the GoEnricher.DoEnrichComponent for case: model.Source if all checks inside framework.***Detector.DoPortDetection have not returned any ports, it runs the framework.DoGoPortsDetection in order to check if there are any ports specified inside the root folder of the project.

case model.Source:
	{
		for _, detector := range getGoFrameworkDetectors() {
			for _, framework := range component.Languages[0].Frameworks {
				if utils.Contains(detector.GetSupportedFrameworks(), framework) {
					detector.DoPortsDetection(component, ctx)
				}
			}
		}
		if len(component.Ports) == 0 {
			framework.DoGoPortsDetection(component, ctx)
		}
	}
}

The framework.DoGoPortsDetection uses the same functionality for source port recognition (like other framework detectors). Finally a test case for Go project recognition is added in the test cases, along with a test project.

Which issue(s) this PR fixes:

This PR partially fixes: #146

func main() {
http.HandleFunc("/", HelloHandler)
fmt.Println("Listening on localhost:8080")
http.ListenAndServe(":8080", nil)

Check failure

Code scanning / gosec

Use of net/http serve function that has no support for setting timeouts

Use of net/http serve function that has no support for setting timeouts
}

for _, file := range files {
bytes, err := os.ReadFile(file)

Check failure

Code scanning / gosec

Potential file inclusion via variable

Potential file inclusion via variable
func main() {
http.HandleFunc("/", HelloHandler)
fmt.Println("Listening on localhost:8080")
http.ListenAndServe(":8080", nil)

Check warning

Code scanning / gosec

Errors unhandled.

Errors unhandled.
@thepetk thepetk requested a review from mike-hoang April 18, 2023 12:50
@thepetk thepetk merged commit 894ac41 into redhat-developer:main Apr 19, 2023
thepetk added a commit to thepetk/alizer that referenced this pull request Apr 20, 2023
* Add udi image case for mocked values of devfile types

Signed-off-by: thepetk <[email protected]>

* Add Go ports detection for project without framework

Signed-off-by: thepetk <[email protected]>

* Add tests for raw go project port recognition

Signed-off-by: thepetk <[email protected]>

* Remove unnecessary comments on test project

Signed-off-by: thepetk <[email protected]>

---------

Signed-off-by: thepetk <[email protected]>
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.

Alizer should be more resilient when detecting ports in a component

2 participants