Skip to content
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

feat: NGINX Version #1462

Merged
merged 12 commits into from
Sep 1, 2024
Merged

feat: NGINX Version #1462

merged 12 commits into from
Sep 1, 2024

Conversation

yodigos
Copy link
Contributor

@yodigos yodigos commented Aug 25, 2024

No description provided.

procdiscovery/pkg/inspectors/nginx/nginx.go Outdated Show resolved Hide resolved
procdiscovery/pkg/inspectors/nginx/nginx.go Show resolved Hide resolved
procdiscovery/pkg/inspectors/nginx/nginx.go Outdated Show resolved Hide resolved
procdiscovery/pkg/inspectors/langdetect.go Outdated Show resolved Hide resolved
procdiscovery/pkg/inspectors/langdetect.go Outdated Show resolved Hide resolved
procdiscovery/pkg/inspectors/langdetect.go Outdated Show resolved Hide resolved
@@ -119,10 +120,15 @@ func runtimeInspection(pods []corev1.Pod, ignoredContainers []string) ([]odigosv
}
}

runtimeVersion := ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
runtimeVersion := ""
var runtimeVersion string


func (g *GolangInspector) GetRuntimeVersion(p *process.Details, containerURL string) *version.Version {
file := fmt.Sprintf("/proc/%d/exe", p.ProcessID)
buildInfo, err := buildinfo.ReadFile(file)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We are calling ReadFile twice for each Go process, if it is possible to reuse the buildInfo from the Inspect function it will be better

return programLanguageDetails, true
func (j *JavaInspector) GetRuntimeVersion(proc *process.Details, containerURL string) *version.Version {
if value, exists := proc.GetDetailedEnvsValue(process.JavaVersionConst); exists {
re := regexp.MustCompile(JavaVersionRegex)
Copy link
Contributor

Choose a reason for hiding this comment

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

define as a global const, avoiding re-compiliong the regex each time

return "", nil
}

re := regexp.MustCompile(NginxVersionRegex)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as the comment for the other regex - use as a const

}
match := re.FindStringSubmatch(buildInfo.GoVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why we need this regex here. The buildinfo package is an official go package which should provide a valid go version if one exists.

@yodigos yodigos merged commit e12b670 into odigos-io:main Sep 1, 2024
22 checks passed
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.

3 participants